Skip to content

Commit

Permalink
Corrected DID Document building
Browse files Browse the repository at this point in the history
Signed-off-by: artem.ivanov <[email protected]>
  • Loading branch information
Artemkaaas committed Jan 30, 2024
1 parent 4952bd3 commit 9bb3ad1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions vdr/src/contracts/did/types/did_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub enum VerificationKeyType {
JsonWebKey2020,
EcdsaSecp256k1VerificationKey2019,
EcdsaSecp256k1VerificationKey2020,
EcdsaSecp256k1RecoveryMethod2020,
}

impl ToString for VerificationKeyType {
Expand All @@ -130,6 +131,9 @@ impl ToString for VerificationKeyType {
| VerificationKeyType::EcdsaSecp256k1VerificationKey2020 => {
"EcdsaSecp256k1VerificationKey2019".to_string()
}
VerificationKeyType::EcdsaSecp256k1RecoveryMethod2020 => {
"EcdsaSecp256k1RecoveryMethod2020".to_string()
}
}
}
}
Expand All @@ -144,6 +148,9 @@ impl TryFrom<&str> for VerificationKeyType {
"Ed25519VerificationKey2020" => Ok(VerificationKeyType::Ed25519VerificationKey2020),
"X25519KeyAgreementKey2020" => Ok(VerificationKeyType::X25519KeyAgreementKey2020),
"JsonWebKey2020" => Ok(VerificationKeyType::JsonWebKey2020),
"EcdsaSecp256k1RecoveryMethod2020" => {
Ok(VerificationKeyType::EcdsaSecp256k1RecoveryMethod2020)
}
"EcdsaSecp256k1VerificationKey2019" => {
Ok(VerificationKeyType::EcdsaSecp256k1VerificationKey2020)
}
Expand Down
4 changes: 2 additions & 2 deletions vdr/src/contracts/did/types/did_doc_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl DidDocumentBuilder {
) -> DidDocumentBuilder {
let id = id.map(String::from).unwrap_or_else(|| {
format!(
"{}:delegate-{}",
"{}+delegate-{}",
self.id.as_ref(),
self.verification_method.len()
)
Expand Down Expand Up @@ -186,7 +186,7 @@ impl DidDocumentBuilder {
) -> DidDocumentBuilder {
let id = id
.map(String::from)
.unwrap_or_else(|| format!("#service-{}", self.service.len() + 1));
.unwrap_or_else(|| format!("#{}#service-{}", self.id.as_ref(), self.service.len() + 1));
let service = Service {
id,
type_: type_.to_string(),
Expand Down

0 comments on commit 9bb3ad1

Please sign in to comment.