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 c9e6eb8ee1..747c112235 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 @@ -275,8 +275,8 @@ async def _get_suite_for_detail( verkey_id_strategy = self.profile.context.inject(BaseVerificationKeyStrategy) verification_method = ( verification_method - or verkey_id_strategy.get_verification_method_id_for_did( - issuer_id, proof_purpose="assertionMethod" + or await verkey_id_strategy.get_verification_method_id_for_did( + issuer_id, self.profile, proof_purpose="assertionMethod" ) ) 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 5fe28602a1..46962448f0 100644 --- a/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py +++ b/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py @@ -120,8 +120,10 @@ async def _get_issue_suite( """Get signature suite for signing presentation.""" did_info = await self._did_info_for_did(issuer_id) verkey_id_strategy = self.profile.context.inject(BaseVerificationKeyStrategy) - verification_method = verkey_id_strategy.get_verification_method_id_for_did( - issuer_id, proof_purpose="assertionMethod" + verification_method = ( + await verkey_id_strategy.get_verification_method_id_for_did( + issuer_id, self.profile, proof_purpose="assertionMethod" + ) ) if verification_method is None: diff --git a/aries_cloudagent/wallet/default_verification_key_strategy.py b/aries_cloudagent/wallet/default_verification_key_strategy.py index 4a5ffd89b1..4f580618b3 100644 --- a/aries_cloudagent/wallet/default_verification_key_strategy.py +++ b/aries_cloudagent/wallet/default_verification_key_strategy.py @@ -2,6 +2,8 @@ from abc import ABC, abstractmethod from typing import Optional, List +from aries_cloudagent.core.profile import Profile + from aries_cloudagent.wallet.key_type import KeyType from aries_cloudagent.did.did_key import DIDKey @@ -11,9 +13,10 @@ class BaseVerificationKeyStrategy(ABC): """Base class for defining which verification method is in use.""" @abstractmethod - def get_verification_method_id_for_did( + async def get_verification_method_id_for_did( self, did: str, + profile: Optional[Profile], allowed_verification_method_types: Optional[List[KeyType]] = None, proof_purpose: Optional[str] = None, ) -> Optional[str]: @@ -22,6 +25,7 @@ def get_verification_method_id_for_did( Returns None if no strategy is specified for this DID. :params did: the did + :params profile: context of the call :params allowed_verification_method_types: list of accepted key types :params proof_purpose: the verkey relationship (assertionMethod, keyAgreement, ..) :returns Optional[str]: the current verkey ID @@ -35,9 +39,10 @@ class DefaultVerificationKeyStrategy(BaseVerificationKeyStrategy): Supports did:key: and did:sov only. """ - def get_verification_method_id_for_did( + async def get_verification_method_id_for_did( self, did: str, + profile: Optional[Profile], allowed_verification_method_types: Optional[List[KeyType]] = None, proof_purpose: Optional[str] = None, ) -> Optional[str]: @@ -45,7 +50,8 @@ def get_verification_method_id_for_did( Returns None if no strategy is specified for this DID. - :params str did: the did + :params did: the did + :params profile: context of the call :params allowed_verification_method_types: list of accepted key types :params proof_purpose: the verkey relationship (assertionMethod, keyAgreement, ..) :returns Optional[str]: the current verkey ID diff --git a/aries_cloudagent/wallet/tests/test_default_verification_key_strategy.py b/aries_cloudagent/wallet/tests/test_default_verification_key_strategy.py index c53207836e..1d610f53fe 100644 --- a/aries_cloudagent/wallet/tests/test_default_verification_key_strategy.py +++ b/aries_cloudagent/wallet/tests/test_default_verification_key_strategy.py @@ -1,5 +1,7 @@ from unittest import TestCase +from aries_cloudagent.core.profile import Profile + from aries_cloudagent.did.did_key import DIDKey from aries_cloudagent.wallet.default_verification_key_strategy import ( @@ -11,20 +13,25 @@ class TestDefaultVerificationKeyStrategy(TestCase): - def test_with_did_sov(self): + async def test_with_did_sov(self): strategy = DefaultVerificationKeyStrategy() assert ( - strategy.get_verification_method_id_for_did(TEST_DID_SOV) + await strategy.get_verification_method_id_for_did(TEST_DID_SOV, Profile()) == TEST_DID_SOV + "#key-1" ) - def test_with_did_key(self): + async def test_with_did_key(self): strategy = DefaultVerificationKeyStrategy() assert ( - strategy.get_verification_method_id_for_did(TEST_DID_KEY) + await strategy.get_verification_method_id_for_did(TEST_DID_KEY, Profile()) == DIDKey.from_did(TEST_DID_KEY).key_id ) - def test_unsupported_did_method(self): + async def test_unsupported_did_method(self): strategy = DefaultVerificationKeyStrategy() - assert strategy.get_verification_method_id_for_did("did:test:test") is None + assert ( + await strategy.get_verification_method_id_for_did( + "did:test:test", Profile() + ) + is None + )