diff --git a/didcomm_messaging/crypto/backend/askar.py b/didcomm_messaging/crypto/backend/askar.py index eaf1b9d..df5b24e 100644 --- a/didcomm_messaging/crypto/backend/askar.py +++ b/didcomm_messaging/crypto/backend/askar.py @@ -116,11 +116,6 @@ def multikey(self) -> str: """Get the key in multibase format.""" return self._multikey - @property - def key_bytes(self) -> bytes: - """Get the bytes of the key.""" - return self.key.get_public_bytes() - class AskarSecretKey(SecretKey): """Secret key implementation for Askar.""" @@ -135,6 +130,10 @@ def kid(self) -> str: """Get the key ID.""" return self._kid + def as_public_key(self) -> AskarKey: + """Return AskarKey representation.""" + return AskarKey(self.key, self.kid) + class AskarCryptoService(CryptoService[AskarKey, AskarSecretKey]): """CryptoService backend implemented using Askar.""" @@ -418,4 +417,4 @@ async def get_secret_by_kid(self, kid: str) -> Optional[AskarSecretKey]: return None # cached_property doesn't play nice with pyright - return AskarKey(key_entry.key, kid) # type: ignore + return AskarSecretKey(key_entry.key, kid) # type: ignore diff --git a/didcomm_messaging/crypto/backend/authlib.py b/didcomm_messaging/crypto/backend/authlib.py index 1984765..f14bafe 100644 --- a/didcomm_messaging/crypto/backend/authlib.py +++ b/didcomm_messaging/crypto/backend/authlib.py @@ -56,18 +56,6 @@ def multikey(self) -> str: """Return the key in multikey format.""" return self._multikey - @property - def key_bytes(self) -> bytes: - """Get the bytes of the key.""" - jwk = self.key.as_dict(is_private=False) - codec = self.kty_crv_to_codec.get((jwk["kty"], jwk.get("crv"))) - - if not codec: - raise ValueError("Unsupported key type") - - key_bytes = b64url.decode(jwk["x"]) - return key_bytes - @classmethod def key_to_multikey(cls, key: AsymmetricKey) -> str: """Convert an Authlib key to a multikey.""" diff --git a/didcomm_messaging/crypto/base.py b/didcomm_messaging/crypto/base.py index 5b1cc83..ce2d233 100644 --- a/didcomm_messaging/crypto/base.py +++ b/didcomm_messaging/crypto/base.py @@ -69,11 +69,6 @@ def kid(self) -> str: def multikey(self) -> str: """Get the key in multikey format.""" - @property - @abstractmethod - def key_bytes(self) -> bytes: - """Get the bytes of the key.""" - class SecretKey(ABC): """Secret Key Type.""" diff --git a/didcomm_messaging/messaging.py b/didcomm_messaging/messaging.py index 3a98106..3dab806 100644 --- a/didcomm_messaging/messaging.py +++ b/didcomm_messaging/messaging.py @@ -41,7 +41,7 @@ class UnpackResult: """Result of unpacking a message.""" unpacked: bytes - encrytped: bool + encrypted: bool authenticated: bool recipient_kid: str sender_kid: Optional[str] = None @@ -139,7 +139,7 @@ async def unpack( ) return UnpackResult( unpacked, - encrytped=bool(metadata.method), + encrypted=bool(metadata.method), authenticated=bool(metadata.sender_kid), recipient_kid=metadata.recip_key.kid, sender_kid=metadata.sender_kid, diff --git a/didcomm_messaging/quickstart.py b/didcomm_messaging/quickstart.py index 3241b5d..00a5189 100644 --- a/didcomm_messaging/quickstart.py +++ b/didcomm_messaging/quickstart.py @@ -258,7 +258,7 @@ async def setup_relay( await secrets.add_secret(AskarSecretKey(verkey, f"{new_did}#key-1")) await secrets.add_secret(AskarSecretKey(xkey, f"{new_did}#key-2")) - # V1 formats + # Legacy formats # verkey await secrets.add_secret(AskarSecretKey(verkey, doc.authentication[0])) # xkey diff --git a/didcomm_messaging/resolver/peer.py b/didcomm_messaging/resolver/peer.py index 372be46..84bc3ab 100644 --- a/didcomm_messaging/resolver/peer.py +++ b/didcomm_messaging/resolver/peer.py @@ -32,9 +32,7 @@ class Peer4(DIDResolver): async def is_resolvable(self, did: str) -> bool: """Check to see if a DID is resolvable.""" - return bool(peer_4_pattern_short.match(did)) or bool( - peer_4_pattern_long.match(did) - ) + return bool(peer_4_pattern_short.match(did) or peer_4_pattern_long.match(did)) async def resolve(self, did: str) -> dict: """Resolve a did:peer:4 DID.""" diff --git a/didcomm_messaging/v1/crypto/askar.py b/didcomm_messaging/v1/crypto/askar.py index 03212e5..e53d59b 100644 --- a/didcomm_messaging/v1/crypto/askar.py +++ b/didcomm_messaging/v1/crypto/askar.py @@ -4,12 +4,14 @@ from typing import Optional, Sequence, Tuple, cast from base58 import b58decode +import base58 from pydid import VerificationMethod from didcomm_messaging.crypto.jwe import JweBuilder, JweEnvelope, JweRecipient from .base import ( V1CryptoService, - V1UnpackResult, + V1CryptoServiceError, + V1CryptoUnpackResult, RecipData, ) @@ -24,13 +26,19 @@ class AskarV1CryptoService(V1CryptoService[AskarKey, AskarSecretKey]): """V1 crypto service implementation for askar.""" - def kid_to_public_key(self, kid: str) -> AskarKey: + def v1_kid_to_public_key(self, kid: str) -> AskarKey: """Get a public key from a kid. In DIDComm v1, kids are the base58 encoded keys. """ return AskarKey(Key.from_public_bytes(KeyAlg.ED25519, b58decode(kid)), kid) + def public_key_to_v1_kid(self, key: AskarKey) -> str: + """Convert a public key into a v1 kid representation.""" + if key.key.algorithm != KeyAlg.ED25519: + raise V1CryptoServiceError() + return base58.b58encode(key.key.get_public_bytes()).decode() + @classmethod def verification_method_to_public_key(cls, vm: VerificationMethod) -> AskarKey: """Convert a verification method to a public key.""" @@ -50,11 +58,14 @@ async def pack_message( # avoid converting to bytes object: this way the only copy is zeroed afterward # tell type checking it's bytes to make it happy cek_b = cast(bytes, key_get_secret_bytes(cek._handle)) - sender_vk = from_key.kid if from_key else None + sender_vk = ( + self.public_key_to_v1_kid(from_key.as_public_key()) if from_key else None + ) sender_xk = from_key.key.convert_key(KeyAlg.X25519) if from_key else None for target_vk in to_verkeys: target_xk = target_vk.key.convert_key(KeyAlg.X25519) + target_vk_kid = self.public_key_to_v1_kid(target_vk) if sender_vk and sender_xk: enc_sender = crypto_box.crypto_box_seal(target_xk, sender_vk) nonce = crypto_box.random_nonce() @@ -64,7 +75,7 @@ async def pack_message( encrypted_key=enc_cek, header=OrderedDict( [ - ("kid", target_vk.kid), + ("kid", target_vk_kid), ("sender", self.b64url.encode(enc_sender)), ("iv", self.b64url.encode(nonce)), ] @@ -72,11 +83,9 @@ async def pack_message( ) ) else: - enc_sender = None - nonce = None enc_cek = crypto_box.crypto_box_seal(target_xk, cek_b) builder.add_recipient( - JweRecipient(encrypted_key=enc_cek, header={"kid": target_vk.kid}) + JweRecipient(encrypted_key=enc_cek, header={"kid": target_vk_kid}) ) builder.set_protected( OrderedDict( @@ -97,7 +106,7 @@ async def unpack_message( wrapper: JweEnvelope, recip_key: AskarSecretKey, recip_data: RecipData, - ) -> V1UnpackResult: + ) -> V1CryptoUnpackResult: """Decode a message using the DIDComm v1 'unpack' algorithm.""" payload_key, sender_vk = self._extract_payload_key(recip_key.key, recip_data) @@ -108,7 +117,7 @@ async def unpack_message( tag=wrapper.tag, aad=wrapper.protected_b64, ) - return V1UnpackResult(message, recip_key.kid, sender_vk) + return V1CryptoUnpackResult(message, recip_key.kid, sender_vk) def _extract_payload_key( self, recip_key: Key, recip_data: RecipData diff --git a/didcomm_messaging/v1/crypto/base.py b/didcomm_messaging/v1/crypto/base.py index 4366eb6..df8f7e3 100644 --- a/didcomm_messaging/v1/crypto/base.py +++ b/didcomm_messaging/v1/crypto/base.py @@ -18,26 +18,34 @@ class RecipData(NamedTuple): enc_cek: bytes -class V1UnpackResult(NamedTuple): +class V1CryptoUnpackResult(NamedTuple): """Result of unpacking.""" - message: bytes + unpacked: bytes recip: str sender: Optional[str] +class V1CryptoServiceError(Exception): + """Raised on errors in crypto service.""" + + class V1CryptoService(ABC, Generic[P, S]): """CryptoService interface for DIDComm v1.""" b64url = Base64UrlEncoder() @abstractmethod - def kid_to_public_key(self, kid: str) -> P: + def v1_kid_to_public_key(self, kid: str) -> P: """Get a public key from a kid. In DIDComm v1, kids are the base58 encoded keys. """ + @abstractmethod + def public_key_to_v1_kid(self, key: P) -> str: + """Return the DIDComm v1 kid representation for a key.""" + @classmethod @abstractmethod def verification_method_to_public_key(cls, vm: VerificationMethod) -> P: @@ -52,5 +60,5 @@ async def pack_message( @abstractmethod async def unpack_message( self, wrapper: JweEnvelope, recip_key: S, recip_data: RecipData - ) -> V1UnpackResult: + ) -> V1CryptoUnpackResult: """Decode a message using DIDCvomm v1 'unpack' algorithm.""" diff --git a/didcomm_messaging/v1/crypto/nacl.py b/didcomm_messaging/v1/crypto/nacl.py index 5d55435..42ac97b 100644 --- a/didcomm_messaging/v1/crypto/nacl.py +++ b/didcomm_messaging/v1/crypto/nacl.py @@ -10,7 +10,7 @@ from didcomm_messaging.crypto.jwe import JweBuilder, JweEnvelope, JweRecipient from didcomm_messaging.multiformats import multibase, multicodec -from .base import V1CryptoService, V1UnpackResult, RecipData +from .base import V1CryptoService, V1CryptoUnpackResult, RecipData try: import nacl.bindings @@ -60,7 +60,7 @@ def key(self) -> str: @property def kid(self) -> str: """Get the key ID.""" - return self.key + raise NotImplementedError() @property def multikey(self) -> str: @@ -69,22 +69,21 @@ def multikey(self) -> str: multicodec.wrap("ed25519-pub", base58.b58decode(self.key)), "base58btc" ) - @property - def key_bytes(self) -> bytes: - """Get the bytes of the key.""" - return self.value - class NaclV1CryptoService(V1CryptoService[EdPublicKey, KeyPair]): """V1 crypto service using pynacl.""" - def kid_to_public_key(self, kid: str): + def v1_kid_to_public_key(self, kid: str): """Get a public key from a kid. In DIDComm v1, kids are the base58 encoded keys. """ return EdPublicKey(base58.b58decode(kid)) + def public_key_to_v1_kid(self, key: EdPublicKey) -> str: + """Convert a public key into a v1 kid representation.""" + return base58.b58encode(key.value).decode() + @classmethod def verification_method_to_public_key(cls, vm: VerificationMethod) -> EdPublicKey: """Convert a verification method to a public key.""" @@ -120,7 +119,7 @@ async def pack_message( encrypted_key=enc_cek, header=OrderedDict( [ - ("kid", target_vk.kid), + ("kid", self.public_key_to_v1_kid(target_vk)), ("sender", self.b64url.encode(enc_sender)), ("iv", self.b64url.encode(nonce)), ] @@ -128,11 +127,12 @@ async def pack_message( ) ) else: - enc_sender = None - nonce = None enc_cek = nacl.bindings.crypto_box_seal(cek, target_xk) builder.add_recipient( - JweRecipient(encrypted_key=enc_cek, header={"kid": target_vk.kid}) + JweRecipient( + encrypted_key=enc_cek, + header={"kid": self.public_key_to_v1_kid(target_vk)}, + ) ) builder.set_protected( @@ -180,7 +180,7 @@ def _extract_payload_key(self, recip_key: KeyPair, recip_data: RecipData): async def unpack_message( self, wrapper: JweEnvelope, recip_key: KeyPair, recip_data: RecipData - ) -> V1UnpackResult: + ) -> V1CryptoUnpackResult: """Decode a message using DIDCvomm v1 'unpack' algorithm.""" cek, sender_vk = self._extract_payload_key(recip_key, recip_data) @@ -188,7 +188,7 @@ async def unpack_message( message = nacl.bindings.crypto_aead_chacha20poly1305_ietf_decrypt( payload_bin, wrapper.protected_b64, wrapper.iv, cek ) - return V1UnpackResult(message, recip_key.kid, sender_vk) + return V1CryptoUnpackResult(message, recip_key.kid, sender_vk) class InMemSecretsManager(SecretsManager[KeyPair]): @@ -206,7 +206,7 @@ def _create_keypair(self, seed: Optional[bytes] = None) -> Tuple[bytes, bytes]: """Create a keypair.""" if seed: if not isinstance(seed, bytes): - raise ValueError("Seed value is not a string or bytes") + raise ValueError("Seed value is not bytes") if len(seed) != 32: raise ValueError("Seed value must be 32 bytes in length") else: diff --git a/didcomm_messaging/v1/messaging.py b/didcomm_messaging/v1/messaging.py index c35723d..69c1fc7 100644 --- a/didcomm_messaging/v1/messaging.py +++ b/didcomm_messaging/v1/messaging.py @@ -4,15 +4,14 @@ import json from typing import Generic, Optional, Sequence, Union -import base58 from pydantic import AnyUrl -from pydid import VerificationMethod +from pydid import DIDDocument, VerificationMethod from pydid.service import DIDCommV1Service from didcomm_messaging.crypto import P, S, SecretsManager +from didcomm_messaging.resolver import DIDResolver from didcomm_messaging.v1.crypto.base import V1CryptoService from didcomm_messaging.v1.packaging import V1PackagingService -from didcomm_messaging.resolver import DIDResolver class V1DIDCommMessagingError(Exception): @@ -32,7 +31,7 @@ class V1UnpackResult: """Result of unpacking a message.""" unpacked: bytes - encrytped: bool + encrypted: bool authenticated: bool recipient_kid: str sender_kid: Optional[str] = None @@ -58,6 +57,14 @@ class Target: class V1DIDCommMessagingService(Generic[P, S]): """Main entrypoint for DIDComm Messaging.""" + def vm_to_v1_kid(self, crypto: V1CryptoService, doc: DIDDocument, ref: str) -> str: + """Convert a verification method ref to a DIDComm v1 kid.""" + return crypto.public_key_to_v1_kid( + crypto.verification_method_to_public_key( + doc.dereference_as(VerificationMethod, ref) + ) + ) + async def did_to_target( self, crypto: V1CryptoService[P, S], resolver: DIDResolver, did: str ) -> Target: @@ -73,19 +80,10 @@ async def did_to_target( target = services[0] recipient_keys = [ - base58.b58encode( - crypto.verification_method_to_public_key( - doc.dereference_as(VerificationMethod, recip) - ).key_bytes - ).decode() - for recip in target.recipient_keys + self.vm_to_v1_kid(crypto, doc, recip) for recip in target.recipient_keys ] routing_keys = [ - base58.b58encode( - crypto.verification_method_to_public_key( - doc.dereference_as(VerificationMethod, routing_key) - ).key_bytes - ).decode() + self.vm_to_v1_kid(crypto, doc, routing_key) for routing_key in target.routing_keys ] endpoint = target.service_endpoint @@ -113,12 +111,7 @@ async def from_did_to_kid( target = services[0] recipient_keys = [ - base58.b58encode( - crypto.verification_method_to_public_key( - doc.dereference_as(VerificationMethod, recip) - ).key_bytes - ).decode() - for recip in target.recipient_keys + self.vm_to_v1_kid(crypto, doc, recip) for recip in target.recipient_keys ] return recipient_keys[0] @@ -211,7 +204,7 @@ async def unpack( unpacked, recip, sender = await packaging.unpack(crypto, secrets, encoded_message) return V1UnpackResult( unpacked, - encrytped=bool(recip), + encrypted=bool(recip), authenticated=bool(sender), recipient_kid=recip, sender_kid=sender, diff --git a/didcomm_messaging/v1/packaging.py b/didcomm_messaging/v1/packaging.py index ef661d7..f96b6d8 100644 --- a/didcomm_messaging/v1/packaging.py +++ b/didcomm_messaging/v1/packaging.py @@ -6,7 +6,7 @@ from didcomm_messaging.crypto.jwe import JweEnvelope, JweRecipient from didcomm_messaging.v1.crypto.base import ( V1CryptoService, - V1UnpackResult, + V1CryptoUnpackResult, RecipData, ) from didcomm_messaging.multiformats.multibase import Base64UrlEncoder @@ -83,7 +83,7 @@ async def unpack( crypto: V1CryptoService[P, S], secrets: SecretsManager[S], enc_message: Union[JweEnvelope, str, bytes], - ) -> V1UnpackResult: + ) -> V1CryptoUnpackResult: """Unpack a DIDComm v1 message.""" if isinstance(enc_message, (str, bytes)): try: @@ -109,6 +109,6 @@ async def pack( frm: Optional[str] = None, ): """Pack a DIDComm v1 message.""" - recip_keys = [crypto.kid_to_public_key(kid) for kid in to] + recip_keys = [crypto.v1_kid_to_public_key(kid) for kid in to] sender_key = await secrets.get_secret_by_kid(frm) if frm else None return await crypto.pack_message(recip_keys, sender_key, message) diff --git a/didcomm_messaging/v1/utils.py b/didcomm_messaging/v1/utils.py new file mode 100644 index 0000000..bf4b8ee --- /dev/null +++ b/didcomm_messaging/v1/utils.py @@ -0,0 +1,13 @@ +"""Utilities for DIDComm v1.""" + +import base58 +from didcomm_messaging.multiformats import multibase, multicodec + + +def v1_kid_to_multikey(kid: str) -> str: + """Convert a kid to a multikey value.""" + decoded = base58.b58decode(kid) + if len(decoded) != 32: + raise ValueError("Invalid kid; does not represent base58 encoded ed25519 pub key") + + return multibase.encode(multicodec.wrap("ed25519-pub", decoded), "base58btc") diff --git a/pdm.lock b/pdm.lock index 5b612b3..94ce6c3 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "askar", "authlib", "dev", "did_peer", "legacy", "nacl"] strategy = ["cross_platform"] lock_version = "4.4.1" -content_hash = "sha256:5c5481f5ae1d8c66d655eaa8a99961229004b213afb4d2e1fb163b9b5277eb78" +content_hash = "sha256:eb174aa8c00b83658d930e8778c70171d2a99d5fe1645b2e1e1e5e881f5c365c" [[package]] name = "annotated-types" diff --git a/pyproject.toml b/pyproject.toml index 85f9e5b..89fd15d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ authors = [ ] dependencies = [ "base58>=2.1.1", - "pydid>=0.4.2", + "pydid>=0.5.1", ] requires-python = ">=3.9" readme = "README.md" diff --git a/tests/v1/conftest.py b/tests/v1/conftest.py index 8f4a154..d827101 100644 --- a/tests/v1/conftest.py +++ b/tests/v1/conftest.py @@ -8,11 +8,10 @@ from didcomm_messaging.crypto.backend.askar import AskarKey, AskarSecretsManager from didcomm_messaging.resolver import DIDResolver from didcomm_messaging.resolver.peer import Peer4 -from didcomm_messaging.v1.crypto.askar import AskarSecretKey, AskarV1CryptoService +from didcomm_messaging.v1.crypto.askar import AskarV1CryptoService from didcomm_messaging.v1.crypto.nacl import ( EdPublicKey, InMemSecretsManager, - KeyPair, NaclV1CryptoService, ) from didcomm_messaging.v1.messaging import V1DIDCommMessaging @@ -82,20 +81,20 @@ async def bob_key(store: Store): kid = base58.b58encode(key.get_public_bytes()).decode() async with store.session() as session: await session.insert_key(kid, key) - return AskarSecretKey(key, kid) + yield AskarKey(key, kid) @pytest.fixture def alice_key(nacl_secrets: InMemSecretsManager): """Generate alice's keys.""" - yield nacl_secrets.create() + keypair = nacl_secrets.create() + yield EdPublicKey(keypair.verkey) @pytest.fixture -def alice_did(alice_key: KeyPair): - alice_pub = EdPublicKey(alice_key.verkey) +def alice_did(alice_key: EdPublicKey): input_doc = input_doc_from_keys_and_services( - [KeySpec(alice_pub.multikey, relationships=["authentication"])], + [KeySpec(alice_key.multikey, relationships=["authentication"])], [ { "id": "#didcomm", @@ -109,10 +108,9 @@ def alice_did(alice_key: KeyPair): @pytest.fixture -def bob_did(bob_key: AskarSecretKey): - bob_pub = AskarKey(bob_key.key, bob_key.kid) +def bob_did(bob_key: AskarKey): input_doc = input_doc_from_keys_and_services( - [KeySpec(bob_pub.multikey, relationships=["authentication"])], + [KeySpec(bob_key.multikey, relationships=["authentication"])], [ { "id": "#didcomm", diff --git a/tests/v1/test_nacl_x_askar.py b/tests/v1/test_nacl_x_askar.py index 8193274..57a5f8b 100644 --- a/tests/v1/test_nacl_x_askar.py +++ b/tests/v1/test_nacl_x_askar.py @@ -1,7 +1,8 @@ import pytest -from didcomm_messaging.crypto.base import SecretKey +from didcomm_messaging.crypto.base import PublicKey from didcomm_messaging.v1.messaging import V1DIDCommMessaging +from didcomm_messaging.v1.utils import v1_kid_to_multikey @pytest.mark.asyncio @@ -10,8 +11,8 @@ async def test_pack_unpack_auth_n_to_a( bob: V1DIDCommMessaging, alice_did: str, bob_did: str, - alice_key: SecretKey, - bob_key: SecretKey, + alice_key: PublicKey, + bob_key: PublicKey, ): """Test that we can pack and unpack going from askar to crypto.""" @@ -19,8 +20,9 @@ async def test_pack_unpack_auth_n_to_a( packed_msg = await alice.pack(msg, bob_did, alice_did) unpacked = await bob.unpack(packed_msg.message) assert unpacked.unpacked == msg - assert unpacked.sender_kid == alice_key.kid - assert unpacked.recipient_kid == bob_key.kid + assert unpacked.sender_kid is not None + assert v1_kid_to_multikey(unpacked.sender_kid) == alice_key.multikey + assert v1_kid_to_multikey(unpacked.recipient_kid) == bob_key.multikey @pytest.mark.asyncio @@ -29,8 +31,8 @@ async def test_pack_unpack_auth_a_to_n( bob: V1DIDCommMessaging, alice_did: str, bob_did: str, - alice_key: SecretKey, - bob_key: SecretKey, + alice_key: PublicKey, + bob_key: PublicKey, ): """Test that we can pack and unpack going from askar to crypto.""" @@ -38,8 +40,9 @@ async def test_pack_unpack_auth_a_to_n( packed_msg = await bob.pack(msg, alice_did, bob_did) unpacked = await alice.unpack(packed_msg.message) assert unpacked.unpacked == msg - assert unpacked.sender_kid == bob_key.kid - assert unpacked.recipient_kid == alice_key.kid + assert unpacked.sender_kid is not None + assert v1_kid_to_multikey(unpacked.sender_kid) == bob_key.multikey + assert v1_kid_to_multikey(unpacked.recipient_kid) == alice_key.multikey @pytest.mark.asyncio @@ -47,7 +50,7 @@ async def test_pack_unpack_anon_n_to_a( alice: V1DIDCommMessaging, bob: V1DIDCommMessaging, bob_did: str, - bob_key: SecretKey, + bob_key: PublicKey, ): """Test that we can pack and unpack going from askar to crypto.""" @@ -55,7 +58,7 @@ async def test_pack_unpack_anon_n_to_a( packed_msg = await alice.pack(msg, bob_did) unpacked = await bob.unpack(packed_msg.message) assert unpacked.unpacked == msg - assert unpacked.recipient_kid == bob_key.kid + assert v1_kid_to_multikey(unpacked.recipient_kid) == bob_key.multikey assert unpacked.sender_kid is None @@ -64,7 +67,7 @@ async def test_pack_unpack_anon_a_to_n( alice: V1DIDCommMessaging, bob: V1DIDCommMessaging, alice_did: str, - alice_key: SecretKey, + alice_key: PublicKey, ): """Test that we can pack and unpack going from askar to crypto.""" @@ -72,5 +75,5 @@ async def test_pack_unpack_anon_a_to_n( packed_msg = await bob.pack(msg, alice_did) unpacked = await alice.unpack(packed_msg.message) assert unpacked.unpacked == msg - assert unpacked.recipient_kid == alice_key.kid + assert v1_kid_to_multikey(unpacked.recipient_kid) == alice_key.multikey assert unpacked.sender_kid is None