Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement did-pkh #168

Merged
merged 8 commits into from
Aug 22, 2022
Merged

Implement did-pkh #168

merged 8 commits into from
Aug 22, 2022

Conversation

nitro-neal
Copy link
Contributor

This change implements they did-pkh method as specified here - https://github.com/w3c-ccg/did-pkh/blob/90b28ad3c18d63822a8aab3c752302aa64fc9382/did-pkh-method-draft.md

Linked issue here - #33

This change includes construction of a Bitcoin, Ethereum, or Polygon did:pkh from a network and an address. For more granular creation it can be constructed from a namespace, reference, and account address.

// Example Reference: did:pkh:namespace:reference:account_address
// Ethereum: did:pkh:eip155:1:0xb9c5714089478a327f09197987f16f9e5d936e8a

did/pkh.go Outdated Show resolved Hide resolved
did/pkh.go Outdated Show resolved Hide resolved
did/pkh.go Outdated Show resolved Hide resolved
did/pkh.go Outdated Show resolved Hide resolved
did/pkh.go Outdated Show resolved Hide resolved
did/pkh.go Outdated Show resolved Hide resolved
Copy link
Member

@decentralgabe decentralgabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great, minor changes. may want to add a GetSupportedNetworks() method

did/pkh.go Outdated Show resolved Hide resolved
did/pkh.go Outdated Show resolved Hide resolved
did/pkh_test.go Outdated Show resolved Hide resolved
did/pkh_test.go Outdated Show resolved Hide resolved
did/pkh_test.go Outdated Show resolved Hide resolved
did/pkh_test.go Outdated Show resolved Hide resolved
did/pkh_test.go Outdated Show resolved Hide resolved
did/pkh_test.go Outdated Show resolved Hide resolved
did/pkh_test.go Outdated Show resolved Hide resolved
did/pkh_test.go Outdated Show resolved Hide resolved
did/model.go Outdated
@@ -95,6 +95,8 @@ type VerificationMethod struct {
PublicKeyJWK *cryptosuite.PublicKeyJWK `json:"publicKeyJwk,omitempty" validate:"omitempty,dive"`
// https://datatracker.ietf.org/doc/html/draft-multiformats-multibase-03
PublicKeyMultibase string `json:"publicKeyMultibase,omitempty"`
// for PKH DIDs - https://github.com/w3c-ccg/did-pkh/blob/90b28ad3c18d63822a8aab3c752302aa64fc9382/did-pkh-method-draft.md
BlockchainAccountId string `json:"blockchainAccountId,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BlockchainAccountId string `json:"blockchainAccountId,omitempty"`
BlockchainAccountID string `json:"blockchainAccountId,omitempty"`

did/pkh.go Outdated
Comment on lines 90 to 94
var knownDIDPKHContextJson interface{}
err = json.Unmarshal([]byte(knownDIDPKHContext), &knownDIDPKHContextJson)
if err != nil {
return nil, util.LoggingErrorMsg(err, "could not unmarshal known context json")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var knownDIDPKHContextJson interface{}
err = json.Unmarshal([]byte(knownDIDPKHContext), &knownDIDPKHContextJson)
if err != nil {
return nil, util.LoggingErrorMsg(err, "could not unmarshal known context json")
}
var knownDIDPKHContextJSON interface{}
if err := json.Unmarshal([]byte(knownDIDPKHContext), &knownDIDPKHContextJSON); err != nil {
return nil, util.LoggingErrorMsg(err, "could not unmarshal known context json")
}

did/pkh.go Outdated
}

return &DIDDocument{
Context: knownDIDPKHContextJson,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Context: knownDIDPKHContextJson,
Context: knownDIDPKHContextJSON,

did/pkh.go Outdated
}

func GetSupportedNetworks() []Network {
networks := []Network{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: favor var initialization

var networks []Network

Copy link
Member

@decentralgabe decentralgabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approving pending couple small comments - nice job!

@nitro-neal nitro-neal merged commit 1c67c77 into main Aug 22, 2022
@nitro-neal nitro-neal deleted the pkh branch August 22, 2022 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants