Skip to content

Commit

Permalink
add EcdsaSecp256k1RecoveryMethod2020 verification method
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Jul 9, 2024
1 parent 72e193e commit 199d19d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/document/did.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const (
ErrNotFound ErrorCode = "notFound"
ErrUnknownNetwork ErrorCode = "unknownNetwork"

StateType = "Iden3StateInfo2023"
StateType = "Iden3StateInfo2023"
EcdsaSecp256k1RecoveryMethod2020Type = "EcdsaSecp256k1RecoveryMethod2020"
)

const (
Expand Down Expand Up @@ -76,8 +77,10 @@ func NewDidErrorResolution(errCode ErrorCode, errMsg string) *DidResolution {
}

type VerificationMethod struct {
ID string `json:"id"`
Type string `json:"type"`
ID string `json:"id"`
Type string `json:"type"`
Controller *string `json:"controller"`
BlockchainAccountID *string `json:"blockchainAccountId"`
IdentityState
}

Expand Down
17 changes: 17 additions & 0 deletions pkg/services/did.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@ func (d *DidDocumentServices) GetDidDocument(ctx context.Context, did string, op

didResolution := document.NewDidResolution()
didResolution.DidDocument.ID = did

addr, err := core.EthAddressFromID(userID)

if err == nil {
addressString := fmt.Sprintf("%x", addr)
blockchainAccountID := fmt.Sprintf("eip155:%s:0x%s", resolver.BlockchainID(), addressString)
didResolution.DidDocument.VerificationMethod = append(
didResolution.DidDocument.VerificationMethod,
document.VerificationMethod{
ID: fmt.Sprintf("%s#vm-%d", did, 1),
Type: document.EcdsaSecp256k1RecoveryMethod2020Type,
Controller: &did,
BlockchainAccountID: &blockchainAccountID,
},
)
}

didResolution.DidDocument.VerificationMethod = append(
didResolution.DidDocument.VerificationMethod,
document.VerificationMethod{
Expand Down

0 comments on commit 199d19d

Please sign in to comment.