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

Fix/did web create key #461

Merged
merged 4 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion did/peer/peer0.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (Method0) resolve(didDoc did.DID, _ resolution.Option) (*resolution.Result,
keyReference := Hash + v
id := string(d)

verificationMethod, err := did.ConstructJWKVerificationMethod(id, keyReference, pubKey, cryptoKeyType)
verificationMethod, err := did.ConstructJWKVerificationMethod(keyReference, id, pubKey, cryptoKeyType)
if err != nil {
return nil, err
}
Expand Down
2 changes: 2 additions & 0 deletions did/peer/peer0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func TestPeerResolveMethod0(t *testing.T) {
testDoc := getSampleDIDDocumentMethod0()
assert.Equal(t, testDoc.Context, resolved.Document.Context)
assert.Equal(t, testDoc.ID, resolved.ID)
assert.Equal(t, len(resolved.VerificationMethod), 1)
assert.Equal(t, testDoc.ID, resolved.VerificationMethod[0].Controller)
}

func makeSamplePeerDIDDocument0() *did.Document {
Expand Down
2 changes: 1 addition & 1 deletion did/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (d DIDWeb) CreateDoc(kt crypto.KeyType, publicKey []byte) (*did.Document, e
didWebStr := string(d)
keyReference := didWebStr + "#owner"

verificationMethod, err := did.ConstructJWKVerificationMethod(didWebStr, keyReference, publicKey, kt)
verificationMethod, err := did.ConstructJWKVerificationMethod(keyReference, didWebStr, publicKey, kt)
if err != nil {
return nil, fmt.Errorf("could not construct verification method for DIDWeb %+v", d)
}
Expand Down
6 changes: 6 additions & 0 deletions did/web/web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ func TestDIDWebCreateDoc(t *testing.T) {
doc, err := didWebBasic.CreateDoc(crypto.Ed25519, pk)
assert.NoError(tt, err)
assert.Equal(tt, string(didWebBasic), doc.ID)
tt.Run("Validate Owner Verification Method", func(t *testing.T) {
assert.Equal(t, len(doc.VerificationMethod), 1)
ownerMethod := doc.VerificationMethod[0]
assert.Contains(t, ownerMethod.ID, "owner")
assert.Equal(t, ownerMethod.Controller, doc.ID)
})
})

t.Run("Unsupported Key Type", func(tt *testing.T) {
Expand Down
Loading