Skip to content

Commit

Permalink
Merge pull request #3244 from dbluhm/feature/ed25519-verification-key…
Browse files Browse the repository at this point in the history
…-2020

feat: verify creds signed with Ed25519VerificationKey2020
  • Loading branch information
dbluhm authored Sep 19, 2024
2 parents 3e27fbf + fcad023 commit e50fb6c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ async def test_from_verification_method_x_no_public_key_base58(self):

with self.assertRaises(LinkedDataProofException) as context:
key_pair.from_verification_method({})
assert "no publicKeyBase58" in str(context.exception)
assert "Unrecognized" in str(context.exception)
16 changes: 13 additions & 3 deletions aries_cloudagent/vc/ld_proofs/crypto/wallet_key_pair.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""Key pair based on base wallet interface."""

from typing import List, Optional, Union
from base58 import b58encode

from ....core.profile import Profile
from ....wallet.base import BaseWallet
from ....wallet.key_type import KeyType
from ....wallet.util import b58_to_bytes
from ..error import LinkedDataProofException
from .key_pair import KeyPair
from ....utils.multiformats import multibase, multicodec


class WalletKeyPair(KeyPair):
Expand Down Expand Up @@ -57,15 +59,23 @@ async def verify(self, message: Union[List[bytes], bytes], signature: bytes) ->

def from_verification_method(self, verification_method: dict) -> "WalletKeyPair":
"""Create new WalletKeyPair from public key in verification method."""
if "publicKeyBase58" not in verification_method:
if "publicKeyBase58" in verification_method:
key_material = verification_method["publicKeyBase58"]
elif "sec:publicKeyMultibase" in verification_method:
# verification_method is framed
_, raw_key = multicodec.unwrap(
multibase.decode(verification_method["sec:publicKeyMultibase"]["@value"])
)
key_material = b58encode(raw_key).decode()
else:
raise LinkedDataProofException(
"Unable to set public key from verification method: no publicKeyBase58"
f"Unrecognized verification method type: {verification_method}"
)

return WalletKeyPair(
profile=self.profile,
key_type=self.key_type,
public_key_base58=verification_method["publicKeyBase58"],
public_key_base58=key_material,
)

@property
Expand Down

0 comments on commit e50fb6c

Please sign in to comment.