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

Key agreement #75

Merged
merged 3 commits into from
Sep 22, 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
10 changes: 8 additions & 2 deletions helpers/crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (
)

const (
DidPrefix = "did:knox:"
ProofType = "Ed25519VerificationKey2020"
DidPrefix = "did:knox:"
ProofType = "Ed25519VerificationKey2020"
KeyAgreementType = "X25519KeyAgreementKey2019"
)

var MultiCodecPrefix = []byte{0xed, 0x01}
Expand All @@ -34,6 +35,9 @@ type KeyPairs struct {

AssertionMethodPublicKey string
AssertionMethodPrivateKey []byte

KeyAgreementPublicKey string
KeyAgreementPrivateKey []byte
}

type cryptoManager struct {
Expand Down Expand Up @@ -72,6 +76,8 @@ func (c *cryptoManager) GenerateKeyPair(mnemonic string) (*KeyPairs, error) {
CapabilityDelegationPrivateKey: private,
AssertionMethodPublicKey: encodedPublic,
AssertionMethodPrivateKey: private,
KeyAgreementPublicKey: encodedPublic,
KeyAgreementPrivateKey: private,
}, nil

}
Expand Down
8 changes: 8 additions & 0 deletions helpers/did/did.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ func CreateDidDocument(kps *crypto.KeyPairs) *model.DidDocument {
PublicKeyMultibase: kps.AssertionMethodPublicKey,
},
},
KeyAgreement: []model.KeyMaterial{
adewaleafolabi marked this conversation as resolved.
Show resolved Hide resolved
{
Id: kps.GetVerificationMethod(signer.KeyAgreement),
Type: crypto.KeyAgreementType,
Controller: crypto.DidPrefix + kps.MasterPublicKey,
PublicKeyMultibase: kps.KeyAgreementPublicKey,
},
},
}
}

Expand Down
1 change: 1 addition & 0 deletions model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type DidDocument struct {
CapabilityInvocation []KeyMaterial `json:"capabilityInvocation"`
CapabilityDelegation []KeyMaterial `json:"capabilityDelegation"`
AssertionMethod []KeyMaterial `json:"assertionMethod"`
KeyAgreement []KeyMaterial `json:"keyAgreement,omitempty"`
}

type AuthToken struct {
Expand Down
3 changes: 3 additions & 0 deletions signer/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const (
CapabilityInvocation
CapabilityDelegation
AssertionMethod
KeyAgreement
)

func (vr VerificationRelation) String() string {
Expand All @@ -23,6 +24,8 @@ func (vr VerificationRelation) String() string {
return "capabilityDelegation"
case AssertionMethod:
return "associationMethod"
case KeyAgreement:
return "keyAgreement"
default:
return ""
}
Expand Down
Loading