From 6bf13245c9bf6fcbe433a366637f047f7851a688 Mon Sep 17 00:00:00 2001 From: Andrew Whitehead Date: Wed, 27 Sep 2023 12:13:29 -0700 Subject: [PATCH 1/2] fix concurrent sessions Signed-off-by: Andrew Whitehead --- aries_cloudagent/wallet/routes.py | 54 ++++++++++++++----------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/aries_cloudagent/wallet/routes.py b/aries_cloudagent/wallet/routes.py index e440ba9469..ba5e7d4bd4 100644 --- a/aries_cloudagent/wallet/routes.py +++ b/aries_cloudagent/wallet/routes.py @@ -631,7 +631,6 @@ async def wallet_set_public_did(request: web.BaseRequest): """ context: AdminRequestContext = request["context"] - session = await context.session() outbound_handler = request["outbound_message_router"] @@ -653,9 +652,10 @@ async def wallet_set_public_did(request: web.BaseRequest): if not connection_id: raise web.HTTPBadRequest(reason="No endorser connection found") - wallet = session.inject_or(BaseWallet) - if not wallet: - raise web.HTTPForbidden(reason="No wallet available") + async with context.session() as session: + wallet = session.inject_or(BaseWallet) + if not wallet: + raise web.HTTPForbidden(reason="No wallet available") did = request.query.get("did") if not did: raise web.HTTPBadRequest(reason="Request query must include DID") @@ -677,9 +677,7 @@ async def wallet_set_public_did(request: web.BaseRequest): try: info, attrib_def = await promote_wallet_public_did( - context.profile, context, - context.session, did, write_ledger=write_ledger, connection_id=connection_id, @@ -725,9 +723,7 @@ async def wallet_set_public_did(request: web.BaseRequest): async def promote_wallet_public_did( - profile: Profile, context: AdminRequestContext, - session_fn, did: str, write_ledger: bool = False, connection_id: str = None, @@ -742,7 +738,7 @@ async def promote_wallet_public_did( # write only Indy DID write_ledger = is_indy_did and write_ledger - ledger = profile.inject_or(BaseLedger) + ledger = context.profile.inject_or(BaseLedger) if is_indy_did: if not ledger: @@ -756,30 +752,29 @@ async def promote_wallet_public_did( raise LookupError(f"DID {did} is not posted to the ledger") # check if we need to endorse - if is_author_role(profile): + if is_author_role(context.profile): # authors cannot write to the ledger write_ledger = False # author has not provided a connection id, so determine which to use if not connection_id: - connection_id = await get_endorser_connection_id(profile) + connection_id = await get_endorser_connection_id(context.profile) if not connection_id: raise web.HTTPBadRequest(reason="No endorser connection found") if not write_ledger: - try: - async with profile.session() as session: + async with context.session() as session: + try: connection_record = await ConnRecord.retrieve_by_id( session, connection_id ) - except StorageNotFoundError as err: - raise web.HTTPNotFound(reason=err.roll_up) from err - except BaseModelError as err: - raise web.HTTPBadRequest(reason=err.roll_up) from err - - async with profile.session() as session: + except StorageNotFoundError as err: + raise web.HTTPNotFound(reason=err.roll_up) from err + except BaseModelError as err: + raise web.HTTPBadRequest(reason=err.roll_up) from err endorser_info = await connection_record.metadata_get( session, "endorser_info" ) + if not endorser_info: raise web.HTTPForbidden( reason=( @@ -798,18 +793,16 @@ async def promote_wallet_public_did( did_info: DIDInfo = None attrib_def = None - async with session_fn() as session: + async with context.session() as session: wallet = session.inject_or(BaseWallet) did_info = await wallet.get_local_did(did) info = await wallet.set_public_did(did_info) - if info: - # Publish endpoint if necessary - endpoint = did_info.metadata.get("endpoint") + if info: + # Publish endpoint if necessary + endpoint = did_info.metadata.get("endpoint") - if is_indy_did and not endpoint: - async with session_fn() as session: - wallet = session.inject_or(BaseWallet) + if is_indy_did and not endpoint: endpoint = mediator_endpoint or context.settings.get("default_endpoint") attrib_def = await wallet.set_did_endpoint( info.did, @@ -820,9 +813,10 @@ async def promote_wallet_public_did( routing_keys=routing_keys, ) + if info: # Route the public DID - route_manager = profile.inject(RouteManager) - await route_manager.route_verkey(profile, info.verkey) + route_manager = context.profile.inject(RouteManager) + await route_manager.route_verkey(context.profile, info.verkey) return info, attrib_def @@ -1163,8 +1157,8 @@ async def on_register_nym_event(profile: Profile, event: Event): did = event.payload["did"] connection_id = event.payload.get("connection_id") try: - info, attrib_def = await promote_wallet_public_did( - profile, profile.context, profile.session, did, connection_id + _info, attrib_def = await promote_wallet_public_did( + profile.context, did, connection_id ) except Exception as err: # log the error, but continue From ced024a38cb1371fdb3c4cd4f47de457461fd4d5 Mon Sep 17 00:00:00 2001 From: Andrew Whitehead Date: Thu, 28 Sep 2023 09:43:53 -0700 Subject: [PATCH 2/2] avoid carrying open wallet instance in WalletKeyPair Signed-off-by: Andrew Whitehead --- .../v2_0/formats/ld_proof/handler.py | 5 +- .../present_proof/dif/pres_exch_handler.py | 52 +++++++---------- .../present_proof/v2_0/formats/dif/handler.py | 55 +++++++++--------- .../v2_0/formats/dif/tests/test_handler.py | 2 +- .../crypto/tests/test_wallet_key_pair.py | 56 +++++++++++-------- .../vc/ld_proofs/crypto/wallet_key_pair.py | 35 +++++++----- .../tests/test_bbs_bls_signature_2020.py | 6 +- .../test_bbs_bls_signature_proof_2020.py | 4 +- .../tests/test_ed25519_signature_2018.py | 4 +- .../tests/test_ed25519_signature_2020.py | 4 +- .../vc/ld_proofs/tests/test_ld_proofs.py | 16 +++--- .../vc/tests/test_bbs_mattr_interop.py | 6 +- aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py | 20 +++---- 13 files changed, 130 insertions(+), 135 deletions(-) diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/handler.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/handler.py index 02231f134d..f7e2ff8a43 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/handler.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/handler.py @@ -303,9 +303,6 @@ async def _get_suite( did_info: DIDInfo = None, ): """Get signature suite for issuance of verification.""" - session = await self.profile.session() - wallet = session.inject(BaseWallet) - # Get signature class based on proof type SignatureClass = PROOF_TYPE_SIGNATURE_SUITE_MAPPING[proof_type] @@ -314,7 +311,7 @@ async def _get_suite( verification_method=verification_method, proof=proof, key_pair=WalletKeyPair( - wallet=wallet, + profile=self.profile, key_type=SIGNATURE_SUITE_KEY_TYPE_MAPPING[SignatureClass], public_key_base58=did_info.verkey if did_info else None, ), diff --git a/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py b/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py index 46492d8e87..5f70982eb2 100644 --- a/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py +++ b/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py @@ -115,7 +115,6 @@ def __init__( async def _get_issue_suite( self, *, - wallet: BaseWallet, issuer_id: str, ): """Get signature suite for signing presentation.""" @@ -139,17 +138,13 @@ async def _get_issue_suite( return SignatureClass( verification_method=verification_method, key_pair=WalletKeyPair( - wallet=wallet, + profile=self.profile, key_type=self.ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING[SignatureClass], public_key_base58=did_info.verkey if did_info else None, ), ) - async def _get_derive_suite( - self, - *, - wallet: BaseWallet, - ): + async def _get_derive_suite(self): """Get signature suite for deriving credentials.""" # Get signature class based on proof type SignatureClass = self.DERIVED_PROOF_TYPE_SIGNATURE_SUITE_MAPPING[ @@ -159,7 +154,7 @@ async def _get_derive_suite( # Generically create signature class return SignatureClass( key_pair=WalletKeyPair( - wallet=wallet, + profile=self.profile, key_type=self.DERIVE_SIGNATURE_SUITE_KEY_TYPE_MAPPING[SignatureClass], ), ) @@ -406,18 +401,14 @@ async def filter_constraints( new_credential_dict = self.reveal_doc( credential_dict=credential_dict, constraints=constraints ) - async with self.profile.session() as session: - wallet = session.inject(BaseWallet) - derive_suite = await self._get_derive_suite( - wallet=wallet, - ) - signed_new_credential_dict = await derive_credential( - credential=credential_dict, - reveal_document=new_credential_dict, - suite=derive_suite, - document_loader=document_loader, - ) - credential = self.create_vcrecord(signed_new_credential_dict) + derive_suite = await self._get_derive_suite() + signed_new_credential_dict = await derive_credential( + credential=credential_dict, + reveal_document=new_credential_dict, + suite=derive_suite, + document_loader=document_loader, + ) + credential = self.create_vcrecord(signed_new_credential_dict) result.append(credential) return result @@ -1297,18 +1288,15 @@ async def create_vp( vp["presentation_submission"] = submission_property.serialize() if self.proof_type is BbsBlsSignature2020.signature_type: vp["@context"].append(SECURITY_CONTEXT_BBS_URL) - async with self.profile.session() as session: - wallet = session.inject(BaseWallet) - issue_suite = await self._get_issue_suite( - wallet=wallet, - issuer_id=issuer_id, - ) - signed_vp = await sign_presentation( - presentation=vp, - suite=issue_suite, - challenge=challenge, - document_loader=document_loader, - ) + issue_suite = await self._get_issue_suite( + issuer_id=issuer_id, + ) + signed_vp = await sign_presentation( + presentation=vp, + suite=issue_suite, + challenge=challenge, + document_loader=document_loader, + ) result_vp.append(signed_vp) if len(result_vp) == 1: return result_vp[0] diff --git a/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/handler.py b/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/handler.py index 868d7148bf..8a656368f8 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/handler.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/handler.py @@ -21,7 +21,6 @@ WalletKeyPair, ) from ......vc.vc_ld.verify import verify_presentation -from ......wallet.base import BaseWallet from ......wallet.key_type import ED25519, BLS12381G2 from .....problem_report.v1_0.message import ProblemReport @@ -65,13 +64,13 @@ class DIFPresFormatHandler(V20PresFormatHandler): ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING[BbsBlsSignature2020] = BLS12381G2 ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING[BbsBlsSignatureProof2020] = BLS12381G2 - async def _get_all_suites(self, wallet: BaseWallet): + async def _get_all_suites(self): """Get all supported suites for verifying presentation.""" suites = [] for suite, key_type in self.ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING.items(): suites.append( suite( - key_pair=WalletKeyPair(wallet=wallet, key_type=key_type), + key_pair=WalletKeyPair(profile=self._profile, key_type=key_type), ) ) return suites @@ -471,33 +470,31 @@ async def verify_pres(self, pres_ex_record: V20PresExRecord) -> V20PresExRecord: presentation exchange record, updated """ - async with self._profile.session() as session: - wallet = session.inject(BaseWallet) - dif_proof = pres_ex_record.pres.attachment(DIFPresFormatHandler.format) - pres_request = pres_ex_record.pres_request.attachment( - DIFPresFormatHandler.format - ) - challenge = None - if "options" in pres_request: - challenge = pres_request["options"].get("challenge", str(uuid4())) - if not challenge: - challenge = str(uuid4()) - if isinstance(dif_proof, Sequence): - for proof in dif_proof: - pres_ver_result = await verify_presentation( - presentation=proof, - suites=await self._get_all_suites(wallet=wallet), - document_loader=self._profile.inject(DocumentLoader), - challenge=challenge, - ) - if not pres_ver_result.verified: - break - else: + dif_proof = pres_ex_record.pres.attachment(DIFPresFormatHandler.format) + pres_request = pres_ex_record.pres_request.attachment( + DIFPresFormatHandler.format + ) + challenge = None + if "options" in pres_request: + challenge = pres_request["options"].get("challenge", str(uuid4())) + if not challenge: + challenge = str(uuid4()) + if isinstance(dif_proof, Sequence): + for proof in dif_proof: pres_ver_result = await verify_presentation( - presentation=dif_proof, - suites=await self._get_all_suites(wallet=wallet), + presentation=proof, + suites=await self._get_all_suites(), document_loader=self._profile.inject(DocumentLoader), challenge=challenge, ) - pres_ex_record.verified = json.dumps(pres_ver_result.verified) - return pres_ex_record + if not pres_ver_result.verified: + break + else: + pres_ver_result = await verify_presentation( + presentation=dif_proof, + suites=await self._get_all_suites(), + document_loader=self._profile.inject(DocumentLoader), + challenge=challenge, + ) + pres_ex_record.verified = json.dumps(pres_ver_result.verified) + return pres_ex_record diff --git a/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/tests/test_handler.py b/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/tests/test_handler.py index 8143083c0a..8986ff42ac 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/tests/test_handler.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/tests/test_handler.py @@ -396,7 +396,7 @@ def test_validate_fields(self): self.handler.validate_fields(PRES_20, incorrect_pres) async def test_get_all_suites(self): - suites = await self.handler._get_all_suites(self.wallet) + suites = await self.handler._get_all_suites() assert len(suites) == 4 types = [ Ed25519Signature2018, diff --git a/aries_cloudagent/vc/ld_proofs/crypto/tests/test_wallet_key_pair.py b/aries_cloudagent/vc/ld_proofs/crypto/tests/test_wallet_key_pair.py index 580ce4254a..d1842d9ac2 100644 --- a/aries_cloudagent/vc/ld_proofs/crypto/tests/test_wallet_key_pair.py +++ b/aries_cloudagent/vc/ld_proofs/crypto/tests/test_wallet_key_pair.py @@ -2,7 +2,8 @@ from aries_cloudagent.wallet.key_type import ED25519 - +from .....core.in_memory import InMemoryProfile +from .....wallet.in_memory import InMemoryWallet from ...error import LinkedDataProofException from ..wallet_key_pair import WalletKeyPair @@ -10,10 +11,10 @@ class TestWalletKeyPair(TestCase): async def setUp(self): - self.wallet = async_mock.MagicMock() + self.profile = InMemoryProfile.test_profile() async def test_sign_x_no_public_key(self): - key_pair = WalletKeyPair(wallet=self.wallet, key_type=ED25519) + key_pair = WalletKeyPair(profile=self.profile, key_type=ED25519) with self.assertRaises(LinkedDataProofException) as context: await key_pair.sign(b"Message") @@ -22,23 +23,26 @@ async def test_sign_x_no_public_key(self): async def test_sign(self): public_key_base58 = "verkey" key_pair = WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=ED25519, public_key_base58=public_key_base58, ) signed = async_mock.MagicMock() - self.wallet.sign_message = async_mock.CoroutineMock(return_value=signed) - - singed_ret = await key_pair.sign(b"Message") + with async_mock.patch.object( + InMemoryWallet, + "sign_message", + async_mock.CoroutineMock(return_value=signed), + ) as sign_message: + singed_ret = await key_pair.sign(b"Message") - assert signed == singed_ret - self.wallet.sign_message.assert_called_once_with( - message=b"Message", from_verkey=public_key_base58 - ) + assert signed == singed_ret + sign_message.assert_called_once_with( + message=b"Message", from_verkey=public_key_base58 + ) async def test_verify_x_no_public_key(self): - key_pair = WalletKeyPair(wallet=self.wallet, key_type=ED25519) + key_pair = WalletKeyPair(profile=self.profile, key_type=ED25519) with self.assertRaises(LinkedDataProofException) as context: await key_pair.verify(b"Message", b"signature") @@ -47,24 +51,28 @@ async def test_verify_x_no_public_key(self): async def test_verify(self): public_key_base58 = "verkey" key_pair = WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=ED25519, public_key_base58=public_key_base58, ) - self.wallet.verify_message = async_mock.CoroutineMock(return_value=True) - verified = await key_pair.verify(b"Message", b"signature") - - assert verified - self.wallet.verify_message.assert_called_once_with( - message=b"Message", - signature=b"signature", - from_verkey=public_key_base58, - key_type=ED25519, - ) + with async_mock.patch.object( + InMemoryWallet, + "verify_message", + async_mock.CoroutineMock(return_value=True), + ) as verify_message: + verified = await key_pair.verify(b"Message", b"signature") + + assert verified + verify_message.assert_called_once_with( + message=b"Message", + signature=b"signature", + from_verkey=public_key_base58, + key_type=ED25519, + ) async def test_from_verification_method_x_no_public_key_base58(self): - key_pair = WalletKeyPair(wallet=self.wallet, key_type=ED25519) + key_pair = WalletKeyPair(profile=self.profile, key_type=ED25519) with self.assertRaises(LinkedDataProofException) as context: key_pair.from_verification_method({}) diff --git a/aries_cloudagent/vc/ld_proofs/crypto/wallet_key_pair.py b/aries_cloudagent/vc/ld_proofs/crypto/wallet_key_pair.py index f666b739ac..8d99eaed90 100644 --- a/aries_cloudagent/vc/ld_proofs/crypto/wallet_key_pair.py +++ b/aries_cloudagent/vc/ld_proofs/crypto/wallet_key_pair.py @@ -2,9 +2,10 @@ from typing import List, Optional, Union -from ....wallet.util import b58_to_bytes -from ....wallet.key_type import KeyType +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 @@ -17,13 +18,13 @@ class WalletKeyPair(KeyPair): def __init__( self, *, - wallet: BaseWallet, + profile: Profile, key_type: KeyType, public_key_base58: Optional[str] = None, ) -> None: """Initialize new WalletKeyPair instance.""" super().__init__() - self.wallet = wallet + self.profile = profile self.key_type = key_type self.public_key_base58 = public_key_base58 @@ -33,10 +34,12 @@ async def sign(self, message: Union[List[bytes], bytes]) -> bytes: raise LinkedDataProofException( "Unable to sign message with WalletKey: No key to sign with" ) - return await self.wallet.sign_message( - message=message, - from_verkey=self.public_key_base58, - ) + async with self.profile.session() as session: + wallet = session.inject(BaseWallet) + return await wallet.sign_message( + message=message, + from_verkey=self.public_key_base58, + ) async def verify( self, message: Union[List[bytes], bytes], signature: bytes @@ -47,12 +50,14 @@ async def verify( "Unable to verify message with key pair: No key to verify with" ) - return await self.wallet.verify_message( - message=message, - signature=signature, - from_verkey=self.public_key_base58, - key_type=self.key_type, - ) + async with self.profile.session() as session: + wallet = session.inject(BaseWallet) + return await wallet.verify_message( + message=message, + signature=signature, + from_verkey=self.public_key_base58, + key_type=self.key_type, + ) def from_verification_method(self, verification_method: dict) -> "WalletKeyPair": """Create new WalletKeyPair from public key in verification method.""" @@ -62,7 +67,7 @@ def from_verification_method(self, verification_method: dict) -> "WalletKeyPair" ) return WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=self.key_type, public_key_base58=verification_method["publicKeyBase58"], ) diff --git a/aries_cloudagent/vc/ld_proofs/suites/tests/test_bbs_bls_signature_2020.py b/aries_cloudagent/vc/ld_proofs/suites/tests/test_bbs_bls_signature_2020.py index ba477604e8..a5a141c174 100644 --- a/aries_cloudagent/vc/ld_proofs/suites/tests/test_bbs_bls_signature_2020.py +++ b/aries_cloudagent/vc/ld_proofs/suites/tests/test_bbs_bls_signature_2020.py @@ -3,9 +3,9 @@ from aries_cloudagent.wallet.key_type import BLS12381G2 +from .....core.in_memory import InMemoryProfile from .....did.did_key import DIDKey from .....wallet.in_memory import InMemoryWallet -from .....core.in_memory import InMemoryProfile from ....tests.document_loader import custom_document_loader from ....tests.data import ( TEST_LD_DOCUMENT, @@ -38,11 +38,11 @@ async def setUp(self): ).key_id self.sign_key_pair = WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=BLS12381G2, public_key_base58=self.key.verkey, ) - self.verify_key_pair = WalletKeyPair(wallet=self.wallet, key_type=BLS12381G2) + self.verify_key_pair = WalletKeyPair(profile=self.profile, key_type=BLS12381G2) async def test_sign_ld_proofs(self): signed = await sign( diff --git a/aries_cloudagent/vc/ld_proofs/suites/tests/test_bbs_bls_signature_proof_2020.py b/aries_cloudagent/vc/ld_proofs/suites/tests/test_bbs_bls_signature_proof_2020.py index df2080480d..ae217d4b63 100644 --- a/aries_cloudagent/vc/ld_proofs/suites/tests/test_bbs_bls_signature_proof_2020.py +++ b/aries_cloudagent/vc/ld_proofs/suites/tests/test_bbs_bls_signature_proof_2020.py @@ -3,9 +3,9 @@ from aries_cloudagent.wallet.key_type import BLS12381G2 +from .....core.in_memory import InMemoryProfile from .....did.did_key import DIDKey from .....wallet.in_memory import InMemoryWallet -from .....core.in_memory import InMemoryProfile from ....tests.document_loader import custom_document_loader from ....tests.data import ( TEST_LD_DOCUMENT_SIGNED_BBS, @@ -46,7 +46,7 @@ async def setUp(self): self.key.verkey, BLS12381G2 ).key_id - self.key_pair = WalletKeyPair(wallet=self.wallet, key_type=BLS12381G2) + self.key_pair = WalletKeyPair(profile=self.profile, key_type=BLS12381G2) async def test_derive_ld_proofs(self): derived = await derive( diff --git a/aries_cloudagent/vc/ld_proofs/suites/tests/test_ed25519_signature_2018.py b/aries_cloudagent/vc/ld_proofs/suites/tests/test_ed25519_signature_2018.py index 20e510df3e..fdae59d396 100644 --- a/aries_cloudagent/vc/ld_proofs/suites/tests/test_ed25519_signature_2018.py +++ b/aries_cloudagent/vc/ld_proofs/suites/tests/test_ed25519_signature_2018.py @@ -37,11 +37,11 @@ async def setUp(self): ).key_id self.sign_key_pair = WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=ED25519, public_key_base58=self.key.verkey, ) - self.verify_key_pair = WalletKeyPair(wallet=self.wallet, key_type=ED25519) + self.verify_key_pair = WalletKeyPair(profile=self.profile, key_type=ED25519) async def test_sign_ld_proofs(self): signed = await sign( diff --git a/aries_cloudagent/vc/ld_proofs/suites/tests/test_ed25519_signature_2020.py b/aries_cloudagent/vc/ld_proofs/suites/tests/test_ed25519_signature_2020.py index 165a32fc21..c527e3aa48 100644 --- a/aries_cloudagent/vc/ld_proofs/suites/tests/test_ed25519_signature_2020.py +++ b/aries_cloudagent/vc/ld_proofs/suites/tests/test_ed25519_signature_2020.py @@ -32,11 +32,11 @@ async def setUp(self): ).key_id self.sign_key_pair = WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=ED25519, public_key_base58=self.key.verkey, ) - self.verify_key_pair = WalletKeyPair(wallet=self.wallet, key_type=ED25519) + self.verify_key_pair = WalletKeyPair(profile=self.profile, key_type=ED25519) async def test_sign_ld_proofs(self): signed = await sign( diff --git a/aries_cloudagent/vc/ld_proofs/tests/test_ld_proofs.py b/aries_cloudagent/vc/ld_proofs/tests/test_ld_proofs.py index b8eaecc379..26f170793e 100644 --- a/aries_cloudagent/vc/ld_proofs/tests/test_ld_proofs.py +++ b/aries_cloudagent/vc/ld_proofs/tests/test_ld_proofs.py @@ -65,7 +65,7 @@ async def test_sign_Ed25519Signature2018(self): suite = Ed25519Signature2018( verification_method=self.ed25519_verification_method, key_pair=WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=ED25519, public_key_base58=self.ed25519_key_info.verkey, ), @@ -87,7 +87,7 @@ async def test_sign_Ed25519Signature2020(self): suite = Ed25519Signature2020( verification_method=self.ed25519_verification_method, key_pair=WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=ED25519, public_key_base58=self.ed25519_key_info.verkey, ), @@ -105,7 +105,7 @@ async def test_sign_Ed25519Signature2020(self): async def test_verify_Ed25519Signature2018(self): # Verification requires lot less input parameters suite = Ed25519Signature2018( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=ED25519), + key_pair=WalletKeyPair(profile=self.profile, key_type=ED25519), ) result = await verify( @@ -120,7 +120,7 @@ async def test_verify_Ed25519Signature2018(self): async def test_verify_Ed25519Signature2020(self): # Verification requires lot less input parameters suite = Ed25519Signature2020( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=ED25519), + key_pair=WalletKeyPair(profile=self.profile, key_type=ED25519), ) result = await verify( @@ -140,7 +140,7 @@ async def test_sign_BbsBlsSignature2020(self): suite = BbsBlsSignature2020( verification_method=self.bls12381g2_verification_method, key_pair=WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=BLS12381G2, public_key_base58=self.bls12381g2_key_info.verkey, ), @@ -169,7 +169,7 @@ async def test_sign_BbsBlsSignature2020(self): async def test_verify_BbsBlsSignature2020(self): # Verification requires lot less input parameters suite = BbsBlsSignature2020( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=BLS12381G2), + key_pair=WalletKeyPair(profile=self.profile, key_type=BLS12381G2), ) result = await verify( @@ -185,7 +185,7 @@ async def test_verify_BbsBlsSignature2020(self): async def test_derive_BbsBlsSignatureProof2020(self): # Verification requires lot less input parameters suite = BbsBlsSignatureProof2020( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=BLS12381G2), + key_pair=WalletKeyPair(profile=self.profile, key_type=BLS12381G2), ) result = await derive( @@ -201,7 +201,7 @@ async def test_derive_BbsBlsSignatureProof2020(self): async def test_verify_BbsBlsSignatureProof2020(self): # Verification requires lot less input parameters suite = BbsBlsSignatureProof2020( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=BLS12381G2), + key_pair=WalletKeyPair(profile=self.profile, key_type=BLS12381G2), ) result = await verify( diff --git a/aries_cloudagent/vc/tests/test_bbs_mattr_interop.py b/aries_cloudagent/vc/tests/test_bbs_mattr_interop.py index d9f4dde009..0fd50ccbc1 100644 --- a/aries_cloudagent/vc/tests/test_bbs_mattr_interop.py +++ b/aries_cloudagent/vc/tests/test_bbs_mattr_interop.py @@ -51,17 +51,17 @@ async def setUp(self): self.signature_issuer_suite = BbsBlsSignature2020( verification_method="did:example:489398593#test", key_pair=WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=BLS12381G2, public_key_base58=public_key_base58, ), ) self.signature_suite = BbsBlsSignature2020( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=BLS12381G2), + key_pair=WalletKeyPair(profile=self.profile, key_type=BLS12381G2), ) self.proof_suite = BbsBlsSignatureProof2020( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=BLS12381G2) + key_pair=WalletKeyPair(profile=self.profile, key_type=BLS12381G2) ) async def test_sign_bbs_vc_mattr(self): diff --git a/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py b/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py index d155dadd8f..d169a1907a 100644 --- a/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py +++ b/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py @@ -68,7 +68,7 @@ async def test_issue_Ed25519Signature2018(self): suite = Ed25519Signature2018( verification_method=self.ed25519_verification_method, key_pair=WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=ED25519, public_key_base58=self.ed25519_key_info.verkey, ), @@ -90,7 +90,7 @@ async def test_issue_Ed25519Signature2020(self): suite = Ed25519Signature2020( verification_method=self.ed25519_verification_method, key_pair=WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=ED25519, public_key_base58=self.ed25519_key_info.verkey, ), @@ -133,7 +133,7 @@ async def test_derive_x_invalid_credential_structure(self): async def test_verify_Ed25519Signature2018(self): # Verification requires lot less input parameters suite = Ed25519Signature2018( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=ED25519), + key_pair=WalletKeyPair(profile=self.profile, key_type=ED25519), ) verified = await verify_credential( credential=CREDENTIAL_ISSUED, @@ -146,7 +146,7 @@ async def test_verify_Ed25519Signature2018(self): async def test_verify_Ed25519Signature2020(self): # Verification requires lot less input parameters suite = Ed25519Signature2020( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=ED25519), + key_pair=WalletKeyPair(profile=self.profile, key_type=ED25519), ) verified = await verify_credential( credential=CREDENTIAL_ISSUED_2020, @@ -177,7 +177,7 @@ async def test_issue_BbsBlsSignature2020(self): suite = BbsBlsSignature2020( verification_method=self.bls12381g2_verification_method, key_pair=WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=BLS12381G2, public_key_base58=self.bls12381g2_key_info.verkey, ), @@ -201,7 +201,7 @@ async def test_issue_BbsBlsSignature2020(self): async def test_verify_BbsBlsSignature2020(self): # Verification requires lot less input parameters suite = BbsBlsSignature2020( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=BLS12381G2), + key_pair=WalletKeyPair(profile=self.profile, key_type=BLS12381G2), ) result = await verify_credential( credential=CREDENTIAL_ISSUED_BBS, @@ -227,7 +227,7 @@ async def test_create_presentation_x_invalid_credential_structures(self): suite = Ed25519Signature2018( verification_method=self.ed25519_verification_method, key_pair=WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=ED25519, public_key_base58=self.ed25519_key_info.verkey, ), @@ -260,7 +260,7 @@ async def test_sign_presentation_bbsbls(self): suite = BbsBlsSignature2020( verification_method=self.bls12381g2_verification_method, key_pair=WalletKeyPair( - wallet=self.wallet, + profile=self.profile, key_type=BLS12381G2, public_key_base58=self.bls12381g2_key_info.verkey, ), @@ -269,7 +269,7 @@ async def test_sign_presentation_bbsbls(self): assert unsigned_presentation == PRESENTATION_UNSIGNED unsigned_presentation["@context"].append("https://w3id.org/security/bbs/v1") - presentation = await sign_presentation( + _ = await sign_presentation( presentation=unsigned_presentation, suite=suite, document_loader=custom_document_loader, @@ -278,7 +278,7 @@ async def test_sign_presentation_bbsbls(self): async def test_verify_presentation(self): suite = Ed25519Signature2018( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=ED25519), + key_pair=WalletKeyPair(profile=self.profile, key_type=ED25519), ) verification_result = await verify_presentation( presentation=PRESENTATION_SIGNED,