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

Adds New VerificationMethod ED25519VerificationKey2020 #114

Merged
merged 1 commit into from
Jun 5, 2024
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
4 changes: 2 additions & 2 deletions did/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func NewVerificationMethod(id DIDURL, keyType ssi.KeyType, controller DID, key c
}
vm.PublicKeyJwk = jwkAsMap
}
if keyType == ssi.ED25519VerificationKey2018 {
if keyType == ssi.ED25519VerificationKey2018 || keyType == ssi.ED25519VerificationKey2020 {
ed25519Key, ok := key.(ed25519.PublicKey)
if !ok {
return nil, errors.New("wrong key type")
Expand Down Expand Up @@ -371,7 +371,7 @@ func (v VerificationMethod) JWK() (jwk.Key, error) {
func (v VerificationMethod) PublicKey() (crypto.PublicKey, error) {
var pubKey crypto.PublicKey
switch v.Type {
case ssi.ED25519VerificationKey2018:
case ssi.ED25519VerificationKey2018, ssi.ED25519VerificationKey2020:
var keyBytes []byte
var err error
if v.PublicKeyMultibase != "" {
Expand Down
13 changes: 13 additions & 0 deletions did/document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ func Test_Document(t *testing.T) {
require.NotNil(t, publicKey)
})

t.Run("ED25519VerificationKey2020", func(t *testing.T) {
keyID := DIDURL{DID: actual.ID}
keyID.Fragment = "added-assertion-method-1"

pubKey, _, _ := ed25519.GenerateKey(rand.Reader)
vm, err := NewVerificationMethod(keyID, ssi.ED25519VerificationKey2020, actual.ID, pubKey)
require.NoError(t, err)

publicKey, err := vm.PublicKey()
require.NoError(t, err)
require.NotNil(t, publicKey)
})

t.Run("ECDSASECP256K1VerificationKey2019", func(t *testing.T) {
t.Run("generated key", func(t *testing.T) {
keyID := DIDURL{DID: actual.ID}
Expand Down
6 changes: 5 additions & 1 deletion spec-registries.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ type KeyType string
const JsonWebKey2020 = KeyType("JsonWebKey2020")

// ED25519VerificationKey2018 is the Ed25519VerificationKey2018 verification key type as specified here:
// https://w3c-ccg.github.io/lds-ed25519-2018/
// https://w3c-ccg.github.io/
const ED25519VerificationKey2018 = KeyType("Ed25519VerificationKey2018")

// ED25519VerificationKey2020 is the Ed25519VerificationKey2020 verification key type as specified here:
// https://www.w3.org/TR/vc-di-eddsa/#ed25519verificationkey2020
const ED25519VerificationKey2020 = KeyType("Ed25519VerificationKey2020")

// ECDSASECP256K1VerificationKey2019 is the EcdsaSecp256k1VerificationKey2019 verification key type as specified here:
// https://w3c-ccg.github.io/lds-ecdsa-secp256k1-2019/
const ECDSASECP256K1VerificationKey2019 = KeyType("EcdsaSecp256k1VerificationKey2019")
Expand Down