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

feat: verify creds signed with Ed25519VerificationKey2020 #3244

Merged
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
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
Loading