From 3efe5d889f22a36196c9eca6f0c4d378ef6b3fac Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Tue, 20 Sep 2022 14:02:10 -0600 Subject: [PATCH 01/22] did method registry Signed-off-by: Adam Burdett --- aries_cloudagent/wallet/did_method.py | 109 ++++++++++---------------- 1 file changed, 43 insertions(+), 66 deletions(-) diff --git a/aries_cloudagent/wallet/did_method.py b/aries_cloudagent/wallet/did_method.py index 797c26fd20..1d337e6ee3 100644 --- a/aries_cloudagent/wallet/did_method.py +++ b/aries_cloudagent/wallet/did_method.py @@ -1,91 +1,68 @@ """Did method enum.""" -from typing import List, Mapping, NamedTuple, Optional -from enum import Enum - -from .key_type import KeyType +from typing import Dict, List, Mapping, Optional from .error import BaseError +from .key_type import KeyType -DIDMethodSpec = NamedTuple( - "DIDMethodSpec", - [ - ("method_name", str), - ("supported_key_types", List[KeyType]), - ("supports_rotation", bool), - ], -) +class DIDMethod: + """Class to represent a did method.""" -class DIDMethod(Enum): - """DID Method class specifying DID methods with supported key types.""" - - SOV = DIDMethodSpec( - method_name="sov", supported_key_types=[KeyType.ED25519], supports_rotation=True - ) - KEY = DIDMethodSpec( - method_name="key", - supported_key_types=[KeyType.ED25519, KeyType.BLS12381G2], - supports_rotation=False, - ) + def __init__(self, name, key_types, rotation) -> None: + self._method_name: str = name + self._supported_key_types: List[KeyType] = key_types + self._supports_rotation: bool = rotation @property - def method_name(self) -> str: - """Getter for did method name. e.g. sov or key.""" - return self.value.method_name + def method_name(self): + """Get method name.""" + return self._method_name @property - def supported_key_types(self) -> List[KeyType]: - """Getter for supported key types of method.""" - return self.value.supported_key_types + def supports_rotation(self): + """Check rotation support.""" + return self._supports_rotation @property - def supports_rotation(self) -> bool: - """Check whether the current method supports key rotation.""" - return self.value.supports_rotation + def supported_key_types(self): + """Get supported key types.""" + return self._supported_key_types def supports_key_type(self, key_type: KeyType) -> bool: """Check whether the current method supports the key type.""" return key_type in self.supported_key_types - @classmethod - def from_metadata(cls, metadata: Mapping) -> "DIDMethod": - """Get DID method instance from metadata object. - - Returns SOV if no metadata was found for backwards compatability. - """ - method = metadata.get("method") - - # extract from metadata object - if method: - for did_method in DIDMethod: - if method == did_method.method_name: - return did_method - # return default SOV for backward compat - return DIDMethod.SOV +class DIDMethods: + """DID Method class specifying DID methods with supported key types.""" - @classmethod - def from_method(cls, method: str) -> Optional["DIDMethod"]: - """Get DID method instance from the method name.""" - for did_method in DIDMethod: - if method == did_method.method_name: - return did_method + def __init__(self) -> None: + self._registry: Dict[str, DIDMethod] = {} - return None + def registered(self, method: str) -> bool: + """Check for a supported method.""" + return method in list(self._registry.items()) - @classmethod - def from_did(cls, did: str) -> "DIDMethod": - """Get DID method instance from the method name.""" - if not did.startswith("did:"): - # sov has no prefix - return DIDMethod.SOV + def register(self, method: DIDMethod): + """Registers a new did method.""" + self._registry[method.method_name] = method - parts = did.split(":") - method_str = parts[1] + def from_method(self, method_name: str) -> Optional[DIDMethod]: + """Retrieve a did method from method name.""" + method: DIDMethod = self._registry[method_name] + if method: + return method + raise BaseError(f"Unsupported did method: {method_name}") - method = DIDMethod.from_method(method_str) + def from_metadata(self, metadata: Mapping) -> Optional[DIDMethod]: + """Get DID method instance from metadata object. - if not method: - raise BaseError(f"Unsupported did method: {method_str}") + Returns SOV if no metadata was found for backwards compatibility. + """ + method_name: str = metadata.get("method", "sov") + return self.from_method(method_name) - return method + def from_did(self, did: str) -> Optional[DIDMethod]: + """Get DID method instance from the did url.""" + method_name = did.split(":")[1] if did.startswith("did:") else "sov" + return self.from_method(method_name) From 3adcde672efc096a0904be0afd9a22f299104782 Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Tue, 20 Sep 2022 14:32:22 -0600 Subject: [PATCH 02/22] static SOV/KEY methods Signed-off-by: Adam Burdett --- aries_cloudagent/wallet/did_method.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/aries_cloudagent/wallet/did_method.py b/aries_cloudagent/wallet/did_method.py index 1d337e6ee3..87436a44d7 100644 --- a/aries_cloudagent/wallet/did_method.py +++ b/aries_cloudagent/wallet/did_method.py @@ -1,4 +1,4 @@ -"""Did method enum.""" +"""Did method classes.""" from typing import Dict, List, Mapping, Optional from .error import BaseError @@ -33,6 +33,14 @@ def supports_key_type(self, key_type: KeyType) -> bool: return key_type in self.supported_key_types +SOV = DIDMethod(name="sov", key_types=[KeyType.ED25519], rotation=True) +KEY = DIDMethod( + name="key", + key_types=[KeyType.ED25519, KeyType.BLS12381G2], + rotation=False, +) + + class DIDMethods: """DID Method class specifying DID methods with supported key types.""" @@ -49,10 +57,7 @@ def register(self, method: DIDMethod): def from_method(self, method_name: str) -> Optional[DIDMethod]: """Retrieve a did method from method name.""" - method: DIDMethod = self._registry[method_name] - if method: - return method - raise BaseError(f"Unsupported did method: {method_name}") + return self._registry[method_name] def from_metadata(self, metadata: Mapping) -> Optional[DIDMethod]: """Get DID method instance from metadata object. @@ -62,7 +67,10 @@ def from_metadata(self, metadata: Mapping) -> Optional[DIDMethod]: method_name: str = metadata.get("method", "sov") return self.from_method(method_name) - def from_did(self, did: str) -> Optional[DIDMethod]: + def from_did(self, did: str) -> DIDMethod: """Get DID method instance from the did url.""" - method_name = did.split(":")[1] if did.startswith("did:") else "sov" - return self.from_method(method_name) + method_name = did.split(":")[1] if did.startswith("did:") else SOV.method_name + method: DIDMethod | None = self.from_method(method_name) + if not method: + raise BaseError(f"Unsupported did method: {method_name}") + return method From e9cba3b6f533b9d37cf7f5b2ffe94aad77812532 Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Wed, 21 Sep 2022 07:38:40 -0600 Subject: [PATCH 03/22] static SOV & KEY method Signed-off-by: Adam Burdett --- aries_cloudagent/config/wallet.py | 10 +- aries_cloudagent/core/tests/test_conductor.py | 16 +-- aries_cloudagent/ledger/tests/test_indy.py | 14 +-- .../ledger/tests/test_indy_vdr.py | 34 +++--- .../decorators/tests/test_attach_decorator.py | 6 +- .../messaging/jsonld/tests/test_routes.py | 4 +- .../multitenant/tests/test_base.py | 4 +- .../protocols/connections/v1_0/manager.py | 16 +-- .../connections/v1_0/tests/test_manager.py | 104 +++++++++--------- .../coordinate_mediation/v1_0/manager.py | 4 +- .../v1_0/route_manager.py | 4 +- .../handlers/tests/test_request_handler.py | 4 +- .../handlers/tests/test_response_handler.py | 4 +- .../protocols/didexchange/v1_0/manager.py | 10 +- .../v1_0/messages/tests/test_request.py | 6 +- .../v1_0/messages/tests/test_response.py | 6 +- .../didexchange/v1_0/tests/test_manager.py | 46 ++++---- .../v1_0/tests/test_manager.py | 4 +- .../v1_0/tests/test_routes.py | 30 ++--- .../formats/ld_proof/tests/test_handler.py | 6 +- .../out_of_band/v1_0/tests/test_manager.py | 20 ++-- .../dif/tests/test_pres_exch_handler.py | 18 +-- .../transport/tests/test_pack_format.py | 8 +- .../utils/tests/test_outofband.py | 4 +- aries_cloudagent/wallet/askar.py | 12 +- aries_cloudagent/wallet/base.py | 4 +- aries_cloudagent/wallet/in_memory.py | 8 +- aries_cloudagent/wallet/indy.py | 32 +++--- aries_cloudagent/wallet/routes.py | 16 +-- .../wallet/tests/test_in_memory_wallet.py | 72 ++++++------ .../wallet/tests/test_indy_wallet.py | 24 ++-- .../wallet/tests/test_key_type.py | 18 +-- aries_cloudagent/wallet/tests/test_routes.py | 76 ++++++------- 33 files changed, 322 insertions(+), 322 deletions(-) diff --git a/aries_cloudagent/config/wallet.py b/aries_cloudagent/config/wallet.py index 61e34b2a73..577290ff7c 100644 --- a/aries_cloudagent/config/wallet.py +++ b/aries_cloudagent/config/wallet.py @@ -11,7 +11,7 @@ from ..wallet.base import BaseWallet from ..wallet.crypto import seed_to_did from ..wallet.did_info import DIDInfo -from ..wallet.did_method import DIDMethod +from ..wallet.did_method import SOV from ..wallet.key_type import KeyType from .base import ConfigError from .injection_context import InjectionContext @@ -79,7 +79,7 @@ async def wallet_config( if wallet_seed and seed_to_did(wallet_seed) != public_did: if context.settings.get("wallet.replace_public_did"): replace_did_info = await wallet.create_local_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=wallet_seed + method=SOV, key_type=KeyType.ED25519, seed=wallet_seed ) public_did = replace_did_info.did await wallet.set_public_did(public_did) @@ -99,7 +99,7 @@ async def wallet_config( metadata = {"endpoint": endpoint} if endpoint else None local_did_info = await wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=wallet_seed, metadata=metadata, @@ -110,7 +110,7 @@ async def wallet_config( print(f"Verkey: {local_did_info.verkey}") else: public_did_info = await wallet.create_public_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=wallet_seed + method=SOV, key_type=KeyType.ED25519, seed=wallet_seed ) public_did = public_did_info.did if provision: @@ -128,7 +128,7 @@ async def wallet_config( test_seed = "testseed000000000000000000000001" if test_seed: await wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=test_seed, metadata={"endpoint": "1.2.3.4:8021"}, diff --git a/aries_cloudagent/core/tests/test_conductor.py b/aries_cloudagent/core/tests/test_conductor.py index 203ca1b3b4..3a864cee7d 100644 --- a/aries_cloudagent/core/tests/test_conductor.py +++ b/aries_cloudagent/core/tests/test_conductor.py @@ -41,7 +41,7 @@ from ...version import __version__ from ...wallet.base import BaseWallet from ...wallet.key_type import KeyType -from ...wallet.did_method import DIDMethod +from ...wallet.did_method import SOV from .. import conductor as test_module @@ -131,7 +131,7 @@ async def test_startup(self): wallet = session.inject(BaseWallet) await wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) @@ -600,7 +600,7 @@ async def test_admin(self): session = await conductor.root_profile.session() wallet = session.inject(BaseWallet) await wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) @@ -644,7 +644,7 @@ async def test_admin_startx(self): session = await conductor.root_profile.session() wallet = session.inject(BaseWallet) await wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) @@ -716,7 +716,7 @@ async def test_start_static(self): session = await conductor.root_profile.session() wallet = session.inject(BaseWallet) await wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) @@ -886,7 +886,7 @@ async def test_print_invite_connection(self): session = await conductor.root_profile.session() wallet = session.inject(BaseWallet) await wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) @@ -1389,7 +1389,7 @@ async def test_startup_x_version_mismatch(self): wallet = session.inject(BaseWallet) await wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) @@ -1426,7 +1426,7 @@ async def test_startup_x_no_storage_version(self): wallet = session.inject(BaseWallet) await wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) diff --git a/aries_cloudagent/ledger/tests/test_indy.py b/aries_cloudagent/ledger/tests/test_indy.py index bda1890c2a..7696625b31 100644 --- a/aries_cloudagent/ledger/tests/test_indy.py +++ b/aries_cloudagent/ledger/tests/test_indy.py @@ -20,7 +20,7 @@ from ...wallet.error import WalletNotFoundError from ...wallet.indy import IndyOpenWallet, IndySdkWallet from ...wallet.key_type import KeyType -from ...wallet.did_method import DIDMethod +from ...wallet.did_method import SOV from ..endpoint_type import EndpointType from ..indy import ( @@ -70,7 +70,7 @@ async def setUp(self): did=self.test_did, verkey="3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx", metadata={"test": "test"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) self.test_verkey = "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx" @@ -1219,7 +1219,7 @@ async def test_send_credential_definition( did=self.test_did, verkey=self.test_verkey, metadata=None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mock_did = mock_wallet_get_public_did.return_value @@ -1299,7 +1299,7 @@ async def test_send_credential_definition_endorse_only( self.test_did, self.test_verkey, None, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) async with ledger: @@ -1382,7 +1382,7 @@ async def test_send_credential_definition_exists_in_ledger_and_wallet( did=self.test_did, verkey=self.test_verkey, metadata=None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1794,7 +1794,7 @@ async def test_send_credential_definition_on_ledger_in_wallet( did=self.test_did, verkey=self.test_verkey, metadata=None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mock_did = mock_wallet_get_public_did.return_value @@ -1868,7 +1868,7 @@ async def test_send_credential_definition_create_cred_def_exception( did=self.test_did, verkey=self.test_verkey, metadata=None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) async with ledger: diff --git a/aries_cloudagent/ledger/tests/test_indy_vdr.py b/aries_cloudagent/ledger/tests/test_indy_vdr.py index f20781e838..0d39e4daf6 100644 --- a/aries_cloudagent/ledger/tests/test_indy_vdr.py +++ b/aries_cloudagent/ledger/tests/test_indy_vdr.py @@ -10,7 +10,7 @@ from ...indy.issuer import IndyIssuer from ...wallet.base import BaseWallet from ...wallet.key_type import KeyType -from ...wallet.did_method import DIDMethod +from ...wallet.did_method import SOV from ...wallet.did_info import DIDInfo from ..endpoint_type import EndpointType @@ -67,7 +67,7 @@ async def test_submit_signed( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(SOV, KeyType.ED25519) test_msg = indy_vdr.ledger.build_get_txn_request(test_did.did, 1, 1) async with ledger: @@ -120,7 +120,7 @@ async def test_submit_signed_taa_accept( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(SOV, KeyType.ED25519) async with ledger: test_msg = indy_vdr.ledger.build_get_txn_request(test_did.did, 1, 1) @@ -188,7 +188,7 @@ async def test_txn_endorse( with pytest.raises(BadLedgerRequestError): await ledger.txn_endorse(request_json=test_msg.body) - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(SOV, KeyType.ED25519) test_msg.set_endorser(test_did.did) endorsed_json = await ledger.txn_endorse(request_json=test_msg.body) @@ -201,7 +201,7 @@ async def test_send_schema( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(SOV, KeyType.ED25519) issuer = async_mock.MagicMock(IndyIssuer) issuer.create_schema.return_value = ( "schema_issuer_did:schema_name:9.1", @@ -262,7 +262,7 @@ async def test_send_schema_already_exists( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(SOV, KeyType.ED25519) issuer = async_mock.MagicMock(IndyIssuer) issuer.create_schema.return_value = ( "schema_issuer_did:schema_name:9.1", @@ -292,7 +292,7 @@ async def test_send_schema_ledger_read_only( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(SOV, KeyType.ED25519) issuer = async_mock.MagicMock(IndyIssuer) issuer.create_schema.return_value = ( "schema_issuer_did:schema_name:9.1", @@ -321,7 +321,7 @@ async def test_send_schema_ledger_transaction_error( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(SOV, KeyType.ED25519) issuer = async_mock.MagicMock(IndyIssuer) issuer.create_schema.return_value = ( "schema_issuer_did:schema_name:9.1", @@ -383,7 +383,7 @@ async def test_send_credential_definition( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(SOV, KeyType.ED25519) schema_id = "55GkHamhTU1ZbTbV2ab9DE:2:schema_name:9.1" cred_def_id = "55GkHamhTU1ZbTbV2ab9DE:3:CL:99:tag" cred_def = { @@ -598,7 +598,7 @@ async def test_update_endpoint_for_did( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(SOV, KeyType.ED25519) async with ledger: ledger.pool_handle.submit_request.side_effect = ( {"data": None}, @@ -675,7 +675,7 @@ async def test_construct_attr_json( async def test_update_endpoint_for_did_calls_attr_json(self, ledger: IndyVdrLedger): routing_keys = ["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"] wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(SOV, KeyType.ED25519) async with ledger: with async_mock.patch.object( @@ -742,8 +742,8 @@ async def test_register_nym_local( ledger: IndyVdrLedger, ): wallet: BaseWallet = (await ledger.profile.session()).wallet - public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) - post_did = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + public_did = await wallet.create_public_did(SOV, KeyType.ED25519) + post_did = await wallet.create_local_did(SOV, KeyType.ED25519) async with ledger: await ledger.register_nym(post_did.did, post_did.verkey) did = await wallet.get_local_did(post_did.did) @@ -755,7 +755,7 @@ async def test_register_nym_non_local( ledger: IndyVdrLedger, ): wallet: BaseWallet = (await ledger.profile.session()).wallet - public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + public_did = await wallet.create_public_did(SOV, KeyType.ED25519) async with ledger: await ledger.register_nym("55GkHamhTU1ZbTbV2ab9DE", "verkey") @@ -898,7 +898,7 @@ async def test_send_revoc_reg_def( ledger: IndyVdrLedger, ): wallet: BaseWallet = (await ledger.profile.session()).wallet - public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + public_did = await wallet.create_public_did(SOV, KeyType.ED25519) async with ledger: reg_id = ( "55GkHamhTU1ZbTbV2ab9DE:4:55GkHamhTU1ZbTbV2ab9DE:3:CL:99:tag:CL_ACCUM:0" @@ -927,7 +927,7 @@ async def test_send_revoc_reg_entry( ledger: IndyVdrLedger, ): wallet: BaseWallet = (await ledger.profile.session()).wallet - public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + public_did = await wallet.create_public_did(SOV, KeyType.ED25519) async with ledger: reg_id = ( "55GkHamhTU1ZbTbV2ab9DE:4:55GkHamhTU1ZbTbV2ab9DE:3:CL:99:tag:CL_ACCUM:0" @@ -966,7 +966,7 @@ async def test_credential_definition_id2schema_id(self, ledger: IndyVdrLedger): @pytest.mark.asyncio async def test_rotate_did_keypair(self, ledger: IndyVdrLedger): wallet = (await ledger.profile.session()).wallet - public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + public_did = await wallet.create_public_did(SOV, KeyType.ED25519) async with ledger: with async_mock.patch.object( diff --git a/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py b/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py index 2687c7bf19..7a74698212 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py +++ b/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py @@ -11,7 +11,7 @@ from ....wallet.indy import IndySdkWallet from ....wallet.util import b64_to_bytes, bytes_to_b64 from ....wallet.key_type import KeyType -from ....wallet.did_method import DIDMethod +from ....wallet.did_method import SOV from ..attach_decorator import ( AttachDecorator, @@ -434,7 +434,7 @@ class TestAttachDecoratorSignature: @pytest.mark.asyncio async def test_did_raw_key(self, wallet, seed): did_info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, seed[0] + SOV, KeyType.ED25519, seed[0] ) did_key0 = did_key(did_info.verkey) raw_key0 = raw_key(did_key0) @@ -457,7 +457,7 @@ async def test_indy_sign(self, wallet, seed): ) deco_indy_master = deepcopy(deco_indy) did_info = [ - await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519, seed[i]) + await wallet.create_local_did(SOV, KeyType.ED25519, seed[i]) for i in [0, 1] ] assert deco_indy.data.signatures == 0 diff --git a/aries_cloudagent/messaging/jsonld/tests/test_routes.py b/aries_cloudagent/messaging/jsonld/tests/test_routes.py index 129ac26515..7c20c07861 100644 --- a/aries_cloudagent/messaging/jsonld/tests/test_routes.py +++ b/aries_cloudagent/messaging/jsonld/tests/test_routes.py @@ -14,7 +14,7 @@ from ....resolver.did_resolver import DIDResolver from ....vc.ld_proofs.document_loader import DocumentLoader from ....wallet.base import BaseWallet -from ....wallet.did_method import DIDMethod +from ....wallet.did_method import SOV from ....wallet.error import WalletError from ....wallet.key_type import KeyType from ..error import ( @@ -275,7 +275,7 @@ async def setUp(self): DocumentLoader, custom_document_loader ) self.did_info = await (await self.context.session()).wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519 + SOV, KeyType.ED25519 ) self.request_dict = { "context": self.context, diff --git a/aries_cloudagent/multitenant/tests/test_base.py b/aries_cloudagent/multitenant/tests/test_base.py index 6f7c7b7e78..d8c50b0c88 100644 --- a/aries_cloudagent/multitenant/tests/test_base.py +++ b/aries_cloudagent/multitenant/tests/test_base.py @@ -18,7 +18,7 @@ from ...storage.error import StorageNotFoundError from ...storage.in_memory import InMemoryStorage from ...wallet.did_info import DIDInfo -from ...wallet.did_method import DIDMethod +from ...wallet.did_method import SOV from ...wallet.in_memory import InMemoryWallet from ...wallet.key_type import KeyType from ...wallet.models.wallet_record import WalletRecord @@ -244,7 +244,7 @@ async def test_create_wallet_adds_wallet_route(self): did="public-did", verkey="test_verkey", metadata={"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) diff --git a/aries_cloudagent/protocols/connections/v1_0/manager.py b/aries_cloudagent/protocols/connections/v1_0/manager.py index d937b7ecb2..9bf066140d 100644 --- a/aries_cloudagent/protocols/connections/v1_0/manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/manager.py @@ -19,7 +19,7 @@ from ....wallet.base import BaseWallet from ....wallet.crypto import create_keypair, seed_to_did from ....wallet.did_info import DIDInfo -from ....wallet.did_method import DIDMethod +from ....wallet.did_method import SOV from ....wallet.error import WalletNotFoundError from ....wallet.key_type import KeyType from ....wallet.util import bytes_to_b58 @@ -360,7 +360,7 @@ async def create_request( async with self.profile.session() as session: wallet = session.inject(BaseWallet) # Create new DID for connection - my_info = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + my_info = await wallet.create_local_did(SOV, KeyType.ED25519) connection.my_did = my_info.did # Idempotent; if routing has already been set up, no action taken @@ -468,7 +468,7 @@ async def receive_request( async with self.profile.session() as session: wallet = session.inject(BaseWallet) my_info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519 + SOV, KeyType.ED25519 ) new_connection = ConnRecord( @@ -522,7 +522,7 @@ async def receive_request( else: # request from public did async with self.profile.session() as session: wallet = session.inject(BaseWallet) - my_info = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + my_info = await wallet.create_local_did(SOV, KeyType.ED25519) async with self.profile.session() as session: connection = await ConnRecord.retrieve_by_invitation_msg_id( @@ -613,7 +613,7 @@ async def create_response( else: async with self.profile.session() as session: wallet = session.inject(BaseWallet) - my_info = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + my_info = await wallet.create_local_did(SOV, KeyType.ED25519) connection.my_did = my_info.did # Idempotent; if routing has already been set up, no action taken @@ -831,7 +831,7 @@ async def create_static_connection( wallet = session.inject(BaseWallet) # seed and DID optional my_info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, my_seed, my_did + SOV, KeyType.ED25519, my_seed, my_did ) # must provide their DID and verkey if the seed is not known @@ -845,7 +845,7 @@ async def create_static_connection( their_verkey_bin, _ = create_keypair(KeyType.ED25519, their_seed.encode()) their_verkey = bytes_to_b58(their_verkey_bin) their_info = DIDInfo( - their_did, their_verkey, {}, method=DIDMethod.SOV, key_type=KeyType.ED25519 + their_did, their_verkey, {}, method=SOV, key_type=KeyType.ED25519 ) # Create connection record @@ -1106,7 +1106,7 @@ async def establish_inbound( my_info = await wallet.get_local_did(connection.my_did) else: # Create new DID for connection - my_info = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + my_info = await wallet.create_local_did(SOV, KeyType.ED25519) connection.my_did = my_info.did try: diff --git a/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py index 80efb456bf..4dfcd1f997 100644 --- a/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py @@ -23,7 +23,7 @@ from .....storage.error import StorageNotFoundError from .....transport.inbound.receipt import MessageReceipt from .....wallet.base import DIDInfo -from .....wallet.did_method import DIDMethod +from .....wallet.did_method import SOV from .....wallet.error import WalletNotFoundError from .....wallet.in_memory import InMemoryWallet from .....wallet.key_type import KeyType @@ -120,7 +120,7 @@ async def test_create_invitation_public_and_multi_use_fails(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) with self.assertRaises(ConnectionManagerError): @@ -166,7 +166,7 @@ async def test_create_invitation_public(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) connect_record, connect_invite = await self.manager.create_invitation( @@ -231,7 +231,7 @@ async def test_create_invitation_multi_use(self): async def test_create_invitation_recipient_routing_endpoint(self): async with self.profile.session() as session: await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -274,7 +274,7 @@ async def test_create_invitation_public_and_metadata_fails(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) with self.assertRaises(ConnectionManagerError): @@ -435,7 +435,7 @@ async def test_create_request_my_endpoint(self): async def test_create_request_my_did(self): async with self.profile.session() as session: await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=self.test_did, @@ -480,7 +480,7 @@ async def test_create_request_multitenant(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) await self.manager.create_request( @@ -533,7 +533,7 @@ async def test_create_request_mediation_id(self): did=self.test_did, verkey=self.test_verkey, metadata={}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) create_local_did.return_value = did_info @@ -542,7 +542,7 @@ async def test_create_request_mediation_id(self): mediation_id=mediation_record.mediation_id, my_endpoint=self.test_endpoint, ) - create_local_did.assert_called_once_with(DIDMethod.SOV, KeyType.ED25519) + create_local_did.assert_called_once_with(SOV, KeyType.ED25519) create_did_document.assert_called_once_with( self.manager, did_info, @@ -585,7 +585,7 @@ async def test_create_request_default_mediator(self): did=self.test_did, verkey=self.test_verkey, metadata={}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) create_local_did.return_value = did_info @@ -593,7 +593,7 @@ async def test_create_request_default_mediator(self): record, my_endpoint=self.test_endpoint, ) - create_local_did.assert_called_once_with(DIDMethod.SOV, KeyType.ED25519) + create_local_did.assert_called_once_with(SOV, KeyType.ED25519) create_did_document.assert_called_once_with( self.manager, did_info, @@ -614,7 +614,7 @@ async def test_receive_request_public_did_oob_invite(self): recipient_did=self.test_did, recipient_did_public=True ) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=self.test_did, @@ -654,7 +654,7 @@ async def test_receive_request_public_did_conn_invite(self): recipient_did=self.test_did, recipient_did_public=True ) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=self.test_did, @@ -689,7 +689,7 @@ async def test_receive_request_public_did_no_did_doc(self): recipient_did=self.test_did, recipient_did_public=True ) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=self.test_did, @@ -720,7 +720,7 @@ async def test_receive_request_public_did_wrong_did(self): recipient_did=self.test_did, recipient_did_public=True ) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=self.test_did, @@ -749,7 +749,7 @@ async def test_receive_request_public_did_no_public_invites(self): receipt = MessageReceipt(recipient_did=self.test_did, recipient_did_public=True) async with self.profile.session() as session: await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=self.test_did, @@ -780,7 +780,7 @@ async def test_receive_request_public_did_no_auto_accept(self): recipient_did=self.test_did, recipient_did_public=True ) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=self.test_did, @@ -867,7 +867,7 @@ async def test_create_response_multitenant(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) await self.manager.create_response( @@ -941,7 +941,7 @@ async def test_create_response_mediation(self): did=self.test_did, verkey=self.test_verkey, metadata={}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) create_local_did.return_value = did_info @@ -950,7 +950,7 @@ async def test_create_response_mediation(self): mediation_id=mediation_record.mediation_id, my_endpoint=self.test_endpoint, ) - create_local_did.assert_called_once_with(DIDMethod.SOV, KeyType.ED25519) + create_local_did.assert_called_once_with(SOV, KeyType.ED25519) create_did_document.assert_called_once_with( self.manager, did_info, @@ -1266,7 +1266,7 @@ async def test_create_static_connection_multitenant(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1299,7 +1299,7 @@ async def test_create_static_connection_multitenant_auto_disclose_features(self) self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) await self.manager.create_static_connection( @@ -1331,7 +1331,7 @@ async def test_create_static_connection_multitenant_mediator(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1359,7 +1359,7 @@ async def test_create_static_connection_multitenant_mediator(self): self.test_target_did, self.test_target_verkey, {}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) create_did_document.assert_has_calls( @@ -1537,7 +1537,7 @@ async def test_resolve_inbound_connection(self): self.test_did, self.test_verkey, {"posted": True}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mock_mgr_find_conn.return_value = mock_conn @@ -1589,7 +1589,7 @@ async def test_create_did_document(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1622,7 +1622,7 @@ async def test_create_did_document_not_active(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1650,7 +1650,7 @@ async def test_create_did_document_no_services(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1685,7 +1685,7 @@ async def test_create_did_document_no_service_endpoint(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1723,7 +1723,7 @@ async def test_create_did_document_no_service_recip_keys(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1769,7 +1769,7 @@ async def test_create_did_document_mediation(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mediation_record = MediationRecord( @@ -1795,7 +1795,7 @@ async def test_create_did_document_multiple_mediators(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mediation_record1 = MediationRecord( @@ -1828,7 +1828,7 @@ async def test_create_did_document_mediation_svc_endpoints_overwritten(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mediation_record = MediationRecord( @@ -1863,7 +1863,7 @@ async def test_did_key_storage(self): async def test_get_connection_targets_conn_invitation_no_did(self): async with self.profile.session() as session: local_did = await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -1922,7 +1922,7 @@ async def test_get_connection_targets_conn_invitation_no_did(self): async def test_get_connection_targets_retrieve_connection(self): async with self.profile.session() as session: local_did = await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -1975,7 +1975,7 @@ async def test_get_conn_targets_conn_invitation_no_cache(self): async with self.profile.session() as session: self.context.injector.clear_binding(BaseCache) local_did = await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -2025,7 +2025,7 @@ async def test_fetch_connection_targets_conn_invitation_did_no_resolver(self): async with self.profile.session() as session: self.context.injector.bind_instance(DIDResolver, DIDResolver([])) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -2071,7 +2071,7 @@ async def test_fetch_connection_targets_conn_invitation_did_resolver(self): self.context.injector.bind_instance(DIDResolver, self.resolver) local_did = await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -2139,7 +2139,7 @@ async def test_fetch_connection_targets_conn_invitation_btcr_resolver(self): self.resolver.resolve = async_mock.CoroutineMock(return_value=did_doc) self.context.injector.bind_instance(DIDResolver, self.resolver) local_did = await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=did_doc.id, @@ -2204,7 +2204,7 @@ async def test_fetch_connection_targets_conn_invitation_btcr_without_services(se self.context.injector.bind_instance(DIDResolver, self.resolver) local_did = await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=did_doc.id, @@ -2244,7 +2244,7 @@ async def test_fetch_connection_targets_conn_invitation_no_didcomm_services(self self.resolver.resolve = async_mock.CoroutineMock(return_value=did_doc) self.context.injector.bind_instance(DIDResolver, self.resolver) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=did_doc.id, @@ -2290,7 +2290,7 @@ async def test_fetch_connection_targets_conn_invitation_unsupported_key_type(sel self.resolver.resolve = async_mock.CoroutineMock(return_value=did_doc) self.context.injector.bind_instance(DIDResolver, self.resolver) local_did = await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=did_doc.id, @@ -2319,7 +2319,7 @@ async def test_fetch_connection_targets_oob_invitation_svc_did_no_resolver(self) async with self.profile.session() as session: self.context.injector.bind_instance(DIDResolver, DIDResolver([])) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -2360,7 +2360,7 @@ async def test_fetch_connection_targets_oob_invitation_svc_did_resolver(self): self.context.injector.bind_instance(DIDResolver, self.resolver) local_did = await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -2405,7 +2405,7 @@ async def test_fetch_connection_targets_oob_invitation_svc_block_resolver(self): self.context.injector.bind_instance(DIDResolver, self.resolver) local_did = await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -2451,7 +2451,7 @@ async def test_fetch_connection_targets_oob_invitation_svc_block_resolver(self): async def test_fetch_connection_targets_conn_initiator_completed_no_their_did(self): async with self.profile.session() as session: await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -2468,7 +2468,7 @@ async def test_fetch_connection_targets_conn_initiator_completed_no_their_did(se async def test_fetch_connection_targets_conn_completed_their_did(self): async with self.profile.session() as session: local_did = await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -2499,7 +2499,7 @@ async def test_fetch_connection_targets_conn_completed_their_did(self): async def test_fetch_connection_targets_conn_no_invi_with_their_did(self): async with self.profile.session() as session: local_did = await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -2554,7 +2554,7 @@ async def test_diddoc_connection_targets_diddoc_underspecified(self): async def test_establish_inbound(self): async with self.profile.session() as session: await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -2584,7 +2584,7 @@ async def test_establish_inbound(self): async def test_establish_inbound_conn_rec_no_my_did(self): async with self.profile.session() as session: await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -2613,7 +2613,7 @@ async def test_establish_inbound_conn_rec_no_my_did(self): async def test_establish_inbound_no_conn_record(self): async with self.profile.session() as session: await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, @@ -2642,7 +2642,7 @@ async def test_establish_inbound_no_conn_record(self): async def test_establish_inbound_router_not_ready(self): async with self.profile.session() as session: await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed, did=self.test_did, diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py index f525dd0088..561f57a6c8 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py @@ -11,7 +11,7 @@ from ....storage.record import StorageRecord from ....wallet.base import BaseWallet from ....wallet.did_info import DIDInfo -from ....wallet.did_method import DIDMethod +from ....wallet.did_method import SOV from ....wallet.key_type import KeyType from ...routing.v1_0.manager import RoutingManager from ...routing.v1_0.models.route_record import RouteRecord @@ -111,7 +111,7 @@ async def _create_routing_did(self, session: ProfileSession) -> DIDInfo: wallet = session.inject(BaseWallet) storage = session.inject(BaseStorage) info = await wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, metadata={"type": "routing_did"}, ) diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/route_manager.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/route_manager.py index 07da03fd51..473d7296bb 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/route_manager.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/route_manager.py @@ -14,7 +14,7 @@ from ....storage.error import StorageNotFoundError from ....wallet.base import BaseWallet from ....wallet.did_info import DIDInfo -from ....wallet.did_method import DIDMethod +from ....wallet.did_method import SOV from ....wallet.key_type import KeyType from ...routing.v1_0.models.route_record import RouteRecord from .manager import MediationManager @@ -40,7 +40,7 @@ async def get_or_create_my_did( async with profile.session() as session: wallet = session.inject(BaseWallet) # Create new DID for connection - my_info = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + my_info = await wallet.create_local_did(SOV, KeyType.ED25519) conn_record.my_did = my_info.did await conn_record.save(session, reason="Connection my did created") else: diff --git a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py index ff76d6a9c6..9f6f4a204c 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py @@ -10,7 +10,7 @@ ) from ......core.in_memory import InMemoryProfile from ......wallet.key_type import KeyType -from ......wallet.did_method import DIDMethod +from ......wallet.did_method import SOV from ......messaging.decorators.attach_decorator import AttachDecorator from ......messaging.request_context import RequestContext from ......messaging.responder import MockResponder @@ -88,7 +88,7 @@ async def setUp(self): wallet = self.session.wallet self.did_info = await wallet.create_local_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519 + method=SOV, key_type=KeyType.ED25519 ) self.did_doc_attach = AttachDecorator.data_base64(self.did_doc().serialize()) diff --git a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_response_handler.py b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_response_handler.py index a161b5f325..d5cc3d23dc 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_response_handler.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_response_handler.py @@ -14,7 +14,7 @@ from ......messaging.responder import MockResponder from ......transport.inbound.receipt import MessageReceipt from ......wallet.key_type import KeyType -from ......wallet.did_method import DIDMethod +from ......wallet.did_method import SOV from .....problem_report.v1_0.message import ProblemReport from .....trustping.v1_0.messages.ping import Ping @@ -65,7 +65,7 @@ async def setUp(self): wallet = (await self.ctx.session()).wallet self.did_info = await wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) diff --git a/aries_cloudagent/protocols/didexchange/v1_0/manager.py b/aries_cloudagent/protocols/didexchange/v1_0/manager.py index 587e6b56b5..5edce76ac2 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/manager.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/manager.py @@ -23,7 +23,7 @@ from ....storage.error import StorageNotFoundError from ....transport.inbound.receipt import MessageReceipt from ....wallet.base import BaseWallet -from ....wallet.did_method import DIDMethod +from ....wallet.did_method import SOV from ....wallet.did_posture import DIDPosture from ....wallet.error import WalletError from ....wallet.key_type import KeyType @@ -284,7 +284,7 @@ async def create_request( async with self.profile.session() as session: wallet = session.inject(BaseWallet) my_info = await wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) conn_rec.my_did = my_info.did @@ -417,7 +417,7 @@ async def receive_request( async with self.profile.session() as session: wallet = session.inject(BaseWallet) my_info = await wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -486,7 +486,7 @@ async def receive_request( async with self.profile.session() as session: wallet = session.inject(BaseWallet) my_info = await wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -580,7 +580,7 @@ async def create_response( async with self.profile.session() as session: wallet = session.inject(BaseWallet) my_info = await wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) conn_rec.my_did = my_info.did diff --git a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py index a7ad4f405f..392201abea 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py @@ -8,7 +8,7 @@ PublicKeyType, Service, ) -from ......wallet.did_method import DIDMethod +from ......wallet.did_method import SOV from ......wallet.key_type import KeyType from ......core.in_memory import InMemoryProfile from ......messaging.decorators.attach_decorator import AttachDecorator @@ -59,7 +59,7 @@ class TestDIDXRequest(AsyncTestCase, TestConfig): async def setUp(self): self.wallet = InMemoryProfile.test_session().wallet self.did_info = await self.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -116,7 +116,7 @@ class TestDIDXRequestSchema(AsyncTestCase, TestConfig): async def setUp(self): self.wallet = InMemoryProfile.test_session().wallet self.did_info = await self.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) diff --git a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py index 9cf32b8359..1a47bdb45f 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py @@ -8,7 +8,7 @@ PublicKeyType, Service, ) -from ......wallet.did_method import DIDMethod +from ......wallet.did_method import SOV from ......wallet.key_type import KeyType from ......core.in_memory import InMemoryProfile from ......messaging.decorators.attach_decorator import AttachDecorator @@ -58,7 +58,7 @@ class TestDIDXResponse(AsyncTestCase, TestConfig): async def setUp(self): self.wallet = InMemoryProfile.test_session().wallet self.did_info = await self.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -112,7 +112,7 @@ class TestDIDXResponseSchema(AsyncTestCase, TestConfig): async def setUp(self): self.wallet = InMemoryProfile.test_session().wallet self.did_info = await self.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) diff --git a/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py index 131d87670e..e19711c2b8 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py @@ -28,7 +28,7 @@ from .....wallet.did_info import DIDInfo from .....wallet.error import WalletError from .....wallet.in_memory import InMemoryWallet -from .....wallet.did_method import DIDMethod +from .....wallet.did_method import SOV from .....wallet.key_type import KeyType from .....did.did_key import DIDKey @@ -114,7 +114,7 @@ async def setUp(self): self.context = self.profile.context async with self.profile.session() as session: self.did_info = await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -202,7 +202,7 @@ async def test_receive_invitation_oob_public_did(self): self.profile.context.update_settings({"public_invites": True}) public_did_info = None await session.wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) public_did_info = await session.wallet.get_public_did() @@ -303,7 +303,7 @@ async def test_create_request_implicit(self): async def test_create_request_implicit_use_public_did(self): async with self.profile.session() as session: info_public = await session.wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) conn_rec = await self.manager.create_request_implicit( @@ -374,7 +374,7 @@ async def test_create_request_multitenant(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mock_attach_deco.data_base64 = async_mock.MagicMock( @@ -502,7 +502,7 @@ async def test_receive_request_explicit_public_did(self): await mediation_record.save(session) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=TestConfig.test_did, @@ -601,7 +601,7 @@ async def test_receive_request_invi_not_found(self): ) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=TestConfig.test_did, @@ -633,7 +633,7 @@ async def test_receive_request_public_did_no_did_doc_attachment(self): ) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=TestConfig.test_did, @@ -693,7 +693,7 @@ async def test_receive_request_public_did_x_not_public(self): ) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=TestConfig.test_did, @@ -735,7 +735,7 @@ async def test_receive_request_public_did_x_wrong_did(self): ) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=TestConfig.test_did, @@ -802,7 +802,7 @@ async def test_receive_request_public_did_x_did_doc_attach_bad_sig(self): ) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=TestConfig.test_did, @@ -863,7 +863,7 @@ async def test_receive_request_public_did_no_public_invites(self): ) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=TestConfig.test_did, @@ -910,7 +910,7 @@ async def test_receive_request_public_did_no_auto_accept(self): ) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=TestConfig.test_did, @@ -1003,7 +1003,7 @@ async def test_receive_request_peer_did(self): mock_conn_rec_state_request = ConnRecord.State.REQUEST await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=TestConfig.test_did, @@ -1077,7 +1077,7 @@ async def test_receive_request_peer_did_not_found_x(self): ) await session.wallet.create_local_did( - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, seed=None, did=TestConfig.test_did, @@ -1253,7 +1253,7 @@ async def test_create_response_multitenant(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mock_create_did_doc.return_value = async_mock.MagicMock( @@ -1670,7 +1670,7 @@ async def test_create_did_document(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1704,7 +1704,7 @@ async def test_create_did_document_not_completed(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1732,7 +1732,7 @@ async def test_create_did_document_no_services(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1767,7 +1767,7 @@ async def test_create_did_document_no_service_endpoint(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1805,7 +1805,7 @@ async def test_create_did_document_no_service_recip_keys(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1851,7 +1851,7 @@ async def test_did_key_storage(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) @@ -1897,7 +1897,7 @@ async def test_resolve_did_document_error(self): public_did_info = None async with self.profile.session() as session: await session.wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) public_did_info = await session.wallet.get_public_did() diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py index edad031889..1264bb2271 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py @@ -16,7 +16,7 @@ from .....storage.error import StorageNotFoundError from .....wallet.base import BaseWallet from .....wallet.did_info import DIDInfo -from .....wallet.did_method import DIDMethod +from .....wallet.did_method import SOV from .....wallet.key_type import KeyType from ..manager import TransactionManager, TransactionManagerError @@ -124,7 +124,7 @@ async def setUp(self): async with self.profile.session() as session: self.wallet: BaseWallet = session.inject_or(BaseWallet) await self.wallet.create_local_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, did="DJGEjaMunDtFtBVrn1qJMT", metadata={"meta": "data"}, diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py index d91b1ff8b8..9aeb3481e7 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py @@ -9,7 +9,7 @@ from .....ledger.base import BaseLedger from .....wallet.base import BaseWallet from .....wallet.did_info import DIDInfo -from .....wallet.did_method import DIDMethod +from .....wallet.did_method import SOV from .....wallet.key_type import KeyType from ..models.transaction_record import TransactionRecord @@ -436,7 +436,7 @@ async def test_endorse_transaction_response(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) @@ -515,7 +515,7 @@ async def test_endorse_transaction_response_not_found_x(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) @@ -544,7 +544,7 @@ async def test_endorse_transaction_response_base_model_x(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) @@ -579,7 +579,7 @@ async def test_endorse_transaction_response_no_jobs_x(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) @@ -616,7 +616,7 @@ async def skip_test_endorse_transaction_response_no_ledger_x(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) @@ -671,7 +671,7 @@ async def test_endorse_transaction_response_wrong_my_job_x(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) @@ -714,7 +714,7 @@ async def skip_test_endorse_transaction_response_ledger_x(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) @@ -772,7 +772,7 @@ async def test_endorse_transaction_response_txn_mgr_x(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) @@ -824,7 +824,7 @@ async def test_refuse_transaction_response(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) @@ -882,7 +882,7 @@ async def test_refuse_transaction_response_not_found_x(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) @@ -912,7 +912,7 @@ async def test_refuse_transaction_response_conn_base_model_x(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) @@ -947,7 +947,7 @@ async def test_refuse_transaction_response_no_jobs_x(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) @@ -984,7 +984,7 @@ async def test_refuse_transaction_response_wrong_my_job_x(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) @@ -1027,7 +1027,7 @@ async def test_refuse_transaction_response_txn_mgr_x(self): "did", "verkey", {"meta": "data"}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) ) diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py index c4666a679e..690ae592e9 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py @@ -28,7 +28,7 @@ from .......vc.tests.document_loader import custom_document_loader from .......wallet.key_type import KeyType from .......wallet.error import WalletNotFoundError -from .......wallet.did_method import DIDMethod +from .......wallet.did_method import SOV from .......wallet.base import BaseWallet from ....models.detail.ld_proof import V20CredExRecordLDProof @@ -217,7 +217,7 @@ async def test_assert_can_issue_with_id_and_proof_type(self): did=TEST_DID_SOV, verkey="verkey", metadata={}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mock_did_info.return_value = did_info @@ -229,7 +229,7 @@ async def test_assert_can_issue_with_id_and_proof_type(self): did=TEST_DID_SOV, verkey="verkey", metadata={}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.BLS12381G2, ) mock_did_info.return_value = invalid_did_info diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py index 738e295a1f..9197d00447 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py @@ -65,7 +65,7 @@ from .....storage.error import StorageNotFoundError from .....transport.inbound.receipt import MessageReceipt from .....wallet.did_info import DIDInfo, KeyInfo -from .....wallet.did_method import DIDMethod +from .....wallet.did_method import SOV from .....wallet.in_memory import InMemoryWallet from .....wallet.key_type import KeyType from ....connections.v1_0.messages.connection_invitation import ConnectionInvitation @@ -378,7 +378,7 @@ async def test_create_invitation_handshake_succeeds(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) invi_rec = await self.manager.create_invitation( @@ -438,7 +438,7 @@ async def test_create_invitation_multitenant_public(self): self.test_did, self.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) await self.manager.create_invitation( @@ -513,7 +513,7 @@ async def test_create_invitation_attachment_v1_0_cred_offer(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mock_retrieve_cxid.return_value = async_mock.MagicMock( @@ -547,7 +547,7 @@ async def test_create_invitation_attachment_v1_0_cred_offer_no_handshake(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mock_retrieve_cxid.return_value = async_mock.MagicMock( @@ -585,7 +585,7 @@ async def test_create_invitation_attachment_v2_0_cred_offer(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mock_retrieve_cxid_v1.side_effect = test_module.StorageNotFoundError() @@ -623,7 +623,7 @@ async def test_create_invitation_attachment_present_proof_v1_0(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mock_retrieve_pxid.return_value = async_mock.MagicMock( @@ -662,7 +662,7 @@ async def test_create_invitation_attachment_present_proof_v2_0(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mock_retrieve_pxid_1.side_effect = StorageNotFoundError() @@ -750,7 +750,7 @@ async def test_create_invitation_attachment_x(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) with self.assertRaises(OutOfBandManagerError) as context: @@ -834,7 +834,7 @@ async def test_create_invitation_x_public_metadata(self): TestConfig.test_did, TestConfig.test_verkey, None, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) with self.assertRaises(OutOfBandManagerError) as context: diff --git a/aries_cloudagent/protocols/present_proof/dif/tests/test_pres_exch_handler.py b/aries_cloudagent/protocols/present_proof/dif/tests/test_pres_exch_handler.py index 87587eb674..8443f1a048 100644 --- a/aries_cloudagent/protocols/present_proof/dif/tests/test_pres_exch_handler.py +++ b/aries_cloudagent/protocols/present_proof/dif/tests/test_pres_exch_handler.py @@ -12,7 +12,7 @@ from .....storage.vc_holder.vc_record import VCRecord from .....wallet.base import BaseWallet, DIDInfo from .....wallet.crypto import KeyType -from .....wallet.did_method import DIDMethod +from .....wallet.did_method import SOV, KEY from .....wallet.error import WalletNotFoundError from .....vc.ld_proofs import ( BbsBlsSignature2020, @@ -79,10 +79,10 @@ async def setup_tuple(profile): async with profile.session() as session: wallet = session.inject_or(BaseWallet) await wallet.create_local_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519, did="WgWxqztrNooG92RXvxSTWv" + method=SOV, key_type=KeyType.ED25519, did="WgWxqztrNooG92RXvxSTWv" ) await wallet.create_local_did( - method=DIDMethod.KEY, + method=KEY, key_type=KeyType.BLS12381G2, ) creds, pds = get_test_data() @@ -2031,7 +2031,7 @@ async def test_get_sign_key_credential_subject_id(self, profile): did="did:sov:LjgpST2rjsoxYegQDRm7EL", verkey="verkey", metadata={}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mock_did_info.return_value = did_info @@ -2096,7 +2096,7 @@ async def test_get_sign_key_credential_subject_id_error(self, profile): did="did:sov:LjgpST2rjsoxYegQDRm7EL", verkey="verkey", metadata={}, - method=DIDMethod.SOV, + method=SOV, key_type=KeyType.ED25519, ) mock_did_info.return_value = did_info @@ -2164,7 +2164,7 @@ async def test_get_sign_key_credential_subject_id_bbsbls(self, profile): did="did:key:z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL", verkey="verkey", metadata={}, - method=DIDMethod.KEY, + method=KEY, key_type=KeyType.BLS12381G2, ) mock_did_info.return_value = did_info @@ -2255,7 +2255,7 @@ async def test_create_vp_no_issuer(self, profile, setup_tuple): did="did:key:z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL", verkey="verkey", metadata={}, - method=DIDMethod.KEY, + method=KEY, key_type=KeyType.BLS12381G2, ) mock_did_info.return_value = did_info @@ -2315,7 +2315,7 @@ async def test_create_vp_with_bbs_suite(self, profile, setup_tuple): did="did:key:z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL", verkey="verkey", metadata={}, - method=DIDMethod.KEY, + method=KEY, key_type=KeyType.BLS12381G2, ) mock_did_info.return_value = did_info @@ -2369,7 +2369,7 @@ async def test_create_vp_no_issuer_with_bbs_suite(self, profile, setup_tuple): did="did:key:z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL", verkey="verkey", metadata={}, - method=DIDMethod.KEY, + method=KEY, key_type=KeyType.BLS12381G2, ) mock_did_info.return_value = did_info diff --git a/aries_cloudagent/transport/tests/test_pack_format.py b/aries_cloudagent/transport/tests/test_pack_format.py index 1ca7b7f46f..c2c9bafcf1 100644 --- a/aries_cloudagent/transport/tests/test_pack_format.py +++ b/aries_cloudagent/transport/tests/test_pack_format.py @@ -10,7 +10,7 @@ from ...wallet.base import BaseWallet from ...wallet.error import WalletError from ...wallet.key_type import KeyType -from ...wallet.did_method import DIDMethod +from ...wallet.did_method import SOV from .. import pack_format as test_module from ..error import WireFormatEncodeError, WireFormatParseError, RecipientKeysError @@ -140,7 +140,7 @@ async def test_fallback(self): async def test_encode_decode(self): local_did = await self.wallet.create_local_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=self.test_seed + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed ) serializer = PackWireFormat() recipient_keys = (local_did.verkey,) @@ -174,10 +174,10 @@ async def test_encode_decode(self): async def test_forward(self): local_did = await self.wallet.create_local_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=self.test_seed + method=SOV, key_type=KeyType.ED25519, seed=self.test_seed ) router_did = await self.wallet.create_local_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=self.test_routing_seed + method=SOV, key_type=KeyType.ED25519, seed=self.test_routing_seed ) serializer = PackWireFormat() recipient_keys = (local_did.verkey,) diff --git a/aries_cloudagent/utils/tests/test_outofband.py b/aries_cloudagent/utils/tests/test_outofband.py index 2029553471..3f7ec57210 100644 --- a/aries_cloudagent/utils/tests/test_outofband.py +++ b/aries_cloudagent/utils/tests/test_outofband.py @@ -2,7 +2,7 @@ from ...protocols.out_of_band.v1_0.messages.invitation import InvitationMessage from ...wallet.key_type import KeyType -from ...wallet.did_method import DIDMethod +from ...wallet.did_method import SOV from ...wallet.did_info import DIDInfo from .. import outofband as test_module @@ -12,7 +12,7 @@ class TestOutOfBand(TestCase): test_did = "55GkHamhTU1ZbTbV2ab9DE" test_verkey = "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx" test_did_info = DIDInfo( - test_did, test_verkey, None, method=DIDMethod.SOV, key_type=KeyType.ED25519 + test_did, test_verkey, None, method=SOV, key_type=KeyType.ED25519 ) def test_serialize_oob(self): diff --git a/aries_cloudagent/wallet/askar.py b/aries_cloudagent/wallet/askar.py index f2a5c790c6..66ec452ff4 100644 --- a/aries_cloudagent/wallet/askar.py +++ b/aries_cloudagent/wallet/askar.py @@ -31,7 +31,7 @@ validate_seed, verify_signed_message, ) -from .did_method import DIDMethod +from .did_method import SOV, KEY, DIDMethod from .error import WalletError, WalletDuplicateError, WalletNotFoundError from .key_type import KeyType from .util import b58_to_bytes, bytes_to_b58 @@ -180,12 +180,12 @@ async def create_local_did( f" for DID method {method.method_name}" ) - if method == DIDMethod.KEY and did: + if method == KEY and did: raise WalletError("Not allowed to set DID for DID method 'key'") if not metadata: metadata = {} - if method not in [DIDMethod.SOV, DIDMethod.KEY]: + if method not in [SOV, KEY]: raise WalletError( f"Unsupported DID method for askar storage: {method.method_name}" ) @@ -206,7 +206,7 @@ async def create_local_did( else: raise WalletError("Error inserting key") from err - if method == DIDMethod.KEY: + if method == KEY: did = DIDKey.from_public_key(verkey_bytes, key_type).did elif not did: did = bytes_to_b58(verkey_bytes[:16]) @@ -408,7 +408,7 @@ async def set_public_did(self, did: Union[str, DIDInfo]) -> DIDInfo: info = did item = None - if info.method != DIDMethod.SOV: + if info.method != SOV: raise WalletError("Setting public DID is only allowed for did:sov DIDs") public = await self.get_public_did() @@ -462,7 +462,7 @@ async def set_did_endpoint( 'endpoint' affects local wallet """ did_info = await self.get_local_did(did) - if did_info.method != DIDMethod.SOV: + if did_info.method != SOV: raise WalletError("Setting DID endpoint is only allowed for did:sov DIDs") metadata = {**did_info.metadata} if not endpoint_type: diff --git a/aries_cloudagent/wallet/base.py b/aries_cloudagent/wallet/base.py index bbb1288061..46bbc3eab9 100644 --- a/aries_cloudagent/wallet/base.py +++ b/aries_cloudagent/wallet/base.py @@ -9,7 +9,7 @@ from .did_info import DIDInfo, KeyInfo from .key_type import KeyType -from .did_method import DIDMethod +from .did_method import SOV, DIDMethod class BaseWallet(ABC): @@ -241,7 +241,7 @@ async def set_did_endpoint( """ did_info = await self.get_local_did(did) - if did_info.method != DIDMethod.SOV: + if did_info.method != SOV: raise WalletError("Setting DID endpoint is only allowed for did:sov DIDs") metadata = {**did_info.metadata} if not endpoint_type: diff --git a/aries_cloudagent/wallet/in_memory.py b/aries_cloudagent/wallet/in_memory.py index f005ef1d21..adc3e7ba92 100644 --- a/aries_cloudagent/wallet/in_memory.py +++ b/aries_cloudagent/wallet/in_memory.py @@ -17,7 +17,7 @@ ) from .did_info import KeyInfo, DIDInfo from .did_posture import DIDPosture -from .did_method import DIDMethod +from .did_method import SOV, KEY, DIDMethod from .error import WalletError, WalletDuplicateError, WalletNotFoundError from .key_type import KeyType from .util import b58_to_bytes, bytes_to_b58, random_seed @@ -223,12 +223,12 @@ async def create_local_did( # We need some did method specific handling. If more did methods # are added it is probably better create a did method specific handler - if method == DIDMethod.KEY: + if method == KEY: if did: raise WalletError("Not allowed to set DID for DID method 'key'") did = DIDKey.from_public_key(verkey, key_type).did - elif method == DIDMethod.SOV: + elif method == SOV: if not did: did = bytes_to_b58(verkey[:16]) else: @@ -395,7 +395,7 @@ async def set_public_did(self, did: Union[str, DIDInfo]) -> DIDInfo: info = did did = info.did - if info.method != DIDMethod.SOV: + if info.method != SOV: raise WalletError("Setting public DID is only allowed for did:sov DIDs") public = await self.get_public_did() diff --git a/aries_cloudagent/wallet/indy.py b/aries_cloudagent/wallet/indy.py index 4e2406d04f..78ebfc0408 100644 --- a/aries_cloudagent/wallet/indy.py +++ b/aries_cloudagent/wallet/indy.py @@ -30,7 +30,7 @@ verify_signed_message, ) from .did_info import DIDInfo, KeyInfo -from .did_method import DIDMethod +from .did_method import SOV, KEY, DIDMethod from .error import WalletError, WalletDuplicateError, WalletNotFoundError from .key_pair import KeyPairStorageManager from .key_type import KeyType @@ -55,10 +55,10 @@ def __did_info_from_indy_info(self, info): did: str = info["did"] verkey = info["verkey"] - method = DIDMethod.KEY if did.startswith("did:key") else DIDMethod.SOV + method = KEY if did.startswith("did:key") else SOV key_type = KeyType.ED25519 - if method == DIDMethod.KEY: + if method == KEY: did = DIDKey.from_public_key_b58(info["verkey"], key_type).did return DIDInfo( @@ -73,7 +73,7 @@ def __did_info_from_key_pair_info(self, info: dict): method = DIDMethod.from_method(info["metadata"].get("method", "key")) key_type = KeyType.from_key_type(info["key_type"]) - if method == DIDMethod.KEY: + if method == KEY: did = DIDKey.from_public_key_b58(info["verkey"], key_type).did return DIDInfo( @@ -324,7 +324,7 @@ async def __create_indy_local_did( *, did: str = None, ) -> DIDInfo: - if method not in [DIDMethod.SOV, DIDMethod.KEY]: + if method not in [SOV, KEY]: raise WalletError( f"Unsupported DID method for indy storage: {method.method_name}" ) @@ -340,7 +340,7 @@ async def __create_indy_local_did( cfg["did"] = did # Create fully qualified did. This helps with determining the # did method when retrieving - if method != DIDMethod.SOV: + if method != SOV: cfg["method_name"] = method.method_name did_json = json.dumps(cfg) # crypto_type, cid - optional parameters skipped @@ -356,7 +356,7 @@ async def __create_indy_local_did( ) from x_indy # did key uses different format - if method == DIDMethod.KEY: + if method == KEY: did = DIDKey.from_public_key_b58(verkey, key_type).did await self.replace_local_did_metadata(did, metadata or {}) @@ -376,7 +376,7 @@ async def __create_keypair_local_did( metadata: dict = None, seed: str = None, ) -> DIDInfo: - if method != DIDMethod.KEY: + if method != KEY: raise WalletError( f"Unsupported DID method for keypair storage: {method.method_name}" ) @@ -444,7 +444,7 @@ async def create_local_did( f" for DID method {method.method_name}" ) - if method == DIDMethod.KEY and did: + if method == KEY and did: raise WalletError("Not allowed to set DID for DID method 'key'") # All ed25519 keys are handled by indy @@ -477,7 +477,7 @@ async def get_local_dids(self) -> Sequence[DIDInfo]: # this needs to change if more did methods are added key_pair_mgr = KeyPairStorageManager(IndySdkStorage(self.opened)) key_pairs = await key_pair_mgr.find_key_pairs( - tag_query={"method": DIDMethod.KEY.method_name} + tag_query={"method": KEY.method_name} ) for key_pair in key_pairs: ret.append(self.__did_info_from_key_pair_info(key_pair)) @@ -487,7 +487,7 @@ async def get_local_dids(self) -> Sequence[DIDInfo]: async def __get_indy_local_did( self, method: DIDMethod, key_type: KeyType, did: str ) -> DIDInfo: - if method not in [DIDMethod.SOV, DIDMethod.KEY]: + if method not in [SOV, KEY]: raise WalletError( f"Unsupported DID method for indy storage: {method.method_name}" ) @@ -497,7 +497,7 @@ async def __get_indy_local_did( ) # key type is always ed25519, method not always key - if method == DIDMethod.KEY and key_type == KeyType.ED25519: + if method == KEY and key_type == KeyType.ED25519: did_key = DIDKey.from_did(did) # Ed25519 did:keys are masked indy dids so transform to indy @@ -517,7 +517,7 @@ async def __get_indy_local_did( async def __get_keypair_local_did( self, method: DIDMethod, key_type: KeyType, did: str ): - if method != DIDMethod.KEY: + if method != KEY: raise WalletError( f"Unsupported DID method for keypair storage: {method.method_name}" ) @@ -552,7 +552,7 @@ async def get_local_did(self, did: str) -> DIDInfo: key_type = KeyType.ED25519 # If did key, the key type can differ - if method == DIDMethod.KEY: + if method == KEY: did_key = DIDKey.from_did(did) key_type = did_key.key_type @@ -679,7 +679,7 @@ async def set_public_did(self, did: Union[str, DIDInfo]) -> DIDInfo: else: info = did - if info.method != DIDMethod.SOV: + if info.method != SOV: raise WalletError("Setting public DID is only allowed for did:sov DIDs") public = await self.get_public_did() @@ -724,7 +724,7 @@ async def set_did_endpoint( 'endpoint' affects local wallet """ did_info = await self.get_local_did(did) - if did_info.method != DIDMethod.SOV: + if did_info.method != SOV: raise WalletError("Setting DID endpoint is only allowed for did:sov DIDs") metadata = {**did_info.metadata} diff --git a/aries_cloudagent/wallet/routes.py b/aries_cloudagent/wallet/routes.py index eb18163fcb..0783814167 100644 --- a/aries_cloudagent/wallet/routes.py +++ b/aries_cloudagent/wallet/routes.py @@ -38,7 +38,7 @@ from ..storage.error import StorageError, StorageNotFoundError from .base import BaseWallet from .did_info import DIDInfo -from .did_method import DIDMethod +from .did_method import SOV, KEY, DIDMethod from .did_posture import DIDPosture from .error import WalletError, WalletNotFoundError from .key_type import KeyType @@ -66,7 +66,7 @@ class DIDSchema(OpenAPISchema): ) method = fields.Str( description="Did method associated with the DID", - example=DIDMethod.SOV.method_name, + example=SOV.method_name, validate=validate.OneOf([method.method_name for method in DIDMethod]), ) key_type = fields.Str( @@ -136,8 +136,8 @@ class DIDListQueryStringSchema(OpenAPISchema): ) method = fields.Str( required=False, - example=DIDMethod.KEY.method_name, - validate=validate.OneOf([DIDMethod.KEY.method_name, DIDMethod.SOV.method_name]), + example=KEY.method_name, + validate=validate.OneOf([KEY.method_name, SOV.method_name]), description="DID method to query for. e.g. sov to only fetch indy/sov DIDs", ) key_type = fields.Str( @@ -173,9 +173,9 @@ class DIDCreateSchema(OpenAPISchema): method = fields.Str( required=False, - default=DIDMethod.SOV.method_name, - example=DIDMethod.SOV.method_name, - validate=validate.OneOf([DIDMethod.KEY.method_name, DIDMethod.SOV.method_name]), + default=SOV.method_name, + example=SOV.method_name, + validate=validate.OneOf([KEY.method_name, SOV.method_name]), ) options = fields.Nested( @@ -357,7 +357,7 @@ async def wallet_create_did(request: web.BaseRequest): KeyType.from_key_type(body.get("options", {}).get("key_type")) or KeyType.ED25519 ) - method = DIDMethod.from_method(body.get("method")) or DIDMethod.SOV + method = DIDMethod.from_method(body.get("method")) or SOV if not method.supports_key_type(key_type): raise web.HTTPForbidden( diff --git a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py index 6554336908..09743e05d8 100644 --- a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py +++ b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py @@ -5,7 +5,7 @@ from ...messaging.decorators.signature_decorator import SignatureDecorator from ...wallet.in_memory import InMemoryWallet from ...wallet.key_type import KeyType -from ...wallet.did_method import DIDMethod +from ...wallet.did_method import SOV, KEY from ...wallet.error import ( WalletError, WalletDuplicateError, @@ -130,19 +130,19 @@ async def test_signing_key_metadata_bls(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_create_local_sov_random(self, wallet: InMemoryWallet): - info = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519, None, None) + info = await wallet.create_local_did(SOV, KeyType.ED25519, None, None) assert info and info.did and info.verkey @pytest.mark.asyncio async def test_create_local_key_random_ed25519(self, wallet: InMemoryWallet): - info = await wallet.create_local_did(DIDMethod.KEY, KeyType.ED25519, None, None) + info = await wallet.create_local_did(KEY, KeyType.ED25519, None, None) assert info and info.did and info.verkey @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_create_local_key_random_bls12381g2(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.KEY, KeyType.BLS12381G2, None, None + KEY, KeyType.BLS12381G2, None, None ) assert info and info.did and info.verkey @@ -151,61 +151,61 @@ async def test_create_local_incorrect_key_type_for_did_method( self, wallet: InMemoryWallet ): with pytest.raises(WalletError): - await wallet.create_local_did(DIDMethod.SOV, KeyType.BLS12381G2, None, None) + await wallet.create_local_did(SOV, KeyType.BLS12381G2, None, None) @pytest.mark.asyncio async def test_create_local_sov_seeded(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, None + SOV, KeyType.ED25519, self.test_seed, None ) assert info.did == self.test_sov_did assert info.verkey == self.test_ed25519_verkey # should not raise WalletDuplicateError - same verkey await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, None + SOV, KeyType.ED25519, self.test_seed, None ) with pytest.raises(WalletError): _ = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, "invalid-seed", None + SOV, KeyType.ED25519, "invalid-seed", None ) @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_create_local_key_seeded_bls12381g2(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.KEY, KeyType.BLS12381G2, self.test_seed, None + KEY, KeyType.BLS12381G2, self.test_seed, None ) assert info.did == self.test_key_bls12381g2_did assert info.verkey == self.test_bls12381g2_verkey # should not raise WalletDuplicateError - same verkey await wallet.create_local_did( - DIDMethod.KEY, KeyType.BLS12381G2, self.test_seed, None + KEY, KeyType.BLS12381G2, self.test_seed, None ) with pytest.raises(WalletError): _ = await wallet.create_local_did( - DIDMethod.KEY, KeyType.BLS12381G2, "invalid-seed", None + KEY, KeyType.BLS12381G2, "invalid-seed", None ) @pytest.mark.asyncio async def test_create_local_key_seeded_ed25519(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.KEY, KeyType.ED25519, self.test_seed, None + KEY, KeyType.ED25519, self.test_seed, None ) assert info.did == self.test_key_ed25519_did assert info.verkey == self.test_ed25519_verkey # should not raise WalletDuplicateError - same verkey await wallet.create_local_did( - DIDMethod.KEY, KeyType.ED25519, self.test_seed, None + KEY, KeyType.ED25519, self.test_seed, None ) with pytest.raises(WalletError): _ = await wallet.create_local_did( - DIDMethod.KEY, KeyType.ED25519, "invalid-seed", None + KEY, KeyType.ED25519, "invalid-seed", None ) @pytest.mark.asyncio @@ -217,9 +217,9 @@ async def test_rotate_did_keypair(self, wallet: InMemoryWallet): await wallet.rotate_did_keypair_apply(self.test_sov_did) info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, self.test_sov_did + SOV, KeyType.ED25519, self.test_seed, self.test_sov_did ) - key_info = await wallet.create_local_did(DIDMethod.KEY, KeyType.ED25519) + key_info = await wallet.create_local_did(KEY, KeyType.ED25519) with pytest.raises(WalletError): await wallet.rotate_did_keypair_apply(self.test_sov_did) @@ -239,25 +239,25 @@ async def test_rotate_did_keypair(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_create_local_with_did(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, None, self.test_sov_did + SOV, KeyType.ED25519, None, self.test_sov_did ) assert info.did == self.test_sov_did with pytest.raises(WalletDuplicateError): await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, None, self.test_sov_did + SOV, KeyType.ED25519, None, self.test_sov_did ) with pytest.raises(WalletError) as context: await wallet.create_local_did( - DIDMethod.KEY, KeyType.ED25519, None, "did:sov:random" + KEY, KeyType.ED25519, None, "did:sov:random" ) assert "Not allowed to set DID for DID method 'key'" in str(context.value) @pytest.mark.asyncio async def test_local_verkey(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, self.test_sov_did + SOV, KeyType.ED25519, self.test_seed, self.test_sov_did ) assert info.did == self.test_sov_did assert info.verkey == self.test_ed25519_verkey @@ -273,7 +273,7 @@ async def test_local_verkey(self, wallet: InMemoryWallet): @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_local_verkey_bls12381g2(self, wallet: InMemoryWallet): - await wallet.create_local_did(DIDMethod.KEY, KeyType.BLS12381G2, self.test_seed) + await wallet.create_local_did(KEY, KeyType.BLS12381G2, self.test_seed) bls_info_get = await wallet.get_local_did_for_verkey( self.test_bls12381g2_verkey ) @@ -288,7 +288,7 @@ async def test_local_verkey_bls12381g2(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_local_metadata(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, self.test_seed, self.test_sov_did, @@ -318,7 +318,7 @@ async def test_local_metadata(self, wallet: InMemoryWallet): @pytest.mark.ursa_bbs_signatures async def test_local_metadata_bbs(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.KEY, + KEY, KeyType.BLS12381G2, self.test_seed, None, @@ -338,7 +338,7 @@ async def test_local_metadata_bbs(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_create_public_did(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, self.test_seed, self.test_sov_did, @@ -350,7 +350,7 @@ async def test_create_public_did(self, wallet: InMemoryWallet): assert not posted info_public = await wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) assert info_public.metadata.get("posted") @@ -359,7 +359,7 @@ async def test_create_public_did(self, wallet: InMemoryWallet): # test replace info_replace = await wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) assert info_replace.metadata.get("posted") @@ -376,7 +376,7 @@ async def test_create_public_did(self, wallet: InMemoryWallet): async def test_create_public_did_x_not_sov(self, wallet: InMemoryWallet): with pytest.raises(WalletError) as context: await wallet.create_public_did( - DIDMethod.KEY, + KEY, KeyType.ED25519, ) assert "Setting public DID is only allowed for did:sov DIDs" in str( @@ -389,7 +389,7 @@ async def test_create_public_did_x_unsupported_key_type_method( ): with pytest.raises(WalletError) as context: await wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.BLS12381G2, ) assert "Invalid key type" in str(context.value) @@ -397,7 +397,7 @@ async def test_create_public_did_x_unsupported_key_type_method( @pytest.mark.asyncio async def test_set_public_did(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, self.test_seed, self.test_sov_did, @@ -413,7 +413,7 @@ async def test_set_public_did(self, wallet: InMemoryWallet): assert info_same.did == info.did assert info_same.metadata.get("posted") - info_new = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + info_new = await wallet.create_local_did(SOV, KeyType.ED25519) assert info_new.did != info_same.did loc = await wallet.get_local_did(self.test_sov_did) @@ -429,7 +429,7 @@ async def test_set_public_did(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_set_public_did_x_not_sov(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.KEY, + KEY, KeyType.ED25519, ) with pytest.raises(WalletError) as context: @@ -441,7 +441,7 @@ async def test_set_public_did_x_not_sov(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_sign_verify(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, self.test_sov_did + SOV, KeyType.ED25519, self.test_seed, self.test_sov_did ) message_bin = self.test_message.encode("ascii") signature = await wallet.sign_message(message_bin, info.verkey) @@ -493,7 +493,7 @@ async def test_sign_verify(self, wallet: InMemoryWallet): @pytest.mark.ursa_bbs_signatures async def test_sign_verify_bbs(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.KEY, KeyType.BLS12381G2, self.test_seed + KEY, KeyType.BLS12381G2, self.test_seed ) message_bin = self.test_message.encode("ascii") signature = await wallet.sign_message(message_bin, info.verkey) @@ -552,7 +552,7 @@ async def test_sign_verify_bbs(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_pack_unpack(self, wallet: InMemoryWallet): await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, self.test_sov_did + SOV, KeyType.ED25519, self.test_seed, self.test_sov_did ) packed_anon = await wallet.pack_message( @@ -568,7 +568,7 @@ async def test_pack_unpack(self, wallet: InMemoryWallet): assert "Message not provided" in str(excinfo.value) await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_target_seed, self.test_target_did + SOV, KeyType.ED25519, self.test_target_seed, self.test_target_did ) packed_auth = await wallet.pack_message( self.test_message, [self.test_target_verkey], self.test_ed25519_verkey @@ -600,7 +600,7 @@ async def test_signature_round_trip(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_set_did_endpoint_x_not_sov(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.KEY, + KEY, KeyType.ED25519, ) with pytest.raises(WalletError) as context: diff --git a/aries_cloudagent/wallet/tests/test_indy_wallet.py b/aries_cloudagent/wallet/tests/test_indy_wallet.py index 6044a6a658..906ba2e44d 100644 --- a/aries_cloudagent/wallet/tests/test_indy_wallet.py +++ b/aries_cloudagent/wallet/tests/test_indy_wallet.py @@ -18,7 +18,7 @@ from ...indy.sdk.wallet_setup import IndyWalletConfig from ...ledger.endpoint_type import EndpointType from ...wallet.key_type import KeyType -from ...wallet.did_method import DIDMethod +from ...wallet.did_method import SOV from ...ledger.indy import IndySdkLedgerPool from .. import indy as test_module @@ -67,7 +67,7 @@ class TestIndySdkWallet(test_in_memory_wallet.TestInMemoryWallet): @pytest.mark.asyncio async def test_rotate_did_keypair_x(self, wallet: IndySdkWallet): info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, self.test_sov_did + SOV, KeyType.ED25519, self.test_seed, self.test_sov_did ) with async_mock.patch.object( @@ -111,7 +111,7 @@ async def test_create_local_did_x(self, wallet: IndySdkWallet): test_module.ErrorCode.CommonIOError, {"message": "outlier"} ) with pytest.raises(test_module.WalletError) as excinfo: - await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + await wallet.create_local_did(SOV, KeyType.ED25519) assert "outlier" in str(excinfo.value) @pytest.mark.asyncio @@ -120,7 +120,7 @@ async def test_set_did_endpoint_ledger(self, wallet: IndySdkWallet): read_only=False, update_endpoint_for_did=async_mock.CoroutineMock() ) info_pub = await wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) await wallet.set_did_endpoint(info_pub.did, "https://example.com", mock_ledger) @@ -147,7 +147,7 @@ async def test_set_did_endpoint_ledger_with_routing_keys( mock_ledger = async_mock.MagicMock( read_only=False, update_endpoint_for_did=async_mock.CoroutineMock() ) - info_pub = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + info_pub = await wallet.create_public_did(SOV, KeyType.ED25519) await wallet.set_did_endpoint( info_pub.did, "https://example.com", mock_ledger, routing_keys=routing_keys ) @@ -167,7 +167,7 @@ async def test_set_did_endpoint_readonly_ledger(self, wallet: IndySdkWallet): read_only=True, update_endpoint_for_did=async_mock.CoroutineMock() ) info_pub = await wallet.create_public_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, ) await wallet.set_did_endpoint(info_pub.did, "https://example.com", mock_ledger) @@ -206,7 +206,7 @@ async def test_get_local_did_x(self, wallet: IndySdkWallet): @pytest.mark.asyncio async def test_replace_local_did_metadata_x(self, wallet: IndySdkWallet): info = await wallet.create_local_did( - DIDMethod.SOV, + SOV, KeyType.ED25519, self.test_seed, self.test_sov_did, @@ -283,13 +283,13 @@ async def test_compare_pack_unpack(self, in_memory_wallet, wallet: IndySdkWallet Ensure that python-based pack/unpack is compatible with indy-sdk implementation """ await in_memory_wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed + SOV, KeyType.ED25519, self.test_seed ) py_packed = await in_memory_wallet.pack_message( self.test_message, [self.test_verkey], self.test_verkey ) - await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519, self.test_seed) + await wallet.create_local_did(SOV, KeyType.ED25519, self.test_seed) packed = await wallet.pack_message( self.test_message, [self.test_verkey], self.test_verkey ) @@ -820,7 +820,7 @@ async def test_postgres_wallet_works(self): opened = await postgres_wallet.create_wallet() wallet = IndySdkWallet(opened) - await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519, self.test_seed) + await wallet.create_local_did(SOV, KeyType.ED25519, self.test_seed) py_packed = await wallet.pack_message( self.test_message, [self.test_verkey], self.test_verkey ) @@ -862,7 +862,7 @@ async def test_postgres_wallet_scheme_works(self): assert "Wallet was not removed" in str(excinfo.value) wallet = IndySdkWallet(opened) - await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519, self.test_seed) + await wallet.create_local_did(SOV, KeyType.ED25519, self.test_seed) py_packed = await wallet.pack_message( self.test_message, [self.test_verkey], self.test_verkey ) @@ -899,7 +899,7 @@ async def test_postgres_wallet_scheme2_works(self): opened = await postgres_wallet.create_wallet() wallet = IndySdkWallet(opened) - await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519, self.test_seed) + await wallet.create_local_did(SOV, KeyType.ED25519, self.test_seed) py_packed = await wallet.pack_message( self.test_message, [self.test_verkey], self.test_verkey ) diff --git a/aries_cloudagent/wallet/tests/test_key_type.py b/aries_cloudagent/wallet/tests/test_key_type.py index 0dc025a099..0557e91fd4 100644 --- a/aries_cloudagent/wallet/tests/test_key_type.py +++ b/aries_cloudagent/wallet/tests/test_key_type.py @@ -1,7 +1,7 @@ from unittest import TestCase from ...core.error import BaseError -from ..did_method import DIDMethod +from ..did_method import SOV, KEY, DIDMethod from ..key_type import KeyType SOV_DID_METHOD_NAME = "sov" @@ -11,27 +11,27 @@ class TestDidMethod(TestCase): def test_from_metadata(self): - assert DIDMethod.from_metadata({"method": SOV_DID_METHOD_NAME}) == DIDMethod.SOV - assert DIDMethod.from_metadata({"method": KEY_DID_METHOD_NAME}) == DIDMethod.KEY + assert DIDMethod.from_metadata({"method": SOV_DID_METHOD_NAME}) == SOV + assert DIDMethod.from_metadata({"method": KEY_DID_METHOD_NAME}) == KEY # test backwards compat - assert DIDMethod.from_metadata({}) == DIDMethod.SOV + assert DIDMethod.from_metadata({}) == SOV def test_from_method(self): - assert DIDMethod.from_method(SOV_DID_METHOD_NAME) == DIDMethod.SOV - assert DIDMethod.from_method(KEY_DID_METHOD_NAME) == DIDMethod.KEY + assert DIDMethod.from_method(SOV_DID_METHOD_NAME) == SOV + assert DIDMethod.from_method(KEY_DID_METHOD_NAME) == KEY assert DIDMethod.from_method("random") == None def test_from_did(self): - assert DIDMethod.from_did(f"did:{SOV_DID_METHOD_NAME}:xxxx") == DIDMethod.SOV - assert DIDMethod.from_did(f"did:{KEY_DID_METHOD_NAME}:xxxx") == DIDMethod.KEY + assert DIDMethod.from_did(f"did:{SOV_DID_METHOD_NAME}:xxxx") == SOV + assert DIDMethod.from_did(f"did:{KEY_DID_METHOD_NAME}:xxxx") == KEY with self.assertRaises(BaseError) as context: DIDMethod.from_did("did:unknown:something") assert "Unsupported did method: unknown" in str(context.exception) def test_properties(self): - method = DIDMethod.SOV + method = SOV assert method.method_name == SOV_DID_METHOD_NAME assert method.supported_key_types == SOV_SUPPORTED_KEY_TYPES diff --git a/aries_cloudagent/wallet/tests/test_routes.py b/aries_cloudagent/wallet/tests/test_routes.py index c6adb4b5dc..e80a3a9b68 100644 --- a/aries_cloudagent/wallet/tests/test_routes.py +++ b/aries_cloudagent/wallet/tests/test_routes.py @@ -8,7 +8,7 @@ from ...core.in_memory import InMemoryProfile from ...ledger.base import BaseLedger from ...protocols.coordinate_mediation.v1_0.route_manager import RouteManager -from ...wallet.did_method import DIDMethod +from ...wallet.did_method import SOV from ...wallet.key_type import KeyType from ..base import BaseWallet from ..did_info import DIDInfo @@ -71,7 +71,7 @@ def test_format_did_info(self): self.test_did, self.test_verkey, DIDPosture.WALLET_ONLY.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) result = test_module.format_did_info(did_info) @@ -85,7 +85,7 @@ def test_format_did_info(self): self.test_did, self.test_verkey, {"posted": True, "public": True}, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) result = test_module.format_did_info(did_info) @@ -95,7 +95,7 @@ def test_format_did_info(self): self.test_did, self.test_verkey, {"posted": True, "public": False}, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) result = test_module.format_did_info(did_info) @@ -109,7 +109,7 @@ async def test_create_did(self): self.test_did, self.test_verkey, DIDPosture.WALLET_ONLY.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) result = await test_module.wallet_create_did(self.request) @@ -120,7 +120,7 @@ async def test_create_did(self): "verkey": self.test_verkey, "posture": DIDPosture.WALLET_ONLY.moniker, "key_type": KeyType.ED25519.key_type, - "method": DIDMethod.SOV.method_name, + "method": SOV.method_name, } } ) @@ -147,14 +147,14 @@ async def test_did_list(self): self.test_did, self.test_verkey, DIDPosture.WALLET_ONLY.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ), DIDInfo( self.test_posted_did, self.test_posted_verkey, DIDPosture.POSTED.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ), ] @@ -167,14 +167,14 @@ async def test_did_list(self): "verkey": self.test_posted_verkey, "posture": DIDPosture.POSTED.moniker, "key_type": KeyType.ED25519.key_type, - "method": DIDMethod.SOV.method_name, + "method": SOV.method_name, }, { "did": self.test_did, "verkey": self.test_verkey, "posture": DIDPosture.WALLET_ONLY.moniker, "key_type": KeyType.ED25519.key_type, - "method": DIDMethod.SOV.method_name, + "method": SOV.method_name, }, ] } @@ -191,7 +191,7 @@ async def test_did_list_filter_public(self): self.test_did, self.test_verkey, DIDPosture.PUBLIC.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) self.wallet.get_posted_dids.return_value = [ @@ -199,7 +199,7 @@ async def test_did_list_filter_public(self): self.test_posted_did, self.test_posted_verkey, DIDPosture.POSTED.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) ] @@ -212,7 +212,7 @@ async def test_did_list_filter_public(self): "verkey": self.test_verkey, "posture": DIDPosture.PUBLIC.moniker, "key_type": KeyType.ED25519.key_type, - "method": DIDMethod.SOV.method_name, + "method": SOV.method_name, } ] } @@ -229,7 +229,7 @@ async def test_did_list_filter_posted(self): self.test_did, self.test_verkey, DIDPosture.PUBLIC.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) self.wallet.get_posted_dids.return_value = [ @@ -240,7 +240,7 @@ async def test_did_list_filter_posted(self): "posted": True, "public": False, }, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) ] @@ -253,7 +253,7 @@ async def test_did_list_filter_posted(self): "verkey": self.test_posted_verkey, "posture": DIDPosture.POSTED.moniker, "key_type": KeyType.ED25519.key_type, - "method": DIDMethod.SOV.method_name, + "method": SOV.method_name, } ] } @@ -270,7 +270,7 @@ async def test_did_list_filter_did(self): self.test_did, self.test_verkey, DIDPosture.WALLET_ONLY.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) result = await test_module.wallet_did_list(self.request) @@ -282,7 +282,7 @@ async def test_did_list_filter_did(self): "verkey": self.test_verkey, "posture": DIDPosture.WALLET_ONLY.moniker, "key_type": KeyType.ED25519.key_type, - "method": DIDMethod.SOV.method_name, + "method": SOV.method_name, } ] } @@ -310,7 +310,7 @@ async def test_did_list_filter_verkey(self): self.test_did, self.test_verkey, DIDPosture.WALLET_ONLY.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) result = await test_module.wallet_did_list(self.request) @@ -322,7 +322,7 @@ async def test_did_list_filter_verkey(self): "verkey": self.test_verkey, "posture": DIDPosture.WALLET_ONLY.moniker, "key_type": KeyType.ED25519.key_type, - "method": DIDMethod.SOV.method_name, + "method": SOV.method_name, } ] } @@ -349,7 +349,7 @@ async def test_get_public_did(self): self.test_did, self.test_verkey, DIDPosture.PUBLIC.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) result = await test_module.wallet_get_public_did(self.request) @@ -360,7 +360,7 @@ async def test_get_public_did(self): "verkey": self.test_verkey, "posture": DIDPosture.PUBLIC.moniker, "key_type": KeyType.ED25519.key_type, - "method": DIDMethod.SOV.method_name, + "method": SOV.method_name, } } ) @@ -396,7 +396,7 @@ async def test_set_public_did(self): self.test_did, self.test_verkey, DIDPosture.PUBLIC.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) result = await test_module.wallet_set_public_did(self.request) @@ -408,7 +408,7 @@ async def test_set_public_did(self): "verkey": self.test_verkey, "posture": DIDPosture.PUBLIC.moniker, "key_type": KeyType.ED25519.key_type, - "method": DIDMethod.SOV.method_name, + "method": SOV.method_name, } } ) @@ -494,7 +494,7 @@ async def test_set_public_did_x(self): self.test_did, self.test_verkey, DIDPosture.PUBLIC.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) self.wallet.set_public_did.side_effect = test_module.WalletError() @@ -525,7 +525,7 @@ async def test_set_public_did_no_wallet_did(self): self.test_did, self.test_verkey, DIDPosture.PUBLIC.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) self.wallet.set_public_did.side_effect = test_module.WalletNotFoundError() @@ -557,7 +557,7 @@ async def test_set_public_did_update_endpoint(self): self.test_did, self.test_verkey, {**DIDPosture.PUBLIC.metadata, "endpoint": "https://endpoint.com"}, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) result = await test_module.wallet_set_public_did(self.request) @@ -569,7 +569,7 @@ async def test_set_public_did_update_endpoint(self): "verkey": self.test_verkey, "posture": DIDPosture.PUBLIC.moniker, "key_type": KeyType.ED25519.key_type, - "method": DIDMethod.SOV.method_name, + "method": SOV.method_name, } } ) @@ -605,7 +605,7 @@ async def test_set_public_did_update_endpoint_use_default_update_in_wallet(self) self.test_did, self.test_verkey, DIDPosture.PUBLIC.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) self.wallet.get_local_did.return_value = did_info @@ -627,7 +627,7 @@ async def test_set_public_did_update_endpoint_use_default_update_in_wallet(self) "verkey": self.test_verkey, "posture": DIDPosture.PUBLIC.moniker, "key_type": KeyType.ED25519.key_type, - "method": DIDMethod.SOV.method_name, + "method": SOV.method_name, } } ) @@ -651,14 +651,14 @@ async def test_set_did_endpoint(self): self.test_did, self.test_verkey, {"public": False, "endpoint": "http://old-endpoint.ca"}, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) self.wallet.get_public_did.return_value = DIDInfo( self.test_did, self.test_verkey, DIDPosture.PUBLIC.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) @@ -680,14 +680,14 @@ async def test_set_did_endpoint_public_did_no_ledger(self): self.test_did, self.test_verkey, {"public": False, "endpoint": "http://old-endpoint.ca"}, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) self.wallet.get_public_did.return_value = DIDInfo( self.test_did, self.test_verkey, DIDPosture.PUBLIC.metadata, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) self.wallet.set_did_endpoint.side_effect = test_module.LedgerConfigError() @@ -740,7 +740,7 @@ async def test_get_did_endpoint(self): self.test_did, self.test_verkey, {"public": False, "endpoint": "http://old-endpoint.ca"}, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) @@ -788,7 +788,7 @@ async def test_rotate_did_keypair(self): "did", "verkey", {"public": False}, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) ) @@ -823,7 +823,7 @@ async def test_rotate_did_keypair_did_not_local(self): "did", "verkey", {"posted": True, "public": True}, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) ) @@ -838,7 +838,7 @@ async def test_rotate_did_keypair_x(self): "did", "verkey", {"public": False}, - DIDMethod.SOV, + SOV, KeyType.ED25519, ) ) From 709f0ab696648cbc05554d2f67766ff9088648d7 Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Wed, 21 Sep 2022 09:45:31 -0600 Subject: [PATCH 04/22] updated how did methods are consumed Signed-off-by: Adam Burdett --- aries_cloudagent/wallet/askar.py | 37 ++++++++++--------- aries_cloudagent/wallet/did_method.py | 5 ++- aries_cloudagent/wallet/in_memory.py | 6 +-- aries_cloudagent/wallet/indy.py | 14 ++++--- aries_cloudagent/wallet/routes.py | 22 ++++++----- .../wallet/tests/test_key_type.py | 33 ++++++++++------- 6 files changed, 68 insertions(+), 49 deletions(-) diff --git a/aries_cloudagent/wallet/askar.py b/aries_cloudagent/wallet/askar.py index 66ec452ff4..a3914d6376 100644 --- a/aries_cloudagent/wallet/askar.py +++ b/aries_cloudagent/wallet/askar.py @@ -31,7 +31,7 @@ validate_seed, verify_signed_message, ) -from .did_method import SOV, KEY, DIDMethod +from .did_method import SOV, KEY, DIDMethod, DIDMethods from .error import WalletError, WalletDuplicateError, WalletNotFoundError from .key_type import KeyType from .util import b58_to_bytes, bytes_to_b58 @@ -56,7 +56,7 @@ def __init__(self, session: AskarProfileSession): self._session = session @property - def session(self) -> Session: + def session(self) -> AskarProfileSession: """Accessor for Askar profile session instance.""" return self._session @@ -257,7 +257,7 @@ async def get_local_dids(self) -> Sequence[DIDInfo]: ret = [] for item in await self._session.handle.fetch_all(CATEGORY_DID): - ret.append(_load_did_entry(item)) + ret.append(self._load_did_entry(item)) return ret async def get_local_did(self, did: str) -> DIDInfo: @@ -284,7 +284,7 @@ async def get_local_did(self, did: str) -> DIDInfo: raise WalletError("Error when fetching local DID") from err if not did: raise WalletNotFoundError("Unknown DID: {}".format(did)) - return _load_did_entry(did) + return self._load_did_entry(did) async def get_local_did_for_verkey(self, verkey: str) -> DIDInfo: """ @@ -308,7 +308,7 @@ async def get_local_did_for_verkey(self, verkey: str) -> DIDInfo: except AskarError as err: raise WalletError("Error when fetching local DID for verkey") from err if dids: - return _load_did_entry(dids[0]) + return self._load_did_entry(dids[0]) raise WalletNotFoundError("No DID defined for verkey: {}".format(verkey)) async def replace_local_did_metadata(self, did: str, metadata: dict): @@ -403,7 +403,7 @@ async def set_public_did(self, did: Union[str, DIDInfo]) -> DIDInfo: raise WalletError("Error when fetching local DID") from err if not item: raise WalletNotFoundError("Unknown DID: {}".format(did)) - info = _load_did_entry(item) + info = self._load_did_entry(item) else: info = did item = None @@ -507,7 +507,8 @@ async def rotate_did_keypair_start(self, did: str, next_seed: str = None) -> str """ # Check if DID can rotate keys - did_method = DIDMethod.from_did(did) + did_methods = self._session.inject(DIDMethods) + did_method: DIDMethod = did_methods.from_did(did) if not did_method.supports_rotation: raise WalletError( f"DID method '{did_method.method_name}' does not support key rotation." @@ -727,6 +728,17 @@ async def unpack_message(self, enc_message: bytes) -> Tuple[str, str, str]: raise WalletError("Exception when unpacking message") from err return unpacked_json.decode("utf-8"), sender, recipient + def _load_did_entry(self, entry: Entry) -> DIDInfo: + """Convert a DID record into the expected DIDInfo format.""" + did_info = entry.value_json + did_methods: DIDMethods = self._session.inject(DIDMethods) + return DIDInfo( + did=did_info["did"], + verkey=did_info["verkey"], + metadata=did_info.get("metadata"), + method=did_methods.from_method(did_info.get("method", "sov")), + key_type=KeyType.from_key_type(did_info.get("verkey_type", "ed25519")), + ) def _create_keypair(key_type: KeyType, seed: Union[str, bytes] = None) -> Key: """Instantiate a new keypair with an optional seed value.""" @@ -757,13 +769,4 @@ def _create_keypair(key_type: KeyType, seed: Union[str, bytes] = None) -> Key: return Key.generate(alg) -def _load_did_entry(entry: Entry) -> DIDInfo: - """Convert a DID record into the expected DIDInfo format.""" - did_info = entry.value_json - return DIDInfo( - did=did_info["did"], - verkey=did_info["verkey"], - metadata=did_info.get("metadata"), - method=DIDMethod.from_method(did_info.get("method", "sov")), - key_type=KeyType.from_key_type(did_info.get("verkey_type", "ed25519")), - ) + diff --git a/aries_cloudagent/wallet/did_method.py b/aries_cloudagent/wallet/did_method.py index 87436a44d7..5b93666ea1 100644 --- a/aries_cloudagent/wallet/did_method.py +++ b/aries_cloudagent/wallet/did_method.py @@ -45,7 +45,10 @@ class DIDMethods: """DID Method class specifying DID methods with supported key types.""" def __init__(self) -> None: - self._registry: Dict[str, DIDMethod] = {} + self._registry: Dict[str, DIDMethod] = { + SOV.method_name: SOV, + KEY.method_name: KEY + } def registered(self, method: str) -> bool: """Check for a supported method.""" diff --git a/aries_cloudagent/wallet/in_memory.py b/aries_cloudagent/wallet/in_memory.py index adc3e7ba92..f9bb03a37f 100644 --- a/aries_cloudagent/wallet/in_memory.py +++ b/aries_cloudagent/wallet/in_memory.py @@ -17,7 +17,7 @@ ) from .did_info import KeyInfo, DIDInfo from .did_posture import DIDPosture -from .did_method import SOV, KEY, DIDMethod +from .did_method import SOV, KEY, DIDMethod, DIDMethods from .error import WalletError, WalletDuplicateError, WalletNotFoundError from .key_type import KeyType from .util import b58_to_bytes, bytes_to_b58, random_seed @@ -132,8 +132,8 @@ async def rotate_did_keypair_start(self, did: str, next_seed: str = None) -> str local_did = self.profile.local_dids.get(did) if not local_did: raise WalletNotFoundError("Wallet owns no such DID: {}".format(did)) - - did_method = DIDMethod.from_did(did) + did_methods: DIDMethods = self.profile.context.inject(DIDMethods) + did_method: DIDMethod = did_methods.from_did(did) if not did_method.supports_rotation: raise WalletError( f"DID method '{did_method.method_name}' does not support key rotation." diff --git a/aries_cloudagent/wallet/indy.py b/aries_cloudagent/wallet/indy.py index 78ebfc0408..9258199c76 100644 --- a/aries_cloudagent/wallet/indy.py +++ b/aries_cloudagent/wallet/indy.py @@ -48,7 +48,7 @@ class IndySdkWallet(BaseWallet): def __init__(self, opened: IndyOpenWallet): """Create a new IndySdkWallet instance.""" - self.opened = opened + self.opened: IndyOpenWallet = opened def __did_info_from_indy_info(self, info): metadata = json.loads(info["metadata"]) if info["metadata"] else {} @@ -69,8 +69,8 @@ def __did_info_from_key_pair_info(self, info: dict): metadata = info["metadata"] verkey = info["verkey"] - # this needs to change if other did methods are added - method = DIDMethod.from_method(info["metadata"].get("method", "key")) + # TODO: inject context to support did method registry + method = SOV if metadata.get("method", "key") == SOV.method_name else KEY key_type = KeyType.from_key_type(info["key_type"]) if method == KEY: @@ -270,7 +270,9 @@ async def rotate_did_keypair_start(self, did: str, next_seed: str = None) -> str """ # Check if DID can rotate keys - did_method = DIDMethod.from_did(did) + #TODO: inject context for did method registry support + method_name = did.split(":")[1] if did.startswith("did:") else SOV.method_name + did_method = SOV if method_name == SOV.method_name else KEY if not did_method.supports_rotation: raise WalletError( f"DID method '{did_method.method_name}' does not support key rotation." @@ -548,7 +550,9 @@ async def get_local_did(self, did: str) -> DIDInfo: WalletError: If there is a libindy error """ - method = DIDMethod.from_did(did) + #TODO: inject context for did method registry support + method_name = did.split(":")[1] if did.startswith("did:") else SOV.method_name + method = SOV if method_name == SOV.method_name else KEY key_type = KeyType.ED25519 # If did key, the key type can differ diff --git a/aries_cloudagent/wallet/routes.py b/aries_cloudagent/wallet/routes.py index 0783814167..04cad1bf76 100644 --- a/aries_cloudagent/wallet/routes.py +++ b/aries_cloudagent/wallet/routes.py @@ -38,7 +38,7 @@ from ..storage.error import StorageError, StorageNotFoundError from .base import BaseWallet from .did_info import DIDInfo -from .did_method import SOV, KEY, DIDMethod +from .did_method import SOV, KEY, DIDMethod, DIDMethods from .did_posture import DIDPosture from .error import WalletError, WalletNotFoundError from .key_type import KeyType @@ -244,11 +244,12 @@ async def wallet_did_list(request: web.BaseRequest): context: AdminRequestContext = request["context"] filter_did = request.query.get("did") filter_verkey = request.query.get("verkey") - filter_method = DIDMethod.from_method(request.query.get("method")) filter_posture = DIDPosture.get(request.query.get("posture")) filter_key_type = KeyType.from_key_type(request.query.get("key_type")) results = [] async with context.session() as session: + did_methods: DIDMethods = session.inject(DIDMethods) + filter_method: DIDMethod | None = did_methods.from_method(request.query.get("method")) wallet = session.inject_or(BaseWallet) if not wallet: raise web.HTTPForbidden(reason="No wallet available") @@ -357,20 +358,21 @@ async def wallet_create_did(request: web.BaseRequest): KeyType.from_key_type(body.get("options", {}).get("key_type")) or KeyType.ED25519 ) - method = DIDMethod.from_method(body.get("method")) or SOV - if not method.supports_key_type(key_type): - raise web.HTTPForbidden( - reason=( - f"method {method.method_name} does not" - f" support key type {key_type.key_type}" - ) - ) seed = body.get("seed") or None if seed and not context.settings.get("wallet.allow_insecure_seed"): raise web.HTTPBadRequest(reason="Seed support is not enabled") info = None async with context.session() as session: + did_methods = session.inject(DIDMethods) + method = did_methods.from_method(body.get("method", '')) or SOV + if not method.supports_key_type(key_type): + raise web.HTTPForbidden( + reason=( + f"method {method.method_name} does not" + f" support key type {key_type.key_type}" + ) + ) wallet = session.inject_or(BaseWallet) if not wallet: raise web.HTTPForbidden(reason="No wallet available") diff --git a/aries_cloudagent/wallet/tests/test_key_type.py b/aries_cloudagent/wallet/tests/test_key_type.py index 0557e91fd4..6778bae27f 100644 --- a/aries_cloudagent/wallet/tests/test_key_type.py +++ b/aries_cloudagent/wallet/tests/test_key_type.py @@ -1,7 +1,7 @@ from unittest import TestCase from ...core.error import BaseError -from ..did_method import SOV, KEY, DIDMethod +from ..did_method import SOV, KEY, DIDMethods from ..key_type import KeyType SOV_DID_METHOD_NAME = "sov" @@ -10,32 +10,39 @@ class TestDidMethod(TestCase): + """TestCases for did method""" + did_methods = DIDMethods() + def test_from_metadata(self): - assert DIDMethod.from_metadata({"method": SOV_DID_METHOD_NAME}) == SOV - assert DIDMethod.from_metadata({"method": KEY_DID_METHOD_NAME}) == KEY + """Testing 'from_metadata'""" + assert self.did_methods.from_metadata({"method": SOV_DID_METHOD_NAME}) == SOV + assert self.did_methods.from_metadata({"method": KEY_DID_METHOD_NAME}) == KEY # test backwards compat - assert DIDMethod.from_metadata({}) == SOV + assert self.did_methods.from_metadata({}) == SOV def test_from_method(self): - assert DIDMethod.from_method(SOV_DID_METHOD_NAME) == SOV - assert DIDMethod.from_method(KEY_DID_METHOD_NAME) == KEY - assert DIDMethod.from_method("random") == None + """Testing 'from_method'""" + assert self.did_methods.from_method(SOV_DID_METHOD_NAME) == SOV + assert self.did_methods.from_method(KEY_DID_METHOD_NAME) == KEY + assert self.did_methods.from_method("random") is None def test_from_did(self): - assert DIDMethod.from_did(f"did:{SOV_DID_METHOD_NAME}:xxxx") == SOV - assert DIDMethod.from_did(f"did:{KEY_DID_METHOD_NAME}:xxxx") == KEY + """Testing 'from_did'""" + assert self.did_methods.from_did(f"did:{SOV_DID_METHOD_NAME}:xxxx") == SOV + assert self.did_methods.from_did(f"did:{KEY_DID_METHOD_NAME}:xxxx") == KEY with self.assertRaises(BaseError) as context: - DIDMethod.from_did("did:unknown:something") + self.did_methods.from_did("did:unknown:something") assert "Unsupported did method: unknown" in str(context.exception) def test_properties(self): + """Testing 'properties'""" method = SOV assert method.method_name == SOV_DID_METHOD_NAME assert method.supported_key_types == SOV_SUPPORTED_KEY_TYPES - assert method.supports_rotation == True + assert method.supports_rotation is True - assert method.supports_key_type(KeyType.ED25519) == True - assert method.supports_key_type(KeyType.BLS12381G2) == False + assert method.supports_key_type(KeyType.ED25519) is True + assert method.supports_key_type(KeyType.BLS12381G2) is False From 52407cad9b560badb5bd7adb536a386c43f4ff13 Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Wed, 21 Sep 2022 09:46:13 -0600 Subject: [PATCH 05/22] formatting Signed-off-by: Adam Burdett --- .../decorators/tests/test_attach_decorator.py | 7 ++-- .../protocols/connections/v1_0/manager.py | 4 +-- aries_cloudagent/wallet/askar.py | 4 +-- aries_cloudagent/wallet/did_method.py | 2 +- aries_cloudagent/wallet/indy.py | 4 +-- aries_cloudagent/wallet/routes.py | 6 ++-- .../wallet/tests/test_in_memory_wallet.py | 36 +++++-------------- .../wallet/tests/test_indy_wallet.py | 4 +-- .../wallet/tests/test_key_type.py | 1 + 9 files changed, 22 insertions(+), 46 deletions(-) diff --git a/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py b/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py index 7a74698212..170579d9f5 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py +++ b/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py @@ -433,9 +433,7 @@ def test_data_json_external_mutation(self): class TestAttachDecoratorSignature: @pytest.mark.asyncio async def test_did_raw_key(self, wallet, seed): - did_info = await wallet.create_local_did( - SOV, KeyType.ED25519, seed[0] - ) + did_info = await wallet.create_local_did(SOV, KeyType.ED25519, seed[0]) did_key0 = did_key(did_info.verkey) raw_key0 = raw_key(did_key0) assert raw_key0 != did_key0 @@ -457,8 +455,7 @@ async def test_indy_sign(self, wallet, seed): ) deco_indy_master = deepcopy(deco_indy) did_info = [ - await wallet.create_local_did(SOV, KeyType.ED25519, seed[i]) - for i in [0, 1] + await wallet.create_local_did(SOV, KeyType.ED25519, seed[i]) for i in [0, 1] ] assert deco_indy.data.signatures == 0 assert deco_indy.data.header_map() is None diff --git a/aries_cloudagent/protocols/connections/v1_0/manager.py b/aries_cloudagent/protocols/connections/v1_0/manager.py index 9bf066140d..d7418b79dc 100644 --- a/aries_cloudagent/protocols/connections/v1_0/manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/manager.py @@ -467,9 +467,7 @@ async def receive_request( if connection.is_multiuse_invitation: async with self.profile.session() as session: wallet = session.inject(BaseWallet) - my_info = await wallet.create_local_did( - SOV, KeyType.ED25519 - ) + my_info = await wallet.create_local_did(SOV, KeyType.ED25519) new_connection = ConnRecord( invitation_key=connection_key, diff --git a/aries_cloudagent/wallet/askar.py b/aries_cloudagent/wallet/askar.py index a3914d6376..93fc4ef7b4 100644 --- a/aries_cloudagent/wallet/askar.py +++ b/aries_cloudagent/wallet/askar.py @@ -740,6 +740,7 @@ def _load_did_entry(self, entry: Entry) -> DIDInfo: key_type=KeyType.from_key_type(did_info.get("verkey_type", "ed25519")), ) + def _create_keypair(key_type: KeyType, seed: Union[str, bytes] = None) -> Key: """Instantiate a new keypair with an optional seed value.""" if key_type == KeyType.ED25519: @@ -767,6 +768,3 @@ def _create_keypair(key_type: KeyType, seed: Union[str, bytes] = None) -> Key: raise WalletError("Invalid seed for key generation") from None else: return Key.generate(alg) - - - diff --git a/aries_cloudagent/wallet/did_method.py b/aries_cloudagent/wallet/did_method.py index 5b93666ea1..811be53d6b 100644 --- a/aries_cloudagent/wallet/did_method.py +++ b/aries_cloudagent/wallet/did_method.py @@ -47,7 +47,7 @@ class DIDMethods: def __init__(self) -> None: self._registry: Dict[str, DIDMethod] = { SOV.method_name: SOV, - KEY.method_name: KEY + KEY.method_name: KEY, } def registered(self, method: str) -> bool: diff --git a/aries_cloudagent/wallet/indy.py b/aries_cloudagent/wallet/indy.py index 9258199c76..46a5ad8ac6 100644 --- a/aries_cloudagent/wallet/indy.py +++ b/aries_cloudagent/wallet/indy.py @@ -270,7 +270,7 @@ async def rotate_did_keypair_start(self, did: str, next_seed: str = None) -> str """ # Check if DID can rotate keys - #TODO: inject context for did method registry support + # TODO: inject context for did method registry support method_name = did.split(":")[1] if did.startswith("did:") else SOV.method_name did_method = SOV if method_name == SOV.method_name else KEY if not did_method.supports_rotation: @@ -550,7 +550,7 @@ async def get_local_did(self, did: str) -> DIDInfo: WalletError: If there is a libindy error """ - #TODO: inject context for did method registry support + # TODO: inject context for did method registry support method_name = did.split(":")[1] if did.startswith("did:") else SOV.method_name method = SOV if method_name == SOV.method_name else KEY key_type = KeyType.ED25519 diff --git a/aries_cloudagent/wallet/routes.py b/aries_cloudagent/wallet/routes.py index 04cad1bf76..64274165d7 100644 --- a/aries_cloudagent/wallet/routes.py +++ b/aries_cloudagent/wallet/routes.py @@ -249,7 +249,9 @@ async def wallet_did_list(request: web.BaseRequest): results = [] async with context.session() as session: did_methods: DIDMethods = session.inject(DIDMethods) - filter_method: DIDMethod | None = did_methods.from_method(request.query.get("method")) + filter_method: DIDMethod | None = did_methods.from_method( + request.query.get("method") + ) wallet = session.inject_or(BaseWallet) if not wallet: raise web.HTTPForbidden(reason="No wallet available") @@ -365,7 +367,7 @@ async def wallet_create_did(request: web.BaseRequest): info = None async with context.session() as session: did_methods = session.inject(DIDMethods) - method = did_methods.from_method(body.get("method", '')) or SOV + method = did_methods.from_method(body.get("method", "")) or SOV if not method.supports_key_type(key_type): raise web.HTTPForbidden( reason=( diff --git a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py index 09743e05d8..c843296d63 100644 --- a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py +++ b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py @@ -141,9 +141,7 @@ async def test_create_local_key_random_ed25519(self, wallet: InMemoryWallet): @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_create_local_key_random_bls12381g2(self, wallet: InMemoryWallet): - info = await wallet.create_local_did( - KEY, KeyType.BLS12381G2, None, None - ) + info = await wallet.create_local_did(KEY, KeyType.BLS12381G2, None, None) assert info and info.did and info.verkey @pytest.mark.asyncio @@ -155,16 +153,12 @@ async def test_create_local_incorrect_key_type_for_did_method( @pytest.mark.asyncio async def test_create_local_sov_seeded(self, wallet: InMemoryWallet): - info = await wallet.create_local_did( - SOV, KeyType.ED25519, self.test_seed, None - ) + info = await wallet.create_local_did(SOV, KeyType.ED25519, self.test_seed, None) assert info.did == self.test_sov_did assert info.verkey == self.test_ed25519_verkey # should not raise WalletDuplicateError - same verkey - await wallet.create_local_did( - SOV, KeyType.ED25519, self.test_seed, None - ) + await wallet.create_local_did(SOV, KeyType.ED25519, self.test_seed, None) with pytest.raises(WalletError): _ = await wallet.create_local_did( @@ -181,9 +175,7 @@ async def test_create_local_key_seeded_bls12381g2(self, wallet: InMemoryWallet): assert info.verkey == self.test_bls12381g2_verkey # should not raise WalletDuplicateError - same verkey - await wallet.create_local_did( - KEY, KeyType.BLS12381G2, self.test_seed, None - ) + await wallet.create_local_did(KEY, KeyType.BLS12381G2, self.test_seed, None) with pytest.raises(WalletError): _ = await wallet.create_local_did( @@ -192,16 +184,12 @@ async def test_create_local_key_seeded_bls12381g2(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_create_local_key_seeded_ed25519(self, wallet: InMemoryWallet): - info = await wallet.create_local_did( - KEY, KeyType.ED25519, self.test_seed, None - ) + info = await wallet.create_local_did(KEY, KeyType.ED25519, self.test_seed, None) assert info.did == self.test_key_ed25519_did assert info.verkey == self.test_ed25519_verkey # should not raise WalletDuplicateError - same verkey - await wallet.create_local_did( - KEY, KeyType.ED25519, self.test_seed, None - ) + await wallet.create_local_did(KEY, KeyType.ED25519, self.test_seed, None) with pytest.raises(WalletError): _ = await wallet.create_local_did( @@ -244,14 +232,10 @@ async def test_create_local_with_did(self, wallet: InMemoryWallet): assert info.did == self.test_sov_did with pytest.raises(WalletDuplicateError): - await wallet.create_local_did( - SOV, KeyType.ED25519, None, self.test_sov_did - ) + await wallet.create_local_did(SOV, KeyType.ED25519, None, self.test_sov_did) with pytest.raises(WalletError) as context: - await wallet.create_local_did( - KEY, KeyType.ED25519, None, "did:sov:random" - ) + await wallet.create_local_did(KEY, KeyType.ED25519, None, "did:sov:random") assert "Not allowed to set DID for DID method 'key'" in str(context.value) @pytest.mark.asyncio @@ -492,9 +476,7 @@ async def test_sign_verify(self, wallet: InMemoryWallet): @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_sign_verify_bbs(self, wallet: InMemoryWallet): - info = await wallet.create_local_did( - KEY, KeyType.BLS12381G2, self.test_seed - ) + info = await wallet.create_local_did(KEY, KeyType.BLS12381G2, self.test_seed) message_bin = self.test_message.encode("ascii") signature = await wallet.sign_message(message_bin, info.verkey) assert signature diff --git a/aries_cloudagent/wallet/tests/test_indy_wallet.py b/aries_cloudagent/wallet/tests/test_indy_wallet.py index 906ba2e44d..b7de92ec88 100644 --- a/aries_cloudagent/wallet/tests/test_indy_wallet.py +++ b/aries_cloudagent/wallet/tests/test_indy_wallet.py @@ -282,9 +282,7 @@ async def test_compare_pack_unpack(self, in_memory_wallet, wallet: IndySdkWallet """ Ensure that python-based pack/unpack is compatible with indy-sdk implementation """ - await in_memory_wallet.create_local_did( - SOV, KeyType.ED25519, self.test_seed - ) + await in_memory_wallet.create_local_did(SOV, KeyType.ED25519, self.test_seed) py_packed = await in_memory_wallet.pack_message( self.test_message, [self.test_verkey], self.test_verkey ) diff --git a/aries_cloudagent/wallet/tests/test_key_type.py b/aries_cloudagent/wallet/tests/test_key_type.py index 6778bae27f..9b99d90a21 100644 --- a/aries_cloudagent/wallet/tests/test_key_type.py +++ b/aries_cloudagent/wallet/tests/test_key_type.py @@ -11,6 +11,7 @@ class TestDidMethod(TestCase): """TestCases for did method""" + did_methods = DIDMethods() def test_from_metadata(self): From 57777c3eb769da747652f843351a5073106fdfb8 Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Wed, 21 Sep 2022 14:08:48 -0600 Subject: [PATCH 06/22] fix tests Signed-off-by: Adam Burdett --- aries_cloudagent/config/default_context.py | 18 +++++++++--------- aries_cloudagent/ledger/tests/test_indy_vdr.py | 3 ++- aries_cloudagent/wallet/did_method.py | 6 ++++-- aries_cloudagent/wallet/routes.py | 4 +++- .../wallet/tests/test_in_memory_wallet.py | 3 ++- aries_cloudagent/wallet/tests/test_routes.py | 3 ++- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/aries_cloudagent/config/default_context.py b/aries_cloudagent/config/default_context.py index 0c5f90cac2..a2d013c5da 100644 --- a/aries_cloudagent/config/default_context.py +++ b/aries_cloudagent/config/default_context.py @@ -1,27 +1,26 @@ """Classes for configuring the default injection context.""" -from .base_context import ContextBuilder -from .injection_context import InjectionContext -from .provider import CachedProvider, ClassProvider - from ..cache.base import BaseCache from ..cache.in_memory import InMemoryCache from ..core.event_bus import EventBus +from ..core.goal_code_registry import GoalCodeRegistry from ..core.plugin_registry import PluginRegistry from ..core.profile import ProfileManager, ProfileManagerProvider from ..core.protocol_registry import ProtocolRegistry -from ..core.goal_code_registry import GoalCodeRegistry -from ..resolver.did_resolver import DIDResolver -from ..tails.base import BaseTailsServer - from ..protocols.actionmenu.v1_0.base_service import BaseMenuService from ..protocols.actionmenu.v1_0.driver_service import DriverMenuService from ..protocols.didcomm_prefix import DIDCommPrefix from ..protocols.introduction.v0_1.base_service import BaseIntroductionService from ..protocols.introduction.v0_1.demo_service import DemoIntroductionService +from ..resolver.did_resolver import DIDResolver +from ..tails.base import BaseTailsServer from ..transport.wire_format import BaseWireFormat -from ..utils.stats import Collector from ..utils.dependencies import is_indy_sdk_module_installed +from ..utils.stats import Collector +from ..wallet.did_method import DIDMethods +from .base_context import ContextBuilder +from .injection_context import InjectionContext +from .provider import CachedProvider, ClassProvider class DefaultContextBuilder(ContextBuilder): @@ -51,6 +50,7 @@ async def build_context(self) -> InjectionContext: # Global did resolver context.injector.bind_instance(DIDResolver, DIDResolver([])) + context.injector.bind_instance(DIDMethods, DIDMethods()) await self.bind_providers(context) await self.load_plugins(context) diff --git a/aries_cloudagent/ledger/tests/test_indy_vdr.py b/aries_cloudagent/ledger/tests/test_indy_vdr.py index 0d39e4daf6..8605e36d74 100644 --- a/aries_cloudagent/ledger/tests/test_indy_vdr.py +++ b/aries_cloudagent/ledger/tests/test_indy_vdr.py @@ -10,7 +10,7 @@ from ...indy.issuer import IndyIssuer from ...wallet.base import BaseWallet from ...wallet.key_type import KeyType -from ...wallet.did_method import SOV +from ...wallet.did_method import SOV, DIDMethods from ...wallet.did_info import DIDInfo from ..endpoint_type import EndpointType @@ -980,4 +980,5 @@ async def test_rotate_did_keypair(self, ledger: IndyVdrLedger): ] ), ): + ledger.profile.context.injector.bind_instance(DIDMethods,DIDMethods()) await ledger.rotate_public_did_keypair() diff --git a/aries_cloudagent/wallet/did_method.py b/aries_cloudagent/wallet/did_method.py index 811be53d6b..685b66d871 100644 --- a/aries_cloudagent/wallet/did_method.py +++ b/aries_cloudagent/wallet/did_method.py @@ -1,4 +1,4 @@ -"""Did method classes.""" +"""Did method registry classes.""" from typing import Dict, List, Mapping, Optional from .error import BaseError @@ -9,6 +9,7 @@ class DIDMethod: """Class to represent a did method.""" def __init__(self, name, key_types, rotation) -> None: + """Constructor for did method class.""" self._method_name: str = name self._supported_key_types: List[KeyType] = key_types self._supports_rotation: bool = rotation @@ -45,6 +46,7 @@ class DIDMethods: """DID Method class specifying DID methods with supported key types.""" def __init__(self) -> None: + """Constructor for did method registry.""" self._registry: Dict[str, DIDMethod] = { SOV.method_name: SOV, KEY.method_name: KEY, @@ -60,7 +62,7 @@ def register(self, method: DIDMethod): def from_method(self, method_name: str) -> Optional[DIDMethod]: """Retrieve a did method from method name.""" - return self._registry[method_name] + return self._registry.get(method_name) def from_metadata(self, metadata: Mapping) -> Optional[DIDMethod]: """Get DID method instance from metadata object. diff --git a/aries_cloudagent/wallet/routes.py b/aries_cloudagent/wallet/routes.py index 64274165d7..2340833299 100644 --- a/aries_cloudagent/wallet/routes.py +++ b/aries_cloudagent/wallet/routes.py @@ -67,7 +67,9 @@ class DIDSchema(OpenAPISchema): method = fields.Str( description="Did method associated with the DID", example=SOV.method_name, - validate=validate.OneOf([method.method_name for method in DIDMethod]), + validate=validate.OneOf( + [method.method_name for method in [SOV, KEY]] + ), # TODO: support more methods ) key_type = fields.Str( description="Key type associated with the DID", diff --git a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py index c843296d63..8181fdcff8 100644 --- a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py +++ b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py @@ -5,7 +5,7 @@ from ...messaging.decorators.signature_decorator import SignatureDecorator from ...wallet.in_memory import InMemoryWallet from ...wallet.key_type import KeyType -from ...wallet.did_method import SOV, KEY +from ...wallet.did_method import SOV, KEY, DIDMethods from ...wallet.error import ( WalletError, WalletDuplicateError, @@ -198,6 +198,7 @@ async def test_create_local_key_seeded_ed25519(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_rotate_did_keypair(self, wallet: InMemoryWallet): + wallet.profile.context.injector.bind_instance(DIDMethods, DIDMethods()) with pytest.raises(WalletNotFoundError): await wallet.rotate_did_keypair_start(self.test_sov_did) diff --git a/aries_cloudagent/wallet/tests/test_routes.py b/aries_cloudagent/wallet/tests/test_routes.py index e80a3a9b68..e690e30761 100644 --- a/aries_cloudagent/wallet/tests/test_routes.py +++ b/aries_cloudagent/wallet/tests/test_routes.py @@ -8,7 +8,7 @@ from ...core.in_memory import InMemoryProfile from ...ledger.base import BaseLedger from ...protocols.coordinate_mediation.v1_0.route_manager import RouteManager -from ...wallet.did_method import SOV +from ...wallet.did_method import SOV, DIDMethods from ...wallet.key_type import KeyType from ..base import BaseWallet from ..did_info import DIDInfo @@ -38,6 +38,7 @@ def setUp(self): self.test_verkey = "verkey" self.test_posted_did = "posted-did" self.test_posted_verkey = "posted-verkey" + self.context.injector.bind_instance(DIDMethods, DIDMethods()) async def test_missing_wallet(self): self.session_inject[BaseWallet] = None From d12fb60085b4c93eee481dae93ebb6e96aae3bb0 Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Wed, 21 Sep 2022 14:53:48 -0600 Subject: [PATCH 07/22] imperative mood to pass flake8 Signed-off-by: Adam Burdett --- aries_cloudagent/ledger/tests/test_indy_vdr.py | 2 +- aries_cloudagent/wallet/askar.py | 1 - aries_cloudagent/wallet/did_method.py | 8 ++++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/aries_cloudagent/ledger/tests/test_indy_vdr.py b/aries_cloudagent/ledger/tests/test_indy_vdr.py index 8605e36d74..6df896c7b3 100644 --- a/aries_cloudagent/ledger/tests/test_indy_vdr.py +++ b/aries_cloudagent/ledger/tests/test_indy_vdr.py @@ -980,5 +980,5 @@ async def test_rotate_did_keypair(self, ledger: IndyVdrLedger): ] ), ): - ledger.profile.context.injector.bind_instance(DIDMethods,DIDMethods()) + ledger.profile.context.injector.bind_instance(DIDMethods, DIDMethods()) await ledger.rotate_public_did_keypair() diff --git a/aries_cloudagent/wallet/askar.py b/aries_cloudagent/wallet/askar.py index 93fc4ef7b4..ae5f7c76be 100644 --- a/aries_cloudagent/wallet/askar.py +++ b/aries_cloudagent/wallet/askar.py @@ -13,7 +13,6 @@ Key, KeyAlg, SeedMethod, - Session, ) from ..askar.didcomm.v1 import pack_message, unpack_message diff --git a/aries_cloudagent/wallet/did_method.py b/aries_cloudagent/wallet/did_method.py index 685b66d871..2abd883e2c 100644 --- a/aries_cloudagent/wallet/did_method.py +++ b/aries_cloudagent/wallet/did_method.py @@ -1,4 +1,4 @@ -"""Did method registry classes.""" +"""did method.py contains registry for did methods.""" from typing import Dict, List, Mapping, Optional from .error import BaseError @@ -9,7 +9,7 @@ class DIDMethod: """Class to represent a did method.""" def __init__(self, name, key_types, rotation) -> None: - """Constructor for did method class.""" + """Construct did method class.""" self._method_name: str = name self._supported_key_types: List[KeyType] = key_types self._supports_rotation: bool = rotation @@ -46,7 +46,7 @@ class DIDMethods: """DID Method class specifying DID methods with supported key types.""" def __init__(self) -> None: - """Constructor for did method registry.""" + """Construct did method registry.""" self._registry: Dict[str, DIDMethod] = { SOV.method_name: SOV, KEY.method_name: KEY, @@ -57,7 +57,7 @@ def registered(self, method: str) -> bool: return method in list(self._registry.items()) def register(self, method: DIDMethod): - """Registers a new did method.""" + """Register a new did method.""" self._registry[method.method_name] = method def from_method(self, method_name: str) -> Optional[DIDMethod]: From 5f5e14c8574ff5bc6ac492ef517cdd25c296ea0c Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Thu, 22 Sep 2022 09:18:22 -0600 Subject: [PATCH 08/22] profile check Signed-off-by: Adam Burdett --- aries_cloudagent/wallet/tests/test_in_memory_wallet.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py index 8181fdcff8..4d1faeeb15 100644 --- a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py +++ b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py @@ -198,7 +198,8 @@ async def test_create_local_key_seeded_ed25519(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_rotate_did_keypair(self, wallet: InMemoryWallet): - wallet.profile.context.injector.bind_instance(DIDMethods, DIDMethods()) + if wallet.profile: + wallet.profile.context.injector.bind_instance(DIDMethods, DIDMethods()) with pytest.raises(WalletNotFoundError): await wallet.rotate_did_keypair_start(self.test_sov_did) From cb97190b29c9dfdc52169722429a4921bdc7360d Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Thu, 22 Sep 2022 09:28:12 -0600 Subject: [PATCH 09/22] comment to trigger checks Signed-off-by: Adam Burdett --- aries_cloudagent/wallet/tests/test_in_memory_wallet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py index 4d1faeeb15..997b9827f9 100644 --- a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py +++ b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py @@ -198,7 +198,7 @@ async def test_create_local_key_seeded_ed25519(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_rotate_did_keypair(self, wallet: InMemoryWallet): - if wallet.profile: + if wallet.profile: # check incase indysdkwallet is being used wallet.profile.context.injector.bind_instance(DIDMethods, DIDMethods()) with pytest.raises(WalletNotFoundError): await wallet.rotate_did_keypair_start(self.test_sov_did) From 1201a430ae8fd80defd478202b5ea171a8960d13 Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Thu, 22 Sep 2022 10:15:23 -0600 Subject: [PATCH 10/22] attr check Signed-off-by: Adam Burdett --- aries_cloudagent/wallet/tests/test_in_memory_wallet.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py index 997b9827f9..218b14bae8 100644 --- a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py +++ b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py @@ -1,6 +1,8 @@ import pytest import time +from aries_cloudagent.core.in_memory import profile + from ...core.in_memory import InMemoryProfile from ...messaging.decorators.signature_decorator import SignatureDecorator from ...wallet.in_memory import InMemoryWallet @@ -198,7 +200,7 @@ async def test_create_local_key_seeded_ed25519(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_rotate_did_keypair(self, wallet: InMemoryWallet): - if wallet.profile: # check incase indysdkwallet is being used + if hasattr(wallet, "profile"): # check incase indysdkwallet is being used wallet.profile.context.injector.bind_instance(DIDMethods, DIDMethods()) with pytest.raises(WalletNotFoundError): await wallet.rotate_did_keypair_start(self.test_sov_did) From 339694a085855c27a7ba3f241e66a7ec8b4c1ffa Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Thu, 22 Sep 2022 11:18:23 -0600 Subject: [PATCH 11/22] key type registry. Signed-off-by: Adam Burdett --- aries_cloudagent/wallet/key_type.py | 137 ++++++++++++++++------------ 1 file changed, 79 insertions(+), 58 deletions(-) diff --git a/aries_cloudagent/wallet/key_type.py b/aries_cloudagent/wallet/key_type.py index 57defdb521..901da168c5 100644 --- a/aries_cloudagent/wallet/key_type.py +++ b/aries_cloudagent/wallet/key_type.py @@ -1,78 +1,99 @@ -"""Key type enum.""" +"""Key type code.""" -from enum import Enum -from typing import NamedTuple, Optional +from typing import Optional -# Define keys -KeySpec = NamedTuple( - "KeySpec", - [("key_type", str), ("multicodec_name", str), ("multicodec_prefix", int)], -) +class KeyType: + """Key Type class.""" -class KeyTypeException(BaseException): - """Key type exception.""" - - -class KeyType(Enum): - """KeyType Enum specifying key types with multicodec name.""" - - # NOTE: the py_multicodec library is outdated. We use hardcoded prefixes here - # until this PR gets released: https://github.com/multiformats/py-multicodec/pull/14 - # multicodec is also not used now, but may be used again if py_multicodec is updated - ED25519 = KeySpec("ed25519", "ed25519-pub", b"\xed\x01") - X25519 = KeySpec("x25519", "x25519-pub", b"\xec\x01") - BLS12381G1 = KeySpec("bls12381g1", "bls12_381-g1-pub", b"\xea\x01") - BLS12381G2 = KeySpec("bls12381g2", "bls12_381-g2-pub", b"\xeb\x01") - BLS12381G1G2 = KeySpec("bls12381g1g2", "bls12_381-g1g2-pub", b"\xee\x01") + def __init__(self, key_type, multicodec_name, multicodec_prefix: bytes) -> None: + """Construct key type.""" + self._type: str = key_type + self._name: str = multicodec_name + self._prefix: bytes = multicodec_prefix @property def key_type(self) -> str: - """Getter for key type identifier.""" - return self.value.key_type + """Get Key type, type.""" + return self._type @property def multicodec_name(self) -> str: - """Getter for multicodec name.""" - return self.value.multicodec_name + """Get key type multicodec name.""" + return self._name @property def multicodec_prefix(self) -> bytes: - """Getter for multicodec prefix.""" - return self.value.multicodec_prefix - - @classmethod - def from_multicodec_name(cls, multicodec_name: str) -> Optional["KeyType"]: - """Get KeyType instance based on multicodec name. Returns None if not found.""" - for key_type in KeyType: - if key_type.multicodec_name == multicodec_name: - return key_type + """Get key type multicodec prefix.""" + return self._prefix - return None - @classmethod - def from_multicodec_prefix(cls, multicodec_prefix: bytes) -> Optional["KeyType"]: - """Get KeyType instance based on multicodec prefix. Returns None if not found.""" - for key_type in KeyType: - if key_type.multicodec_prefix == multicodec_prefix: - return key_type +class KeyTypeException(BaseException): + """Key type exception.""" - return None - @classmethod - def from_prefixed_bytes(cls, prefixed_bytes: bytes) -> Optional["KeyType"]: - """Get KeyType instance based on prefix in bytes. Returns None if not found.""" - for key_type in KeyType: - if prefixed_bytes.startswith(key_type.multicodec_prefix): - return key_type +# NOTE: the py_multicodec library is outdated. We use hardcoded prefixes here +# until this PR gets released: https://github.com/multiformats/py-multicodec/pull/14 +# multicodec is also not used now, but may be used again if py_multicodec is updated +ED25519: KeyType = KeyType("ed25519", "ed25519-pub", b"\xed\x01") +X25519: KeyType = KeyType("x25519", "x25519-pub", b"\xec\x01") +BLS12381G1: KeyType = KeyType("bls12381g1", "bls12_381-g1-pub", b"\xea\x01") +BLS12381G2: KeyType = KeyType("bls12381g2", "bls12_381-g2-pub", b"\xeb\x01") +BLS12381G1G2: KeyType = KeyType("bls12381g1g2", "bls12_381-g1g2-pub", b"\xee\x01") + + +class KeyTypes: + """KeyType class specifying key types with multicodec name.""" + + def __init__(self) -> None: + """Construct key type registry.""" + self._type_registry: dict[str, KeyType] = { + ED25519.key_type: ED25519, + X25519.key_type: X25519, + BLS12381G1.key_type: BLS12381G1, + BLS12381G2.key_type: BLS12381G2, + BLS12381G1G2.key_type: BLS12381G1G2, + } + self._name_registry: dict[str, KeyType] = { + ED25519.multicodec_name: ED25519, + X25519.multicodec_name: X25519, + BLS12381G1.multicodec_name: BLS12381G1, + BLS12381G2.multicodec_name: BLS12381G2, + BLS12381G1G2.multicodec_name: BLS12381G1G2, + } + self._prefix_registry: dict[bytes, KeyType] = { + ED25519.multicodec_prefix: ED25519, + X25519.multicodec_prefix: X25519, + BLS12381G1.multicodec_prefix: BLS12381G1, + BLS12381G2.multicodec_prefix: BLS12381G2, + BLS12381G1G2.multicodec_prefix: BLS12381G1G2, + } + + def register(self, key_type: KeyType): + """Register a new key type.""" + self._type_registry[key_type.key_type] = key_type + self._name_registry[key_type.multicodec_name] = key_type + self._prefix_registry[key_type.multicodec_prefix] = key_type + + def from_multicodec_name(self, multicodec_name: str) -> Optional["KeyType"]: + """Get KeyType instance based on multicodec name. Returns None if not found.""" + return self._name_registry.get(multicodec_name) - return None + def from_multicodec_prefix(self, multicodec_prefix: bytes) -> Optional["KeyType"]: + """Get KeyType instance based on multicodec prefix. Returns None if not found.""" + return self._prefix_registry.get(multicodec_prefix) - @classmethod - def from_key_type(cls, key_type: str) -> Optional["KeyType"]: + def from_prefixed_bytes(self, prefixed_bytes: bytes) -> Optional["KeyType"]: + """Get KeyType instance based on prefix in bytes. Returns None if not found.""" + return next( + ( + key_type + for key_type in self._name_registry.values() + if prefixed_bytes.startswith(key_type.multicodec_prefix) + ), + None, + ) + + def from_key_type(self, key_type: str) -> Optional["KeyType"]: """Get KeyType instance from the key type identifier.""" - for _key_type in KeyType: - if _key_type.key_type == key_type: - return _key_type - - return None + return self._type_registry.get(key_type) From c860e9823eeceb2a57e8ad5cd3122ec2a824f10f Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Thu, 22 Sep 2022 12:11:42 -0600 Subject: [PATCH 12/22] static keytypes Signed-off-by: Adam Burdett --- aries_cloudagent/config/wallet.py | 10 +- aries_cloudagent/core/tests/test_conductor.py | 16 +-- aries_cloudagent/did/did_key.py | 18 +-- .../did/tests/test_did_key_bls12381g1.py | 12 +- .../did/tests/test_did_key_bls12381g1g2.py | 20 +-- .../did/tests/test_did_key_bls12381g2.py | 12 +- .../did/tests/test_did_key_ed25519.py | 12 +- .../did/tests/test_did_key_x25519.py | 12 +- aries_cloudagent/ledger/tests/test_indy.py | 14 +- .../ledger/tests/test_indy_vdr.py | 34 ++--- .../messaging/decorators/attach_decorator.py | 12 +- .../decorators/signature_decorator.py | 6 +- .../decorators/tests/test_attach_decorator.py | 8 +- .../tests/test_signature_decorator.py | 4 +- .../messaging/jsonld/credential.py | 4 +- .../messaging/jsonld/tests/test_credential.py | 4 +- .../messaging/jsonld/tests/test_routes.py | 2 +- .../messaging/tests/test_agent_message.py | 2 +- .../multitenant/tests/test_base.py | 2 +- .../protocols/connections/v1_0/manager.py | 22 ++- .../tests/test_connection_response.py | 4 +- .../connections/v1_0/tests/test_manager.py | 104 +++++++------- .../coordinate_mediation/v1_0/manager.py | 2 +- .../v1_0/normalization.py | 2 +- .../v1_0/route_manager.py | 2 +- .../handlers/tests/test_request_handler.py | 2 +- .../handlers/tests/test_response_handler.py | 2 +- .../protocols/didexchange/v1_0/manager.py | 8 +- .../v1_0/messages/tests/test_request.py | 4 +- .../v1_0/messages/tests/test_response.py | 4 +- .../didexchange/v1_0/tests/test_manager.py | 46 +++--- .../v1_0/tests/test_manager.py | 2 +- .../v1_0/tests/test_routes.py | 28 ++-- .../introduction/v0_1/tests/test_service.py | 6 +- .../v2_0/formats/ld_proof/handler.py | 4 +- .../formats/ld_proof/tests/test_handler.py | 10 +- .../protocols/out_of_band/v1_0/manager.py | 16 +-- .../v1_0/messages/tests/test_invitation.py | 8 +- .../out_of_band/v1_0/tests/test_manager.py | 34 ++--- .../present_proof/dif/pres_exch_handler.py | 10 +- .../dif/tests/test_pres_exch_handler.py | 16 +-- .../present_proof/v2_0/formats/dif/handler.py | 6 +- .../transport/tests/test_pack_format.py | 6 +- .../utils/tests/test_outofband.py | 2 +- .../crypto/tests/test_wallet_key_pair.py | 12 +- .../tests/test_bbs_bls_signature_2020.py | 8 +- .../test_bbs_bls_signature_proof_2020.py | 6 +- .../tests/test_ed25519_signature_2018.py | 8 +- .../vc/ld_proofs/tests/test_ld_proofs.py | 20 +-- .../vc/tests/test_bbs_mattr_interop.py | 8 +- aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py | 22 +-- aries_cloudagent/wallet/askar.py | 20 +-- aries_cloudagent/wallet/crypto.py | 12 +- aries_cloudagent/wallet/did_method.py | 6 +- aries_cloudagent/wallet/indy.py | 34 ++--- aries_cloudagent/wallet/routes.py | 19 ++- aries_cloudagent/wallet/tests/test_crypto.py | 14 +- .../wallet/tests/test_did_method.py | 42 +++--- .../wallet/tests/test_in_memory_wallet.py | 136 +++++++++--------- .../wallet/tests/test_indy_wallet.py | 32 ++--- .../wallet/tests/test_key_pair.py | 14 +- .../wallet/tests/test_key_type.py | 8 +- aries_cloudagent/wallet/tests/test_routes.py | 74 +++++----- 63 files changed, 508 insertions(+), 541 deletions(-) diff --git a/aries_cloudagent/config/wallet.py b/aries_cloudagent/config/wallet.py index 61e34b2a73..d346f7740c 100644 --- a/aries_cloudagent/config/wallet.py +++ b/aries_cloudagent/config/wallet.py @@ -12,7 +12,7 @@ from ..wallet.crypto import seed_to_did from ..wallet.did_info import DIDInfo from ..wallet.did_method import DIDMethod -from ..wallet.key_type import KeyType +from ..wallet.key_type import ED25519 from .base import ConfigError from .injection_context import InjectionContext @@ -79,7 +79,7 @@ async def wallet_config( if wallet_seed and seed_to_did(wallet_seed) != public_did: if context.settings.get("wallet.replace_public_did"): replace_did_info = await wallet.create_local_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=wallet_seed + method=DIDMethod.SOV, key_type=ED25519, seed=wallet_seed ) public_did = replace_did_info.did await wallet.set_public_did(public_did) @@ -100,7 +100,7 @@ async def wallet_config( local_did_info = await wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=wallet_seed, metadata=metadata, ) @@ -110,7 +110,7 @@ async def wallet_config( print(f"Verkey: {local_did_info.verkey}") else: public_did_info = await wallet.create_public_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=wallet_seed + method=DIDMethod.SOV, key_type=ED25519, seed=wallet_seed ) public_did = public_did_info.did if provision: @@ -129,7 +129,7 @@ async def wallet_config( if test_seed: await wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=test_seed, metadata={"endpoint": "1.2.3.4:8021"}, ) diff --git a/aries_cloudagent/core/tests/test_conductor.py b/aries_cloudagent/core/tests/test_conductor.py index 203ca1b3b4..28763e2b8f 100644 --- a/aries_cloudagent/core/tests/test_conductor.py +++ b/aries_cloudagent/core/tests/test_conductor.py @@ -40,7 +40,7 @@ from ...utils.stats import Collector from ...version import __version__ from ...wallet.base import BaseWallet -from ...wallet.key_type import KeyType +from ...wallet.key_type import ED25519 from ...wallet.did_method import DIDMethod from .. import conductor as test_module @@ -132,7 +132,7 @@ async def test_startup(self): wallet = session.inject(BaseWallet) await wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) mock_inbound_mgr.return_value.setup.assert_awaited_once() @@ -601,7 +601,7 @@ async def test_admin(self): wallet = session.inject(BaseWallet) await wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) with async_mock.patch.object( @@ -645,7 +645,7 @@ async def test_admin_startx(self): wallet = session.inject(BaseWallet) await wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) with async_mock.patch.object( @@ -717,7 +717,7 @@ async def test_start_static(self): wallet = session.inject(BaseWallet) await wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) mock_mgr.return_value.create_static_connection = async_mock.AsyncMock() @@ -887,7 +887,7 @@ async def test_print_invite_connection(self): wallet = session.inject(BaseWallet) await wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) await conductor.start() @@ -1390,7 +1390,7 @@ async def test_startup_x_version_mismatch(self): wallet = session.inject(BaseWallet) await wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) mock_inbound_mgr.return_value.setup.assert_awaited_once() @@ -1427,7 +1427,7 @@ async def test_startup_x_no_storage_version(self): wallet = session.inject(BaseWallet) await wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) mock_inbound_mgr.return_value.setup.assert_awaited_once() diff --git a/aries_cloudagent/did/did_key.py b/aries_cloudagent/did/did_key.py index 70101910fb..c85a66fc8b 100644 --- a/aries_cloudagent/did/did_key.py +++ b/aries_cloudagent/did/did_key.py @@ -1,7 +1,7 @@ """DID Key class and resolver methods.""" from ..wallet.crypto import ed25519_pk_to_curve25519 -from ..wallet.key_type import KeyType +from ..wallet.key_type import BLS12381G1G2, ED25519, KeyType, BLS12381G1, X25519, BLS12381G2 from ..wallet.util import b58_to_bytes, bytes_to_b58 from ..vc.ld_proofs.constants import DID_V1_CONTEXT_URL @@ -169,8 +169,8 @@ def construct_did_key_bls12381g1g2(did_key: "DIDKey") -> dict: g1_public_key = did_key.public_key[:48] g2_public_key = did_key.public_key[48:] - bls12381g1_key = DIDKey.from_public_key(g1_public_key, KeyType.BLS12381G1) - bls12381g2_key = DIDKey.from_public_key(g2_public_key, KeyType.BLS12381G2) + bls12381g1_key = DIDKey.from_public_key(g1_public_key, BLS12381G1) + bls12381g2_key = DIDKey.from_public_key(g2_public_key, BLS12381G2) bls12381g1_key_id = f"{did_key.did}#{bls12381g1_key.fingerprint}" bls12381g2_key_id = f"{did_key.did}#{bls12381g2_key.fingerprint}" @@ -241,7 +241,7 @@ def construct_did_key_ed25519(did_key: "DIDKey") -> dict: """ curve25519 = ed25519_pk_to_curve25519(did_key.public_key) - x25519 = DIDKey.from_public_key(curve25519, KeyType.X25519) + x25519 = DIDKey.from_public_key(curve25519, X25519) did_doc = construct_did_signature_key_base( id=did_key.did, @@ -289,9 +289,9 @@ def construct_did_signature_key_base( DID_KEY_RESOLVERS = { - KeyType.ED25519: construct_did_key_ed25519, - KeyType.X25519: construct_did_key_x25519, - KeyType.BLS12381G2: construct_did_key_bls12381g2, - KeyType.BLS12381G1: construct_did_key_bls12381g1, - KeyType.BLS12381G1G2: construct_did_key_bls12381g1g2, + ED25519: construct_did_key_ed25519, + X25519: construct_did_key_x25519, + BLS12381G2: construct_did_key_bls12381g2, + BLS12381G1: construct_did_key_bls12381g1, + BLS12381G1G2: construct_did_key_bls12381g1g2, } diff --git a/aries_cloudagent/did/tests/test_did_key_bls12381g1.py b/aries_cloudagent/did/tests/test_did_key_bls12381g1.py index 9b95465df4..b110bc2b2f 100644 --- a/aries_cloudagent/did/tests/test_did_key_bls12381g1.py +++ b/aries_cloudagent/did/tests/test_did_key_bls12381g1.py @@ -1,7 +1,7 @@ from unittest import TestCase -from ...wallet.key_type import KeyType +from ...wallet.key_type import BLS12381G1 from ...wallet.util import b58_to_bytes from ..did_key import DIDKey, DID_KEY_RESOLVERS from .test_dids import ( @@ -24,13 +24,13 @@ class TestDIDKey(TestCase): def test_bls12381g1_from_public_key(self): key_bytes = b58_to_bytes(TEST_BLS12381G1_BASE58_KEY) - did_key = DIDKey.from_public_key(key_bytes, KeyType.BLS12381G1) + did_key = DIDKey.from_public_key(key_bytes, BLS12381G1) assert did_key.did == TEST_BLS12381G1_DID def test_bls12381g1_from_public_key_b58(self): did_key = DIDKey.from_public_key_b58( - TEST_BLS12381G1_BASE58_KEY, KeyType.BLS12381G1 + TEST_BLS12381G1_BASE58_KEY, BLS12381G1 ) assert did_key.did == TEST_BLS12381G1_DID @@ -53,20 +53,20 @@ def test_bls12381g1_properties(self): assert did_key.did == TEST_BLS12381G1_DID assert did_key.public_key_b58 == TEST_BLS12381G1_BASE58_KEY assert did_key.public_key == b58_to_bytes(TEST_BLS12381G1_BASE58_KEY) - assert did_key.key_type == KeyType.BLS12381G1 + assert did_key.key_type == BLS12381G1 assert did_key.key_id == TEST_BLS12381G1_KEY_ID assert did_key.prefixed_public_key == TEST_BLS12381G1_PREFIX_BYTES def test_bls12381g1_diddoc(self): did_key = DIDKey.from_did(TEST_BLS12381G1_DID) - resolver = DID_KEY_RESOLVERS[KeyType.BLS12381G1] + resolver = DID_KEY_RESOLVERS[BLS12381G1] assert resolver(did_key) == did_key.did_doc def test_bls12381g1_resolver(self): did_key = DIDKey.from_did(TEST_BLS12381G1_DID) - resolver = DID_KEY_RESOLVERS[KeyType.BLS12381G1] + resolver = DID_KEY_RESOLVERS[BLS12381G1] did_doc = resolver(did_key) assert ( diff --git a/aries_cloudagent/did/tests/test_did_key_bls12381g1g2.py b/aries_cloudagent/did/tests/test_did_key_bls12381g1g2.py index 59e2a05907..3b5a21c8cd 100644 --- a/aries_cloudagent/did/tests/test_did_key_bls12381g1g2.py +++ b/aries_cloudagent/did/tests/test_did_key_bls12381g1g2.py @@ -1,6 +1,6 @@ from unittest import TestCase -from ...wallet.key_type import KeyType +from ...wallet.key_type import BLS12381G1, BLS12381G1G2, BLS12381G2 from ...wallet.util import b58_to_bytes from ..did_key import DIDKey, DID_KEY_RESOLVERS from .test_dids import ( @@ -31,13 +31,13 @@ class TestDIDKey(TestCase): def test_bls12381g1g2_from_public_key(self): key_bytes = b58_to_bytes(TEST_BLS12381G1G2_BASE58_KEY) - did_key = DIDKey.from_public_key(key_bytes, KeyType.BLS12381G1G2) + did_key = DIDKey.from_public_key(key_bytes, BLS12381G1G2) assert did_key.did == TEST_BLS12381G1G2_DID def test_bls12381g1g2_from_public_key_b58(self): did_key = DIDKey.from_public_key_b58( - TEST_BLS12381G1G2_BASE58_KEY, KeyType.BLS12381G1G2 + TEST_BLS12381G1G2_BASE58_KEY, BLS12381G1G2 ) assert did_key.did == TEST_BLS12381G1G2_DID @@ -60,13 +60,13 @@ def test_bls12381g1g2_properties(self): assert did_key.did == TEST_BLS12381G1G2_DID assert did_key.public_key_b58 == TEST_BLS12381G1G2_BASE58_KEY assert did_key.public_key == b58_to_bytes(TEST_BLS12381G1G2_BASE58_KEY) - assert did_key.key_type == KeyType.BLS12381G1G2 + assert did_key.key_type == BLS12381G1G2 assert did_key.prefixed_public_key == TEST_BLS12381G1G2_PREFIX_BYTES def test_bls12381g1g2_diddoc(self): did_key = DIDKey.from_did(TEST_BLS12381G1G2_DID) - resolver = DID_KEY_RESOLVERS[KeyType.BLS12381G1G2] + resolver = DID_KEY_RESOLVERS[BLS12381G1G2] assert resolver(did_key) == did_key.did_doc @@ -74,7 +74,7 @@ def test_bls12381g1g2_resolver(self): did_key = DIDKey.from_did( "did:key:z5TcESXuYUE9aZWYwSdrUEGK1HNQFHyTt4aVpaCTVZcDXQmUheFwfNZmRksaAbBneNm5KyE52SdJeRCN1g6PJmF31GsHWwFiqUDujvasK3wTiDr3vvkYwEJHt7H5RGEKYEp1ErtQtcEBgsgY2DA9JZkHj1J9HZ8MRDTguAhoFtR4aTBQhgnkP4SwVbxDYMEZoF2TMYn3s" ) - resolver = DID_KEY_RESOLVERS[KeyType.BLS12381G1G2] + resolver = DID_KEY_RESOLVERS[BLS12381G1G2] did_doc = resolver(did_key) assert ( @@ -88,13 +88,13 @@ def test_bls12381g1g1_to_g1(self): # TODO: add easier method to go form g1 <- g1g2 -> g2 # First 48 bytes is g1 key g1_public_key = g1g2_did.public_key[:48] - g1_did = DIDKey.from_public_key(g1_public_key, KeyType.BLS12381G1) + g1_did = DIDKey.from_public_key(g1_public_key, BLS12381G1) assert g1_did.fingerprint == TEST_BLS12381G1_FINGERPRINT assert g1_did.did == TEST_BLS12381G1_DID assert g1_did.public_key_b58 == TEST_BLS12381G1_BASE58_KEY assert g1_did.public_key == b58_to_bytes(TEST_BLS12381G1_BASE58_KEY) - assert g1_did.key_type == KeyType.BLS12381G1 + assert g1_did.key_type == BLS12381G1 def test_bls12381g1g1_to_g2(self): g1g2_did = DIDKey.from_did(TEST_BLS12381G1G2_DID) @@ -102,10 +102,10 @@ def test_bls12381g1g1_to_g2(self): # TODO: add easier method to go form g1 <- g1g2 -> g2 # From 48 bytes is g2 key g2_public_key = g1g2_did.public_key[48:] - g2_did = DIDKey.from_public_key(g2_public_key, KeyType.BLS12381G2) + g2_did = DIDKey.from_public_key(g2_public_key, BLS12381G2) assert g2_did.fingerprint == TEST_BLS12381G2_FINGERPRINT assert g2_did.did == TEST_BLS12381G2_DID assert g2_did.public_key_b58 == TEST_BLS12381G2_BASE58_KEY assert g2_did.public_key == b58_to_bytes(TEST_BLS12381G2_BASE58_KEY) - assert g2_did.key_type == KeyType.BLS12381G2 + assert g2_did.key_type == BLS12381G2 diff --git a/aries_cloudagent/did/tests/test_did_key_bls12381g2.py b/aries_cloudagent/did/tests/test_did_key_bls12381g2.py index 0f2cb67fc1..ddd1259b97 100644 --- a/aries_cloudagent/did/tests/test_did_key_bls12381g2.py +++ b/aries_cloudagent/did/tests/test_did_key_bls12381g2.py @@ -1,6 +1,6 @@ from unittest import TestCase -from ...wallet.key_type import KeyType +from ...wallet.key_type import BLS12381G2 from ...wallet.util import b58_to_bytes from ..did_key import DIDKey, DID_KEY_RESOLVERS from .test_dids import ( @@ -19,13 +19,13 @@ class TestDIDKey(TestCase): def test_bls12381g2_from_public_key(self): key_bytes = b58_to_bytes(TEST_BLS12381G2_BASE58_KEY) - did_key = DIDKey.from_public_key(key_bytes, KeyType.BLS12381G2) + did_key = DIDKey.from_public_key(key_bytes, BLS12381G2) assert did_key.did == TEST_BLS12381G2_DID def test_bls12381g2_from_public_key_b58(self): did_key = DIDKey.from_public_key_b58( - TEST_BLS12381G2_BASE58_KEY, KeyType.BLS12381G2 + TEST_BLS12381G2_BASE58_KEY, BLS12381G2 ) assert did_key.did == TEST_BLS12381G2_DID @@ -48,20 +48,20 @@ def test_bls12381g2_properties(self): assert did_key.did == TEST_BLS12381G2_DID assert did_key.public_key_b58 == TEST_BLS12381G2_BASE58_KEY assert did_key.public_key == b58_to_bytes(TEST_BLS12381G2_BASE58_KEY) - assert did_key.key_type == KeyType.BLS12381G2 + assert did_key.key_type == BLS12381G2 assert did_key.key_id == TEST_BLS12381G2_KEY_ID assert did_key.prefixed_public_key == TEST_BLS12381G2_PREFIX_BYTES def test_bls12381g2_diddoc(self): did_key = DIDKey.from_did(TEST_BLS12381G2_DID) - resolver = DID_KEY_RESOLVERS[KeyType.BLS12381G2] + resolver = DID_KEY_RESOLVERS[BLS12381G2] assert resolver(did_key) == did_key.did_doc def test_bls12381g2_resolver(self): did_key = DIDKey.from_did(TEST_BLS12381G2_DID) - resolver = DID_KEY_RESOLVERS[KeyType.BLS12381G2] + resolver = DID_KEY_RESOLVERS[BLS12381G2] did_doc = resolver(did_key) assert ( diff --git a/aries_cloudagent/did/tests/test_did_key_ed25519.py b/aries_cloudagent/did/tests/test_did_key_ed25519.py index 3911fc3e36..53c2eb8bf2 100644 --- a/aries_cloudagent/did/tests/test_did_key_ed25519.py +++ b/aries_cloudagent/did/tests/test_did_key_ed25519.py @@ -1,6 +1,6 @@ from unittest import TestCase -from ...wallet.key_type import KeyType +from ...wallet.key_type import ED25519 from ...wallet.util import b58_to_bytes from ..did_key import DIDKey, DID_KEY_RESOLVERS from .test_dids import DID_ED25519_z6MkmjY8GnV5i9YTDtPETC2uUAW6ejw3nk5mXF5yci5ab7th @@ -17,12 +17,12 @@ class TestDIDKey(TestCase): def test_ed25519_from_public_key(self): key_bytes = b58_to_bytes(TEST_ED25519_BASE58_KEY) - did_key = DIDKey.from_public_key(key_bytes, KeyType.ED25519) + did_key = DIDKey.from_public_key(key_bytes, ED25519) assert did_key.did == TEST_ED25519_DID def test_ed25519_from_public_key_b58(self): - did_key = DIDKey.from_public_key_b58(TEST_ED25519_BASE58_KEY, KeyType.ED25519) + did_key = DIDKey.from_public_key_b58(TEST_ED25519_BASE58_KEY, ED25519) assert did_key.did == TEST_ED25519_DID @@ -44,20 +44,20 @@ def test_ed25519_properties(self): assert did_key.did == TEST_ED25519_DID assert did_key.public_key_b58 == TEST_ED25519_BASE58_KEY assert did_key.public_key == b58_to_bytes(TEST_ED25519_BASE58_KEY) - assert did_key.key_type == KeyType.ED25519 + assert did_key.key_type == ED25519 assert did_key.key_id == TEST_ED25519_KEY_ID assert did_key.prefixed_public_key == TEST_ED25519_PREFIX_BYTES def test_ed25519_diddoc(self): did_key = DIDKey.from_did(TEST_ED25519_DID) - resolver = DID_KEY_RESOLVERS[KeyType.ED25519] + resolver = DID_KEY_RESOLVERS[ED25519] assert resolver(did_key) == did_key.did_doc def test_ed25519_resolver(self): did_key = DIDKey.from_did(TEST_ED25519_DID) - resolver = DID_KEY_RESOLVERS[KeyType.ED25519] + resolver = DID_KEY_RESOLVERS[ED25519] did_doc = resolver(did_key) # resolved using uniresolver, updated to did v1 diff --git a/aries_cloudagent/did/tests/test_did_key_x25519.py b/aries_cloudagent/did/tests/test_did_key_x25519.py index 924011f396..84513da814 100644 --- a/aries_cloudagent/did/tests/test_did_key_x25519.py +++ b/aries_cloudagent/did/tests/test_did_key_x25519.py @@ -1,6 +1,6 @@ from unittest import TestCase -from ...wallet.key_type import KeyType +from ...wallet.key_type import X25519 from ...wallet.util import b58_to_bytes from ..did_key import DIDKey, DID_KEY_RESOLVERS from .test_dids import DID_X25519_z6LShLeXRTzevtwcfehaGEzCMyL3bNsAeKCwcqwJxyCo63yE @@ -15,12 +15,12 @@ class TestDIDKey(TestCase): def test_x25519_from_public_key(self): key_bytes = b58_to_bytes(TEST_X25519_BASE58_KEY) - did_key = DIDKey.from_public_key(key_bytes, KeyType.X25519) + did_key = DIDKey.from_public_key(key_bytes, X25519) assert did_key.did == TEST_X25519_DID def test_x25519_from_public_key_b58(self): - did_key = DIDKey.from_public_key_b58(TEST_X25519_BASE58_KEY, KeyType.X25519) + did_key = DIDKey.from_public_key_b58(TEST_X25519_BASE58_KEY, X25519) assert did_key.did == TEST_X25519_DID @@ -42,20 +42,20 @@ def test_x25519_properties(self): assert did_key.did == TEST_X25519_DID assert did_key.public_key_b58 == TEST_X25519_BASE58_KEY assert did_key.public_key == b58_to_bytes(TEST_X25519_BASE58_KEY) - assert did_key.key_type == KeyType.X25519 + assert did_key.key_type == X25519 assert did_key.key_id == TEST_X25519_KEY_ID assert did_key.prefixed_public_key == TEST_X25519_PREFIX_BYTES def test_x25519_diddoc(self): did_key = DIDKey.from_did(TEST_X25519_DID) - resolver = DID_KEY_RESOLVERS[KeyType.X25519] + resolver = DID_KEY_RESOLVERS[X25519] assert resolver(did_key) == did_key.did_doc def test_x25519_resolver(self): did_key = DIDKey.from_did(TEST_X25519_DID) - resolver = DID_KEY_RESOLVERS[KeyType.X25519] + resolver = DID_KEY_RESOLVERS[X25519] did_doc = resolver(did_key) # resolved using uniresolver, updated to did v1 diff --git a/aries_cloudagent/ledger/tests/test_indy.py b/aries_cloudagent/ledger/tests/test_indy.py index bda1890c2a..52a0df6463 100644 --- a/aries_cloudagent/ledger/tests/test_indy.py +++ b/aries_cloudagent/ledger/tests/test_indy.py @@ -19,7 +19,7 @@ from ...wallet.did_posture import DIDPosture from ...wallet.error import WalletNotFoundError from ...wallet.indy import IndyOpenWallet, IndySdkWallet -from ...wallet.key_type import KeyType +from ...wallet.key_type import ED25519 from ...wallet.did_method import DIDMethod from ..endpoint_type import EndpointType @@ -71,7 +71,7 @@ async def setUp(self): verkey="3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx", metadata={"test": "test"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) self.test_verkey = "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx" context = InjectionContext() @@ -1220,7 +1220,7 @@ async def test_send_credential_definition( verkey=self.test_verkey, metadata=None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_did = mock_wallet_get_public_did.return_value ( @@ -1300,7 +1300,7 @@ async def test_send_credential_definition_endorse_only( self.test_verkey, None, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) async with ledger: ( @@ -1383,7 +1383,7 @@ async def test_send_credential_definition_exists_in_ledger_and_wallet( verkey=self.test_verkey, metadata=None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) async with ledger: @@ -1795,7 +1795,7 @@ async def test_send_credential_definition_on_ledger_in_wallet( verkey=self.test_verkey, metadata=None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_did = mock_wallet_get_public_did.return_value @@ -1869,7 +1869,7 @@ async def test_send_credential_definition_create_cred_def_exception( verkey=self.test_verkey, metadata=None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) async with ledger: with self.assertRaises(LedgerError): diff --git a/aries_cloudagent/ledger/tests/test_indy_vdr.py b/aries_cloudagent/ledger/tests/test_indy_vdr.py index f20781e838..bb765b0ca1 100644 --- a/aries_cloudagent/ledger/tests/test_indy_vdr.py +++ b/aries_cloudagent/ledger/tests/test_indy_vdr.py @@ -9,7 +9,7 @@ from ...core.in_memory import InMemoryProfile from ...indy.issuer import IndyIssuer from ...wallet.base import BaseWallet -from ...wallet.key_type import KeyType +from ...wallet.key_type import ED25519 from ...wallet.did_method import DIDMethod from ...wallet.did_info import DIDInfo @@ -67,7 +67,7 @@ async def test_submit_signed( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) test_msg = indy_vdr.ledger.build_get_txn_request(test_did.did, 1, 1) async with ledger: @@ -120,7 +120,7 @@ async def test_submit_signed_taa_accept( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) async with ledger: test_msg = indy_vdr.ledger.build_get_txn_request(test_did.did, 1, 1) @@ -188,7 +188,7 @@ async def test_txn_endorse( with pytest.raises(BadLedgerRequestError): await ledger.txn_endorse(request_json=test_msg.body) - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) test_msg.set_endorser(test_did.did) endorsed_json = await ledger.txn_endorse(request_json=test_msg.body) @@ -201,7 +201,7 @@ async def test_send_schema( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) issuer = async_mock.MagicMock(IndyIssuer) issuer.create_schema.return_value = ( "schema_issuer_did:schema_name:9.1", @@ -262,7 +262,7 @@ async def test_send_schema_already_exists( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) issuer = async_mock.MagicMock(IndyIssuer) issuer.create_schema.return_value = ( "schema_issuer_did:schema_name:9.1", @@ -292,7 +292,7 @@ async def test_send_schema_ledger_read_only( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) issuer = async_mock.MagicMock(IndyIssuer) issuer.create_schema.return_value = ( "schema_issuer_did:schema_name:9.1", @@ -321,7 +321,7 @@ async def test_send_schema_ledger_transaction_error( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) issuer = async_mock.MagicMock(IndyIssuer) issuer.create_schema.return_value = ( "schema_issuer_did:schema_name:9.1", @@ -383,7 +383,7 @@ async def test_send_credential_definition( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) schema_id = "55GkHamhTU1ZbTbV2ab9DE:2:schema_name:9.1" cred_def_id = "55GkHamhTU1ZbTbV2ab9DE:3:CL:99:tag" cred_def = { @@ -598,7 +598,7 @@ async def test_update_endpoint_for_did( ledger: IndyVdrLedger, ): wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) async with ledger: ledger.pool_handle.submit_request.side_effect = ( {"data": None}, @@ -675,7 +675,7 @@ async def test_construct_attr_json( async def test_update_endpoint_for_did_calls_attr_json(self, ledger: IndyVdrLedger): routing_keys = ["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"] wallet = (await ledger.profile.session()).wallet - test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + test_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) async with ledger: with async_mock.patch.object( @@ -742,8 +742,8 @@ async def test_register_nym_local( ledger: IndyVdrLedger, ): wallet: BaseWallet = (await ledger.profile.session()).wallet - public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) - post_did = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + public_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) + post_did = await wallet.create_local_did(DIDMethod.SOV, ED25519) async with ledger: await ledger.register_nym(post_did.did, post_did.verkey) did = await wallet.get_local_did(post_did.did) @@ -755,7 +755,7 @@ async def test_register_nym_non_local( ledger: IndyVdrLedger, ): wallet: BaseWallet = (await ledger.profile.session()).wallet - public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + public_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) async with ledger: await ledger.register_nym("55GkHamhTU1ZbTbV2ab9DE", "verkey") @@ -898,7 +898,7 @@ async def test_send_revoc_reg_def( ledger: IndyVdrLedger, ): wallet: BaseWallet = (await ledger.profile.session()).wallet - public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + public_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) async with ledger: reg_id = ( "55GkHamhTU1ZbTbV2ab9DE:4:55GkHamhTU1ZbTbV2ab9DE:3:CL:99:tag:CL_ACCUM:0" @@ -927,7 +927,7 @@ async def test_send_revoc_reg_entry( ledger: IndyVdrLedger, ): wallet: BaseWallet = (await ledger.profile.session()).wallet - public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + public_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) async with ledger: reg_id = ( "55GkHamhTU1ZbTbV2ab9DE:4:55GkHamhTU1ZbTbV2ab9DE:3:CL:99:tag:CL_ACCUM:0" @@ -966,7 +966,7 @@ async def test_credential_definition_id2schema_id(self, ledger: IndyVdrLedger): @pytest.mark.asyncio async def test_rotate_did_keypair(self, ledger: IndyVdrLedger): wallet = (await ledger.profile.session()).wallet - public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + public_did = await wallet.create_public_did(DIDMethod.SOV, ED25519) async with ledger: with async_mock.patch.object( diff --git a/aries_cloudagent/messaging/decorators/attach_decorator.py b/aries_cloudagent/messaging/decorators/attach_decorator.py index 309ebc6a68..66284378df 100644 --- a/aries_cloudagent/messaging/decorators/attach_decorator.py +++ b/aries_cloudagent/messaging/decorators/attach_decorator.py @@ -24,7 +24,7 @@ str_to_b64, unpad, ) -from ...wallet.key_type import KeyType +from ...wallet.key_type import ED25519 from ...did.did_key import DIDKey from ..models.base import BaseModel, BaseModelError, BaseModelSchema from ..valid import ( @@ -201,7 +201,7 @@ def did_key(verkey: str) -> str: if verkey.startswith("did:key:"): return verkey - return DIDKey.from_public_key_b58(verkey, KeyType.ED25519).did + return DIDKey.from_public_key_b58(verkey, ED25519).did def raw_key(verkey: str) -> str: @@ -440,13 +440,9 @@ async def verify(self, wallet: BaseWallet, signer_verkey: str = None) -> bool: verkey = bytes_to_b58(b64_to_bytes(protected["jwk"]["x"], urlsafe=True)) encoded_pk = DIDKey.from_did(protected["jwk"]["kid"]).public_key_b58 verkey_to_check.append(encoded_pk) - if not await wallet.verify_message( - sign_input, b_sig, verkey, KeyType.ED25519 - ): + if not await wallet.verify_message(sign_input, b_sig, verkey, ED25519): return False - if not await wallet.verify_message( - sign_input, b_sig, encoded_pk, KeyType.ED25519 - ): + if not await wallet.verify_message(sign_input, b_sig, encoded_pk, ED25519): return False if signer_verkey and signer_verkey not in verkey_to_check: return False diff --git a/aries_cloudagent/messaging/decorators/signature_decorator.py b/aries_cloudagent/messaging/decorators/signature_decorator.py index 71bf1c42ea..a8b67cce29 100644 --- a/aries_cloudagent/messaging/decorators/signature_decorator.py +++ b/aries_cloudagent/messaging/decorators/signature_decorator.py @@ -9,7 +9,7 @@ from ...protocols.didcomm_prefix import DIDCommPrefix from ...wallet.base import BaseWallet from ...wallet.util import b64_to_bytes, bytes_to_b64 -from ...wallet.key_type import KeyType +from ...wallet.key_type import ED25519 from ..models.base import BaseModel, BaseModelSchema from ..valid import Base64URL, BASE64URL, INDY_RAW_PUBLIC_KEY @@ -111,9 +111,7 @@ async def verify(self, wallet: BaseWallet) -> bool: return False msg_bin = b64_to_bytes(self.sig_data, urlsafe=True) sig_bin = b64_to_bytes(self.signature, urlsafe=True) - return await wallet.verify_message( - msg_bin, sig_bin, self.signer, KeyType.ED25519 - ) + return await wallet.verify_message(msg_bin, sig_bin, self.signer, ED25519) def __str__(self): """Get a string representation of this class.""" diff --git a/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py b/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py index 2687c7bf19..13a91e61f2 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py +++ b/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py @@ -10,7 +10,7 @@ from ....messaging.models.base import BaseModelError from ....wallet.indy import IndySdkWallet from ....wallet.util import b64_to_bytes, bytes_to_b64 -from ....wallet.key_type import KeyType +from ....wallet.key_type import ED25519 from ....wallet.did_method import DIDMethod from ..attach_decorator import ( @@ -433,9 +433,7 @@ def test_data_json_external_mutation(self): class TestAttachDecoratorSignature: @pytest.mark.asyncio async def test_did_raw_key(self, wallet, seed): - did_info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, seed[0] - ) + did_info = await wallet.create_local_did(DIDMethod.SOV, ED25519, seed[0]) did_key0 = did_key(did_info.verkey) raw_key0 = raw_key(did_key0) assert raw_key0 != did_key0 @@ -457,7 +455,7 @@ async def test_indy_sign(self, wallet, seed): ) deco_indy_master = deepcopy(deco_indy) did_info = [ - await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519, seed[i]) + await wallet.create_local_did(DIDMethod.SOV, ED25519, seed[i]) for i in [0, 1] ] assert deco_indy.data.signatures == 0 diff --git a/aries_cloudagent/messaging/decorators/tests/test_signature_decorator.py b/aries_cloudagent/messaging/decorators/tests/test_signature_decorator.py index c7d23a25e1..4eca03663f 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_signature_decorator.py +++ b/aries_cloudagent/messaging/decorators/tests/test_signature_decorator.py @@ -1,6 +1,6 @@ from asynctest import TestCase as AsyncTestCase -from ....wallet.key_type import KeyType +from ....wallet.key_type import ED25519, KeyType from ....core.in_memory import InMemoryProfile from ....protocols.trustping.v1_0.messages.ping import Ping from ....wallet.in_memory import InMemoryWallet @@ -43,7 +43,7 @@ async def test_create_decode_verify(self): profile = InMemoryProfile.test_profile() wallet = InMemoryWallet(profile) - key_info = await wallet.create_signing_key(KeyType.ED25519) + key_info = await wallet.create_signing_key(ED25519) deco = await SignatureDecorator.create( Ping(), key_info.verkey, wallet, timestamp=None diff --git a/aries_cloudagent/messaging/jsonld/credential.py b/aries_cloudagent/messaging/jsonld/credential.py index 23813276b0..c584a83502 100644 --- a/aries_cloudagent/messaging/jsonld/credential.py +++ b/aries_cloudagent/messaging/jsonld/credential.py @@ -18,7 +18,7 @@ def did_key(verkey: str) -> str: if verkey.startswith("did:key:"): return verkey - return DIDKey.from_public_key_b58(verkey, KeyType.ED25519).did + return DIDKey.from_public_key_b58(verkey, ED25519).did def b64encode(str): @@ -76,7 +76,7 @@ async def jws_verify(session, verify_data, signature, public_key): wallet = session.inject(BaseWallet) verified = await wallet.verify_message( - jws_to_verify, decoded_signature, public_key, KeyType.ED25519 + jws_to_verify, decoded_signature, public_key, ED25519 ) return verified diff --git a/aries_cloudagent/messaging/jsonld/tests/test_credential.py b/aries_cloudagent/messaging/jsonld/tests/test_credential.py index 297d5a3b0e..d613ece328 100644 --- a/aries_cloudagent/messaging/jsonld/tests/test_credential.py +++ b/aries_cloudagent/messaging/jsonld/tests/test_credential.py @@ -13,7 +13,7 @@ from ....vc.ld_proofs import DocumentLoader from ....wallet.base import BaseWallet from ....wallet.in_memory import InMemoryWallet -from ....wallet.key_type import KeyType +from ....wallet.key_type import ED25519, KeyType from .. import credential as test_module from ..create_verify_data import DroppedAttributeError @@ -60,7 +60,7 @@ async def test_verify_jws_header(self): class TestOps(AsyncTestCase): async def setUp(self): self.wallet = InMemoryWallet(InMemoryProfile.test_profile()) - await self.wallet.create_signing_key(KeyType.ED25519, TEST_SEED) + await self.wallet.create_signing_key(ED25519, TEST_SEED) self.session = InMemoryProfile.test_session(bind={BaseWallet: self.wallet}) self.profile = self.session.profile diff --git a/aries_cloudagent/messaging/jsonld/tests/test_routes.py b/aries_cloudagent/messaging/jsonld/tests/test_routes.py index 129ac26515..84b66fc341 100644 --- a/aries_cloudagent/messaging/jsonld/tests/test_routes.py +++ b/aries_cloudagent/messaging/jsonld/tests/test_routes.py @@ -275,7 +275,7 @@ async def setUp(self): DocumentLoader, custom_document_loader ) self.did_info = await (await self.context.session()).wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519 + DIDMethod.SOV, ED25519 ) self.request_dict = { "context": self.context, diff --git a/aries_cloudagent/messaging/tests/test_agent_message.py b/aries_cloudagent/messaging/tests/test_agent_message.py index 4e1b87e28e..2c4f9f4021 100644 --- a/aries_cloudagent/messaging/tests/test_agent_message.py +++ b/aries_cloudagent/messaging/tests/test_agent_message.py @@ -72,7 +72,7 @@ class BadImplementationClass(AgentMessage): async def test_field_signature(self): session = InMemoryProfile.test_session() wallet = session.wallet - key_info = await wallet.create_signing_key(KeyType.ED25519) + key_info = await wallet.create_signing_key(ED25519) msg = SignedAgentMessage() msg.value = None diff --git a/aries_cloudagent/multitenant/tests/test_base.py b/aries_cloudagent/multitenant/tests/test_base.py index 6f7c7b7e78..fa29fc34e3 100644 --- a/aries_cloudagent/multitenant/tests/test_base.py +++ b/aries_cloudagent/multitenant/tests/test_base.py @@ -245,7 +245,7 @@ async def test_create_wallet_adds_wallet_route(self): verkey="test_verkey", metadata={"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_route_manager = async_mock.MagicMock() diff --git a/aries_cloudagent/protocols/connections/v1_0/manager.py b/aries_cloudagent/protocols/connections/v1_0/manager.py index d937b7ecb2..9fa1f897a0 100644 --- a/aries_cloudagent/protocols/connections/v1_0/manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/manager.py @@ -21,7 +21,7 @@ from ....wallet.did_info import DIDInfo from ....wallet.did_method import DIDMethod from ....wallet.error import WalletNotFoundError -from ....wallet.key_type import KeyType +from ....wallet.key_type import ED25519, KeyType from ....wallet.util import bytes_to_b58 from ...coordinate_mediation.v1_0.manager import MediationManager from ...discovery.v2_0.manager import V20DiscoveryMgr @@ -177,7 +177,7 @@ async def create_invitation( async with self.profile.session() as session: wallet = session.inject(BaseWallet) invitation_signing_key = await wallet.create_signing_key( - key_type=KeyType.ED25519 + key_type=ED25519 ) invitation_key = invitation_signing_key.verkey recipient_keys = [invitation_key] @@ -360,7 +360,7 @@ async def create_request( async with self.profile.session() as session: wallet = session.inject(BaseWallet) # Create new DID for connection - my_info = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + my_info = await wallet.create_local_did(DIDMethod.SOV, ED25519) connection.my_did = my_info.did # Idempotent; if routing has already been set up, no action taken @@ -467,9 +467,7 @@ async def receive_request( if connection.is_multiuse_invitation: async with self.profile.session() as session: wallet = session.inject(BaseWallet) - my_info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519 - ) + my_info = await wallet.create_local_did(DIDMethod.SOV, ED25519) new_connection = ConnRecord( invitation_key=connection_key, @@ -522,7 +520,7 @@ async def receive_request( else: # request from public did async with self.profile.session() as session: wallet = session.inject(BaseWallet) - my_info = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + my_info = await wallet.create_local_did(DIDMethod.SOV, ED25519) async with self.profile.session() as session: connection = await ConnRecord.retrieve_by_invitation_msg_id( @@ -613,7 +611,7 @@ async def create_response( else: async with self.profile.session() as session: wallet = session.inject(BaseWallet) - my_info = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + my_info = await wallet.create_local_did(DIDMethod.SOV, ED25519) connection.my_did = my_info.did # Idempotent; if routing has already been set up, no action taken @@ -831,7 +829,7 @@ async def create_static_connection( wallet = session.inject(BaseWallet) # seed and DID optional my_info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, my_seed, my_did + DIDMethod.SOV, ED25519, my_seed, my_did ) # must provide their DID and verkey if the seed is not known @@ -842,10 +840,10 @@ async def create_static_connection( if not their_did: their_did = seed_to_did(their_seed) if not their_verkey: - their_verkey_bin, _ = create_keypair(KeyType.ED25519, their_seed.encode()) + their_verkey_bin, _ = create_keypair(ED25519, their_seed.encode()) their_verkey = bytes_to_b58(their_verkey_bin) their_info = DIDInfo( - their_did, their_verkey, {}, method=DIDMethod.SOV, key_type=KeyType.ED25519 + their_did, their_verkey, {}, method=DIDMethod.SOV, key_type=ED25519 ) # Create connection record @@ -1106,7 +1104,7 @@ async def establish_inbound( my_info = await wallet.get_local_did(connection.my_did) else: # Create new DID for connection - my_info = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + my_info = await wallet.create_local_did(DIDMethod.SOV, ED25519) connection.my_did = my_info.did try: diff --git a/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_response.py b/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_response.py index 98beb344fd..2973ade36c 100644 --- a/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_response.py +++ b/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_response.py @@ -2,7 +2,7 @@ from asynctest import TestCase as AsyncTestCase -from ......wallet.key_type import KeyType +from ......wallet.key_type import ED25519, KeyType from ......connections.models.diddoc import ( DIDDoc, PublicKey, @@ -108,7 +108,7 @@ async def test_make_model(self): ) session = InMemoryProfile.test_session() wallet = session.wallet - key_info = await wallet.create_signing_key(KeyType.ED25519) + key_info = await wallet.create_signing_key(ED25519) await connection_response.sign_field("connection", key_info.verkey, wallet) data = connection_response.serialize() model_instance = ConnectionResponse.deserialize(data) diff --git a/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py index 80efb456bf..4437ab0d86 100644 --- a/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py @@ -121,7 +121,7 @@ async def test_create_invitation_public_and_multi_use_fails(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) with self.assertRaises(ConnectionManagerError): await self.manager.create_invitation(public=True, multi_use=True) @@ -167,7 +167,7 @@ async def test_create_invitation_public(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) connect_record, connect_invite = await self.manager.create_invitation( public=True, my_endpoint="testendpoint" @@ -232,7 +232,7 @@ async def test_create_invitation_recipient_routing_endpoint(self): async with self.profile.session() as session: await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -275,7 +275,7 @@ async def test_create_invitation_public_and_metadata_fails(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) with self.assertRaises(ConnectionManagerError): await self.manager.create_invitation( @@ -436,7 +436,7 @@ async def test_create_request_my_did(self): async with self.profile.session() as session: await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=self.test_did, ) @@ -481,7 +481,7 @@ async def test_create_request_multitenant(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) await self.manager.create_request( ConnRecord( @@ -534,7 +534,7 @@ async def test_create_request_mediation_id(self): verkey=self.test_verkey, metadata={}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) create_local_did.return_value = did_info await self.manager.create_request( @@ -542,7 +542,7 @@ async def test_create_request_mediation_id(self): mediation_id=mediation_record.mediation_id, my_endpoint=self.test_endpoint, ) - create_local_did.assert_called_once_with(DIDMethod.SOV, KeyType.ED25519) + create_local_did.assert_called_once_with(DIDMethod.SOV, ED25519) create_did_document.assert_called_once_with( self.manager, did_info, @@ -586,14 +586,14 @@ async def test_create_request_default_mediator(self): verkey=self.test_verkey, metadata={}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) create_local_did.return_value = did_info await self.manager.create_request( record, my_endpoint=self.test_endpoint, ) - create_local_did.assert_called_once_with(DIDMethod.SOV, KeyType.ED25519) + create_local_did.assert_called_once_with(DIDMethod.SOV, ED25519) create_did_document.assert_called_once_with( self.manager, did_info, @@ -615,7 +615,7 @@ async def test_receive_request_public_did_oob_invite(self): ) await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=self.test_did, ) @@ -655,7 +655,7 @@ async def test_receive_request_public_did_conn_invite(self): ) await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=self.test_did, ) @@ -690,7 +690,7 @@ async def test_receive_request_public_did_no_did_doc(self): ) await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=self.test_did, ) @@ -721,7 +721,7 @@ async def test_receive_request_public_did_wrong_did(self): ) await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=self.test_did, ) @@ -750,7 +750,7 @@ async def test_receive_request_public_did_no_public_invites(self): async with self.profile.session() as session: await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=self.test_did, ) @@ -781,7 +781,7 @@ async def test_receive_request_public_did_no_auto_accept(self): ) await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=self.test_did, ) @@ -868,7 +868,7 @@ async def test_create_response_multitenant(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) await self.manager.create_response( ConnRecord( @@ -942,7 +942,7 @@ async def test_create_response_mediation(self): verkey=self.test_verkey, metadata={}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) create_local_did.return_value = did_info await self.manager.create_response( @@ -950,7 +950,7 @@ async def test_create_response_mediation(self): mediation_id=mediation_record.mediation_id, my_endpoint=self.test_endpoint, ) - create_local_did.assert_called_once_with(DIDMethod.SOV, KeyType.ED25519) + create_local_did.assert_called_once_with(DIDMethod.SOV, ED25519) create_did_document.assert_called_once_with( self.manager, did_info, @@ -1267,7 +1267,7 @@ async def test_create_static_connection_multitenant(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) await self.manager.create_static_connection( @@ -1300,7 +1300,7 @@ async def test_create_static_connection_multitenant_auto_disclose_features(self) self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) await self.manager.create_static_connection( my_did=self.test_did, @@ -1332,7 +1332,7 @@ async def test_create_static_connection_multitenant_mediator(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) # With default mediator @@ -1360,7 +1360,7 @@ async def test_create_static_connection_multitenant_mediator(self): self.test_target_verkey, {}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) create_did_document.assert_has_calls( [ @@ -1538,7 +1538,7 @@ async def test_resolve_inbound_connection(self): self.test_verkey, {"posted": True}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_mgr_find_conn.return_value = mock_conn @@ -1590,7 +1590,7 @@ async def test_create_did_document(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_conn = async_mock.MagicMock( @@ -1623,7 +1623,7 @@ async def test_create_did_document_not_active(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_conn = async_mock.MagicMock( @@ -1651,7 +1651,7 @@ async def test_create_did_document_no_services(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_conn = async_mock.MagicMock( @@ -1686,7 +1686,7 @@ async def test_create_did_document_no_service_endpoint(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_conn = async_mock.MagicMock( @@ -1724,7 +1724,7 @@ async def test_create_did_document_no_service_recip_keys(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_conn = async_mock.MagicMock( @@ -1770,7 +1770,7 @@ async def test_create_did_document_mediation(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mediation_record = MediationRecord( role=MediationRecord.ROLE_CLIENT, @@ -1796,7 +1796,7 @@ async def test_create_did_document_multiple_mediators(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mediation_record1 = MediationRecord( role=MediationRecord.ROLE_CLIENT, @@ -1829,7 +1829,7 @@ async def test_create_did_document_mediation_svc_endpoints_overwritten(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mediation_record = MediationRecord( role=MediationRecord.ROLE_CLIENT, @@ -1864,7 +1864,7 @@ async def test_get_connection_targets_conn_invitation_no_did(self): async with self.profile.session() as session: local_did = await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -1923,7 +1923,7 @@ async def test_get_connection_targets_retrieve_connection(self): async with self.profile.session() as session: local_did = await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -1976,7 +1976,7 @@ async def test_get_conn_targets_conn_invitation_no_cache(self): self.context.injector.clear_binding(BaseCache) local_did = await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -2026,7 +2026,7 @@ async def test_fetch_connection_targets_conn_invitation_did_no_resolver(self): self.context.injector.bind_instance(DIDResolver, DIDResolver([])) await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -2072,7 +2072,7 @@ async def test_fetch_connection_targets_conn_invitation_did_resolver(self): local_did = await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -2140,7 +2140,7 @@ async def test_fetch_connection_targets_conn_invitation_btcr_resolver(self): self.context.injector.bind_instance(DIDResolver, self.resolver) local_did = await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=did_doc.id, metadata=None, @@ -2205,7 +2205,7 @@ async def test_fetch_connection_targets_conn_invitation_btcr_without_services(se local_did = await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=did_doc.id, metadata=None, @@ -2245,7 +2245,7 @@ async def test_fetch_connection_targets_conn_invitation_no_didcomm_services(self self.context.injector.bind_instance(DIDResolver, self.resolver) await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=did_doc.id, metadata=None, @@ -2291,7 +2291,7 @@ async def test_fetch_connection_targets_conn_invitation_unsupported_key_type(sel self.context.injector.bind_instance(DIDResolver, self.resolver) local_did = await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=did_doc.id, metadata=None, @@ -2320,7 +2320,7 @@ async def test_fetch_connection_targets_oob_invitation_svc_did_no_resolver(self) self.context.injector.bind_instance(DIDResolver, DIDResolver([])) await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -2361,7 +2361,7 @@ async def test_fetch_connection_targets_oob_invitation_svc_did_resolver(self): local_did = await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -2406,7 +2406,7 @@ async def test_fetch_connection_targets_oob_invitation_svc_block_resolver(self): local_did = await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -2420,7 +2420,7 @@ async def test_fetch_connection_targets_oob_invitation_svc_block_resolver(self): service_endpoint=self.test_endpoint, recipient_keys=[ DIDKey.from_public_key_b58( - self.test_target_verkey, KeyType.ED25519 + self.test_target_verkey, ED25519 ).did ], routing_keys=[], @@ -2452,7 +2452,7 @@ async def test_fetch_connection_targets_conn_initiator_completed_no_their_did(se async with self.profile.session() as session: await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -2469,7 +2469,7 @@ async def test_fetch_connection_targets_conn_completed_their_did(self): async with self.profile.session() as session: local_did = await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -2500,7 +2500,7 @@ async def test_fetch_connection_targets_conn_no_invi_with_their_did(self): async with self.profile.session() as session: local_did = await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -2555,7 +2555,7 @@ async def test_establish_inbound(self): async with self.profile.session() as session: await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -2585,7 +2585,7 @@ async def test_establish_inbound_conn_rec_no_my_did(self): async with self.profile.session() as session: await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -2614,7 +2614,7 @@ async def test_establish_inbound_no_conn_record(self): async with self.profile.session() as session: await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, @@ -2643,7 +2643,7 @@ async def test_establish_inbound_router_not_ready(self): async with self.profile.session() as session: await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=self.test_seed, did=self.test_did, metadata=None, diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py index f525dd0088..7a67b57369 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py @@ -112,7 +112,7 @@ async def _create_routing_did(self, session: ProfileSession) -> DIDInfo: storage = session.inject(BaseStorage) info = await wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, metadata={"type": "routing_did"}, ) record = StorageRecord( diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/normalization.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/normalization.py index 1d8610e60c..c105aa05d5 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/normalization.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/normalization.py @@ -16,4 +16,4 @@ def normalize_from_public_key(key: str): if key.startswith("did:key:"): return key - return DIDKey.from_public_key_b58(key, KeyType.ED25519).did + return DIDKey.from_public_key_b58(key, ED25519).did diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/route_manager.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/route_manager.py index 07da03fd51..4e03d929a9 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/route_manager.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/route_manager.py @@ -40,7 +40,7 @@ async def get_or_create_my_did( async with profile.session() as session: wallet = session.inject(BaseWallet) # Create new DID for connection - my_info = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + my_info = await wallet.create_local_did(DIDMethod.SOV, ED25519) conn_record.my_did = my_info.did await conn_record.save(session, reason="Connection my did created") else: diff --git a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py index ff76d6a9c6..34acf504ba 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py @@ -88,7 +88,7 @@ async def setUp(self): wallet = self.session.wallet self.did_info = await wallet.create_local_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519 + method=DIDMethod.SOV, key_type=ED25519 ) self.did_doc_attach = AttachDecorator.data_base64(self.did_doc().serialize()) diff --git a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_response_handler.py b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_response_handler.py index a161b5f325..79e0af0782 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_response_handler.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_response_handler.py @@ -66,7 +66,7 @@ async def setUp(self): wallet = (await self.ctx.session()).wallet self.did_info = await wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) self.did_doc_attach = AttachDecorator.data_base64(self.did_doc().serialize()) diff --git a/aries_cloudagent/protocols/didexchange/v1_0/manager.py b/aries_cloudagent/protocols/didexchange/v1_0/manager.py index 587e6b56b5..12e6726b87 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/manager.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/manager.py @@ -285,7 +285,7 @@ async def create_request( wallet = session.inject(BaseWallet) my_info = await wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) conn_rec.my_did = my_info.did @@ -418,7 +418,7 @@ async def receive_request( wallet = session.inject(BaseWallet) my_info = await wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) new_conn_rec = ConnRecord( @@ -487,7 +487,7 @@ async def receive_request( wallet = session.inject(BaseWallet) my_info = await wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) auto_accept = bool( @@ -581,7 +581,7 @@ async def create_response( wallet = session.inject(BaseWallet) my_info = await wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) conn_rec.my_did = my_info.did diff --git a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py index a7ad4f405f..b3dae6e2a9 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py @@ -60,7 +60,7 @@ async def setUp(self): self.wallet = InMemoryProfile.test_session().wallet self.did_info = await self.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) did_doc_attach = AttachDecorator.data_base64(self.make_did_doc().serialize()) @@ -117,7 +117,7 @@ async def setUp(self): self.wallet = InMemoryProfile.test_session().wallet self.did_info = await self.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) did_doc_attach = AttachDecorator.data_base64(self.make_did_doc().serialize()) diff --git a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py index 9cf32b8359..78b8443255 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py @@ -59,7 +59,7 @@ async def setUp(self): self.wallet = InMemoryProfile.test_session().wallet self.did_info = await self.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) did_doc_attach = AttachDecorator.data_base64(self.make_did_doc().serialize()) @@ -113,7 +113,7 @@ async def setUp(self): self.wallet = InMemoryProfile.test_session().wallet self.did_info = await self.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) did_doc_attach = AttachDecorator.data_base64(self.make_did_doc().serialize()) diff --git a/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py index 131d87670e..8cdbcbc316 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py @@ -115,7 +115,7 @@ async def setUp(self): async with self.profile.session() as session: self.did_info = await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) self.ledger = async_mock.create_autospec(BaseLedger) @@ -142,7 +142,7 @@ async def setUp(self): self.oob_manager = OutOfBandManager(self.profile) self.test_mediator_routing_keys = [ DIDKey.from_public_key_b58( - "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRR", KeyType.ED25519 + "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRR", ED25519 ).did ] self.test_mediator_conn_id = "mediator-conn-id" @@ -203,7 +203,7 @@ async def test_receive_invitation_oob_public_did(self): public_did_info = None await session.wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) public_did_info = await session.wallet.get_public_did() with async_mock.patch.object( @@ -304,7 +304,7 @@ async def test_create_request_implicit_use_public_did(self): async with self.profile.session() as session: info_public = await session.wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) conn_rec = await self.manager.create_request_implicit( their_public_did=TestConfig.test_target_did, @@ -375,7 +375,7 @@ async def test_create_request_multitenant(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_attach_deco.data_base64 = async_mock.MagicMock( return_value=async_mock.MagicMock( @@ -503,7 +503,7 @@ async def test_receive_request_explicit_public_did(self): await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=TestConfig.test_did, ) @@ -602,7 +602,7 @@ async def test_receive_request_invi_not_found(self): await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=TestConfig.test_did, ) @@ -634,7 +634,7 @@ async def test_receive_request_public_did_no_did_doc_attachment(self): await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=TestConfig.test_did, ) @@ -694,7 +694,7 @@ async def test_receive_request_public_did_x_not_public(self): await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=TestConfig.test_did, ) @@ -736,7 +736,7 @@ async def test_receive_request_public_did_x_wrong_did(self): await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=TestConfig.test_did, ) @@ -803,7 +803,7 @@ async def test_receive_request_public_did_x_did_doc_attach_bad_sig(self): await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=TestConfig.test_did, ) @@ -864,7 +864,7 @@ async def test_receive_request_public_did_no_public_invites(self): await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=TestConfig.test_did, ) @@ -911,7 +911,7 @@ async def test_receive_request_public_did_no_auto_accept(self): await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=TestConfig.test_did, ) @@ -1004,7 +1004,7 @@ async def test_receive_request_peer_did(self): await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=TestConfig.test_did, ) @@ -1078,7 +1078,7 @@ async def test_receive_request_peer_did_not_found_x(self): await session.wallet.create_local_did( method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, seed=None, did=TestConfig.test_did, ) @@ -1254,7 +1254,7 @@ async def test_create_response_multitenant(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_create_did_doc.return_value = async_mock.MagicMock( serialize=async_mock.MagicMock() @@ -1671,7 +1671,7 @@ async def test_create_did_document(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_conn = async_mock.MagicMock( @@ -1705,7 +1705,7 @@ async def test_create_did_document_not_completed(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_conn = async_mock.MagicMock( @@ -1733,7 +1733,7 @@ async def test_create_did_document_no_services(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_conn = async_mock.MagicMock( @@ -1768,7 +1768,7 @@ async def test_create_did_document_no_service_endpoint(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_conn = async_mock.MagicMock( @@ -1806,7 +1806,7 @@ async def test_create_did_document_no_service_recip_keys(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_conn = async_mock.MagicMock( @@ -1852,7 +1852,7 @@ async def test_did_key_storage(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) did_doc = self.make_did_doc( @@ -1898,7 +1898,7 @@ async def test_resolve_did_document_error(self): async with self.profile.session() as session: await session.wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) public_did_info = await session.wallet.get_public_did() with async_mock.patch.object( diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py index edad031889..12f898b3be 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py @@ -125,7 +125,7 @@ async def setUp(self): self.wallet: BaseWallet = session.inject_or(BaseWallet) await self.wallet.create_local_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, did="DJGEjaMunDtFtBVrn1qJMT", metadata={"meta": "data"}, ) diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py index d91b1ff8b8..4d40885c0d 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py @@ -437,7 +437,7 @@ async def test_endorse_transaction_response(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), @@ -516,7 +516,7 @@ async def test_endorse_transaction_response_not_found_x(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), @@ -545,7 +545,7 @@ async def test_endorse_transaction_response_base_model_x(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), @@ -580,7 +580,7 @@ async def test_endorse_transaction_response_no_jobs_x(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), @@ -617,7 +617,7 @@ async def skip_test_endorse_transaction_response_no_ledger_x(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), @@ -672,7 +672,7 @@ async def test_endorse_transaction_response_wrong_my_job_x(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), @@ -715,7 +715,7 @@ async def skip_test_endorse_transaction_response_ledger_x(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), @@ -773,7 +773,7 @@ async def test_endorse_transaction_response_txn_mgr_x(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), @@ -825,7 +825,7 @@ async def test_refuse_transaction_response(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), @@ -883,7 +883,7 @@ async def test_refuse_transaction_response_not_found_x(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), @@ -913,7 +913,7 @@ async def test_refuse_transaction_response_conn_base_model_x(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), @@ -948,7 +948,7 @@ async def test_refuse_transaction_response_no_jobs_x(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), @@ -985,7 +985,7 @@ async def test_refuse_transaction_response_wrong_my_job_x(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), @@ -1028,7 +1028,7 @@ async def test_refuse_transaction_response_txn_mgr_x(self): "verkey", {"meta": "data"}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) ) ), diff --git a/aries_cloudagent/protocols/introduction/v0_1/tests/test_service.py b/aries_cloudagent/protocols/introduction/v0_1/tests/test_service.py index a2bff3f785..5947030e4b 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/tests/test_service.py +++ b/aries_cloudagent/protocols/introduction/v0_1/tests/test_service.py @@ -36,12 +36,10 @@ def setUp(self): _type="did-communication", did=TEST_DID, recipient_keys=[ - DIDKey.from_public_key_b58(TEST_VERKEY, KeyType.ED25519).did + DIDKey.from_public_key_b58(TEST_VERKEY, ED25519).did ], routing_keys=[ - DIDKey.from_public_key_b58( - TEST_ROUTE_VERKEY, KeyType.ED25519 - ).did + DIDKey.from_public_key_b58(TEST_ROUTE_VERKEY, ED25519).did ], service_endpoint=TEST_ENDPOINT, ) 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 796e71e67f..66177376a2 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 @@ -64,13 +64,13 @@ AuthenticationProofPurpose.term, } SUPPORTED_ISSUANCE_SUITES = {Ed25519Signature2018} -SIGNATURE_SUITE_KEY_TYPE_MAPPING = {Ed25519Signature2018: KeyType.ED25519} +SIGNATURE_SUITE_KEY_TYPE_MAPPING = {Ed25519Signature2018: ED25519} # We only want to add bbs suites to supported if the module is installed if BbsBlsSignature2020.BBS_SUPPORTED: SUPPORTED_ISSUANCE_SUITES.add(BbsBlsSignature2020) - SIGNATURE_SUITE_KEY_TYPE_MAPPING[BbsBlsSignature2020] = KeyType.BLS12381G2 + SIGNATURE_SUITE_KEY_TYPE_MAPPING[BbsBlsSignature2020] = BLS12381G2 PROOF_TYPE_SIGNATURE_SUITE_MAPPING = { diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py index c4666a679e..53ea35b095 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py @@ -218,7 +218,7 @@ async def test_assert_can_issue_with_id_and_proof_type(self): verkey="verkey", metadata={}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_did_info.return_value = did_info await self.handler._assert_can_issue_with_id_and_proof_type( @@ -230,7 +230,7 @@ async def test_assert_can_issue_with_id_and_proof_type(self): verkey="verkey", metadata={}, method=DIDMethod.SOV, - key_type=KeyType.BLS12381G2, + key_type=BLS12381G2, ) mock_did_info.return_value = invalid_did_info with self.assertRaises(V20CredFormatError) as context: @@ -281,7 +281,7 @@ async def test_get_suite_for_detail(self): assert type(suite) == Ed25519Signature2018 assert suite.verification_method == DIDKey.from_did(TEST_DID_KEY).key_id assert suite.proof == {"created": LD_PROOF_VC_DETAIL["options"]["created"]} - assert suite.key_pair.key_type == KeyType.ED25519 + assert suite.key_pair.key_type == ED25519 assert suite.key_pair.public_key_base58 == mock_did_info.return_value.verkey mock_can_issue.assert_called_once_with( @@ -303,7 +303,7 @@ async def test_get_suite(self): assert type(suite) == BbsBlsSignature2020 assert suite.verification_method == "verification_method" assert suite.proof == proof - assert suite.key_pair.key_type == KeyType.BLS12381G2 + assert suite.key_pair.key_type == BLS12381G2 assert suite.key_pair.public_key_base58 == did_info.verkey suite = await self.handler._get_suite( @@ -316,7 +316,7 @@ async def test_get_suite(self): assert type(suite) == Ed25519Signature2018 assert suite.verification_method == "verification_method" assert suite.proof == proof - assert suite.key_pair.key_type == KeyType.ED25519 + assert suite.key_pair.key_type == ED25519 assert suite.key_pair.public_key_base58 == did_info.verkey async def test_get_verification_method(self): diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/manager.py b/aries_cloudagent/protocols/out_of_band/v1_0/manager.py index 4bdfcc39a6..49fd1988e4 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/manager.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/manager.py @@ -19,7 +19,7 @@ from ....storage.error import StorageNotFoundError from ....transport.inbound.receipt import MessageReceipt from ....wallet.base import BaseWallet -from ....wallet.key_type import KeyType +from ....wallet.key_type import ED25519 from ...connections.v1_0.manager import ConnectionManager from ...connections.v1_0.messages.connection_invitation import ConnectionInvitation from ...didcomm_prefix import DIDCommPrefix @@ -265,7 +265,7 @@ async def create_invitation( # Create and store new key for exchange async with self.profile.session() as session: wallet = session.inject(BaseWallet) - connection_key = await wallet.create_signing_key(KeyType.ED25519) + connection_key = await wallet.create_signing_key(ED25519) our_recipient_key = connection_key.verkey @@ -310,7 +310,7 @@ async def create_invitation( routing_keys = [ key if len(key.split(":")) == 3 - else DIDKey.from_public_key_b58(key, KeyType.ED25519).did + else DIDKey.from_public_key_b58(key, ED25519).did for key in routing_keys ] @@ -326,9 +326,7 @@ async def create_invitation( _id="#inline", _type="did-communication", recipient_keys=[ - DIDKey.from_public_key_b58( - connection_key.verkey, KeyType.ED25519 - ).did + DIDKey.from_public_key_b58(connection_key.verkey, ED25519).did ], service_endpoint=my_endpoint, routing_keys=routing_keys, @@ -514,7 +512,7 @@ async def receive_invitation( # Create and store new key for connectionless exchange async with self.profile.session() as session: wallet = session.inject(BaseWallet) - connection_key = await wallet.create_signing_key(KeyType.ED25519) + connection_key = await wallet.create_signing_key(ED25519) oob_record.our_recipient_key = connection_key.verkey oob_record.our_service = ServiceDecorator( recipient_keys=[connection_key.verkey], @@ -752,11 +750,11 @@ async def _perform_handshake( "id": "#inline", "type": "did-communication", "recipientKeys": [ - DIDKey.from_public_key_b58(key, KeyType.ED25519).did + DIDKey.from_public_key_b58(key, ED25519).did for key in recipient_keys ], "routingKeys": [ - DIDKey.from_public_key_b58(key, KeyType.ED25519).did + DIDKey.from_public_key_b58(key, ED25519).did for key in routing_keys ], "serviceEndpoint": endpoint, diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/messages/tests/test_invitation.py b/aries_cloudagent/protocols/out_of_band/v1_0/messages/tests/test_invitation.py index 5340dd66dc..f1e215744c 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/messages/tests/test_invitation.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/messages/tests/test_invitation.py @@ -80,9 +80,7 @@ def test_wrap_serde(self): service = Service( _id="#inline", _type=DID_COMM, - recipient_keys=[ - DIDKey.from_public_key_b58(TEST_VERKEY, KeyType.ED25519).did - ], + recipient_keys=[DIDKey.from_public_key_b58(TEST_VERKEY, ED25519).did], service_endpoint="http://1.2.3.4:8080/service", ) data_deser = { @@ -110,9 +108,7 @@ def test_url_round_trip(self): service = Service( _id="#inline", _type=DID_COMM, - recipient_keys=[ - DIDKey.from_public_key_b58(TEST_VERKEY, KeyType.ED25519).did - ], + recipient_keys=[DIDKey.from_public_key_b58(TEST_VERKEY, ED25519).did], service_endpoint="http://1.2.3.4:8080/service", ) invi_msg = InvitationMessage( diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py index 738e295a1f..1f082ba6df 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py @@ -67,7 +67,7 @@ from .....wallet.did_info import DIDInfo, KeyInfo from .....wallet.did_method import DIDMethod from .....wallet.in_memory import InMemoryWallet -from .....wallet.key_type import KeyType +from .....wallet.key_type import ED25519, KeyType from ....connections.v1_0.messages.connection_invitation import ConnectionInvitation from ....didcomm_prefix import DIDCommPrefix from ....issue_credential.v1_0.message_types import CREDENTIAL_OFFER @@ -379,7 +379,7 @@ async def test_create_invitation_handshake_succeeds(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) invi_rec = await self.manager.create_invitation( my_endpoint=TestConfig.test_endpoint, @@ -411,7 +411,7 @@ async def test_create_invitation_multitenant_local(self): self.multitenant_mgr, "get_default_mediator" ) as mock_get_default_mediator: mock_wallet_create_signing_key.return_value = KeyInfo( - TestConfig.test_verkey, None, KeyType.ED25519 + TestConfig.test_verkey, None, ED25519 ) mock_get_default_mediator.return_value = MediationRecord() await self.manager.create_invitation( @@ -439,7 +439,7 @@ async def test_create_invitation_multitenant_public(self): self.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) await self.manager.create_invitation( hs_protos=[HSProto.RFC23], @@ -514,7 +514,7 @@ async def test_create_invitation_attachment_v1_0_cred_offer(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_retrieve_cxid.return_value = async_mock.MagicMock( credential_offer_dict=self.CRED_OFFER_V1 @@ -548,7 +548,7 @@ async def test_create_invitation_attachment_v1_0_cred_offer_no_handshake(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_retrieve_cxid.return_value = async_mock.MagicMock( credential_offer_dict=self.CRED_OFFER_V1 @@ -586,7 +586,7 @@ async def test_create_invitation_attachment_v2_0_cred_offer(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_retrieve_cxid_v1.side_effect = test_module.StorageNotFoundError() mock_retrieve_cxid_v2.return_value = async_mock.MagicMock( @@ -624,7 +624,7 @@ async def test_create_invitation_attachment_present_proof_v1_0(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_retrieve_pxid.return_value = async_mock.MagicMock( presentation_request_dict=self.PRES_REQ_V1 @@ -663,7 +663,7 @@ async def test_create_invitation_attachment_present_proof_v2_0(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_retrieve_pxid_1.side_effect = StorageNotFoundError() mock_retrieve_pxid_2.return_value = async_mock.MagicMock( @@ -751,7 +751,7 @@ async def test_create_invitation_attachment_x(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) with self.assertRaises(OutOfBandManagerError) as context: await self.manager.create_invitation( @@ -807,7 +807,7 @@ async def test_create_invitation_peer_did(self): assert ( service["routingKeys"][0] == DIDKey.from_public_key_b58( - self.test_mediator_routing_keys[0], KeyType.ED25519 + self.test_mediator_routing_keys[0], ED25519 ).did ) assert service["serviceEndpoint"] == self.test_mediator_endpoint @@ -835,7 +835,7 @@ async def test_create_invitation_x_public_metadata(self): TestConfig.test_verkey, None, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) with self.assertRaises(OutOfBandManagerError) as context: await self.manager.create_invitation( @@ -1294,7 +1294,7 @@ async def test_receive_invitation_connection_protocol(self): recipient_keys=[ DIDKey.from_public_key_b58( "9WCgWKUaAJj3VWxxtzvvMQN3AoFxoBtBDo9ntwJnVVCC", - KeyType.ED25519, + ED25519, ).did ], routing_keys=[], @@ -1564,7 +1564,7 @@ async def test_request_attach_oob_message_processor_connectionless(self): async_mock.CoroutineMock(), ) as mock_service_decorator_from_service: mock_create_signing_key.return_value = KeyInfo( - verkey="a-verkey", metadata={}, key_type=KeyType.ED25519 + verkey="a-verkey", metadata={}, key_type=ED25519 ) mock_service_decorator_from_service.return_value = mock_service_decorator oob_invitation = InvitationMessage( @@ -1581,7 +1581,7 @@ async def test_request_attach_oob_message_processor_connectionless(self): assert oob_record.our_service assert oob_record.state == OobRecord.STATE_PREPARE_RESPONSE - mock_create_signing_key.assert_called_once_with(KeyType.ED25519) + mock_create_signing_key.assert_called_once_with(ED25519) mock_oob_processor.handle_message.assert_called_once_with( self.profile, [attachment.content for attachment in requests_attach], @@ -1697,10 +1697,10 @@ async def test_service_decorator_from_service_object(self): oob_service = OobService( service_endpoint=TestConfig.test_endpoint, recipient_keys=[ - DIDKey.from_public_key_b58(TestConfig.test_verkey, KeyType.ED25519).did + DIDKey.from_public_key_b58(TestConfig.test_verkey, ED25519).did ], routing_keys=[ - DIDKey.from_public_key_b58(verkey, KeyType.ED25519).did + DIDKey.from_public_key_b58(verkey, ED25519).did for verkey in self.test_mediator_routing_keys ], ) 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 638ce0fa3e..79a1aa8deb 100644 --- a/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py +++ b/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py @@ -73,14 +73,14 @@ class DIFPresExchHandler: """Base Presentation Exchange Handler.""" ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING = { - Ed25519Signature2018: KeyType.ED25519, + Ed25519Signature2018: ED25519, } if BbsBlsSignature2020.BBS_SUPPORTED: - ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING[BbsBlsSignature2020] = KeyType.BLS12381G2 + ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING[BbsBlsSignature2020] = BLS12381G2 DERIVE_SIGNATURE_SUITE_KEY_TYPE_MAPPING = { - BbsBlsSignatureProof2020: KeyType.BLS12381G2, + BbsBlsSignatureProof2020: BLS12381G2, } PROOF_TYPE_SIGNATURE_SUITE_MAPPING = { suite.signature_type: suite @@ -196,9 +196,9 @@ async def get_sign_key_credential_subject_id( issuer_id = None filtered_creds_list = [] if self.proof_type == BbsBlsSignature2020.signature_type: - reqd_key_type = KeyType.BLS12381G2 + reqd_key_type = BLS12381G2 else: - reqd_key_type = KeyType.ED25519 + reqd_key_type = ED25519 for cred in applicable_creds: if cred.subject_ids and len(cred.subject_ids) > 0: if not issuer_id: diff --git a/aries_cloudagent/protocols/present_proof/dif/tests/test_pres_exch_handler.py b/aries_cloudagent/protocols/present_proof/dif/tests/test_pres_exch_handler.py index 87587eb674..110252fd97 100644 --- a/aries_cloudagent/protocols/present_proof/dif/tests/test_pres_exch_handler.py +++ b/aries_cloudagent/protocols/present_proof/dif/tests/test_pres_exch_handler.py @@ -79,11 +79,11 @@ async def setup_tuple(profile): async with profile.session() as session: wallet = session.inject_or(BaseWallet) await wallet.create_local_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519, did="WgWxqztrNooG92RXvxSTWv" + method=DIDMethod.SOV, key_type=ED25519, did="WgWxqztrNooG92RXvxSTWv" ) await wallet.create_local_did( method=DIDMethod.KEY, - key_type=KeyType.BLS12381G2, + key_type=BLS12381G2, ) creds, pds = get_test_data() return creds, pds @@ -2032,7 +2032,7 @@ async def test_get_sign_key_credential_subject_id(self, profile): verkey="verkey", metadata={}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_did_info.return_value = did_info ( @@ -2097,7 +2097,7 @@ async def test_get_sign_key_credential_subject_id_error(self, profile): verkey="verkey", metadata={}, method=DIDMethod.SOV, - key_type=KeyType.ED25519, + key_type=ED25519, ) mock_did_info.return_value = did_info with pytest.raises(DIFPresExchError): @@ -2165,7 +2165,7 @@ async def test_get_sign_key_credential_subject_id_bbsbls(self, profile): verkey="verkey", metadata={}, method=DIDMethod.KEY, - key_type=KeyType.BLS12381G2, + key_type=BLS12381G2, ) mock_did_info.return_value = did_info ( @@ -2256,7 +2256,7 @@ async def test_create_vp_no_issuer(self, profile, setup_tuple): verkey="verkey", metadata={}, method=DIDMethod.KEY, - key_type=KeyType.BLS12381G2, + key_type=BLS12381G2, ) mock_did_info.return_value = did_info vp = await dif_pres_exch_handler.create_vp( @@ -2316,7 +2316,7 @@ async def test_create_vp_with_bbs_suite(self, profile, setup_tuple): verkey="verkey", metadata={}, method=DIDMethod.KEY, - key_type=KeyType.BLS12381G2, + key_type=BLS12381G2, ) mock_did_info.return_value = did_info vp = await dif_pres_exch_handler.create_vp( @@ -2370,7 +2370,7 @@ async def test_create_vp_no_issuer_with_bbs_suite(self, profile, setup_tuple): verkey="verkey", metadata={}, method=DIDMethod.KEY, - key_type=KeyType.BLS12381G2, + key_type=BLS12381G2, ) mock_did_info.return_value = did_info vp = await dif_pres_exch_handler.create_vp( 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 9efff76b16..c69b906085 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 @@ -56,14 +56,14 @@ class DIFPresFormatHandler(V20PresFormatHandler): format = V20PresFormat.Format.DIF ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING = { - Ed25519Signature2018: KeyType.ED25519, + Ed25519Signature2018: ED25519, } if BbsBlsSignature2020.BBS_SUPPORTED: - ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING[BbsBlsSignature2020] = KeyType.BLS12381G2 + ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING[BbsBlsSignature2020] = BLS12381G2 ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING[ BbsBlsSignatureProof2020 - ] = KeyType.BLS12381G2 + ] = BLS12381G2 async def _get_all_suites(self, wallet: BaseWallet): """Get all supported suites for verifying presentation.""" diff --git a/aries_cloudagent/transport/tests/test_pack_format.py b/aries_cloudagent/transport/tests/test_pack_format.py index 1ca7b7f46f..e9d9e5c0e2 100644 --- a/aries_cloudagent/transport/tests/test_pack_format.py +++ b/aries_cloudagent/transport/tests/test_pack_format.py @@ -140,7 +140,7 @@ async def test_fallback(self): async def test_encode_decode(self): local_did = await self.wallet.create_local_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=self.test_seed + method=DIDMethod.SOV, key_type=ED25519, seed=self.test_seed ) serializer = PackWireFormat() recipient_keys = (local_did.verkey,) @@ -174,10 +174,10 @@ async def test_encode_decode(self): async def test_forward(self): local_did = await self.wallet.create_local_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=self.test_seed + method=DIDMethod.SOV, key_type=ED25519, seed=self.test_seed ) router_did = await self.wallet.create_local_did( - method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=self.test_routing_seed + method=DIDMethod.SOV, key_type=ED25519, seed=self.test_routing_seed ) serializer = PackWireFormat() recipient_keys = (local_did.verkey,) diff --git a/aries_cloudagent/utils/tests/test_outofband.py b/aries_cloudagent/utils/tests/test_outofband.py index 2029553471..e8f519479c 100644 --- a/aries_cloudagent/utils/tests/test_outofband.py +++ b/aries_cloudagent/utils/tests/test_outofband.py @@ -12,7 +12,7 @@ class TestOutOfBand(TestCase): test_did = "55GkHamhTU1ZbTbV2ab9DE" test_verkey = "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx" test_did_info = DIDInfo( - test_did, test_verkey, None, method=DIDMethod.SOV, key_type=KeyType.ED25519 + test_did, test_verkey, None, method=DIDMethod.SOV, key_type=ED25519 ) def test_serialize_oob(self): 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 705ca244be..4ae0a83753 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 @@ -12,7 +12,7 @@ async def setUp(self): self.wallet = async_mock.MagicMock() async def test_sign_x_no_public_key(self): - key_pair = WalletKeyPair(wallet=self.wallet, key_type=KeyType.ED25519) + key_pair = WalletKeyPair(wallet=self.wallet, key_type=ED25519) with self.assertRaises(LinkedDataProofException) as context: await key_pair.sign(b"Message") @@ -22,7 +22,7 @@ async def test_sign(self): public_key_base58 = "verkey" key_pair = WalletKeyPair( wallet=self.wallet, - key_type=KeyType.ED25519, + key_type=ED25519, public_key_base58=public_key_base58, ) signed = async_mock.MagicMock() @@ -37,7 +37,7 @@ async def test_sign(self): ) async def test_verify_x_no_public_key(self): - key_pair = WalletKeyPair(wallet=self.wallet, key_type=KeyType.ED25519) + key_pair = WalletKeyPair(wallet=self.wallet, key_type=ED25519) with self.assertRaises(LinkedDataProofException) as context: await key_pair.verify(b"Message", b"signature") @@ -47,7 +47,7 @@ async def test_verify(self): public_key_base58 = "verkey" key_pair = WalletKeyPair( wallet=self.wallet, - key_type=KeyType.ED25519, + key_type=ED25519, public_key_base58=public_key_base58, ) self.wallet.verify_message = async_mock.CoroutineMock(return_value=True) @@ -59,11 +59,11 @@ async def test_verify(self): message=b"Message", signature=b"signature", from_verkey=public_key_base58, - key_type=KeyType.ED25519, + key_type=ED25519, ) async def test_from_verification_method_x_no_public_key_base58(self): - key_pair = WalletKeyPair(wallet=self.wallet, key_type=KeyType.ED25519) + key_pair = WalletKeyPair(wallet=self.wallet, key_type=ED25519) with self.assertRaises(LinkedDataProofException) as context: key_pair.from_verification_method({}) 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 f8bfdf6533..7fac62baad 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 @@ -30,19 +30,19 @@ async def setUp(self): self.profile = InMemoryProfile.test_profile() self.wallet = InMemoryWallet(self.profile) self.key = await self.wallet.create_signing_key( - key_type=KeyType.BLS12381G2, seed=self.test_seed + key_type=BLS12381G2, seed=self.test_seed ) self.verification_method = DIDKey.from_public_key_b58( - self.key.verkey, KeyType.BLS12381G2 + self.key.verkey, BLS12381G2 ).key_id self.sign_key_pair = WalletKeyPair( wallet=self.wallet, - key_type=KeyType.BLS12381G2, + key_type=BLS12381G2, public_key_base58=self.key.verkey, ) self.verify_key_pair = WalletKeyPair( - wallet=self.wallet, key_type=KeyType.BLS12381G2 + wallet=self.wallet, key_type=BLS12381G2 ) async def test_sign_ld_proofs(self): 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 e8a79e2297..e60f923983 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 @@ -39,13 +39,13 @@ async def setUp(self): self.profile = InMemoryProfile.test_profile() self.wallet = InMemoryWallet(self.profile) self.key = await self.wallet.create_signing_key( - key_type=KeyType.BLS12381G2, seed=self.test_seed + key_type=BLS12381G2, seed=self.test_seed ) self.verification_method = DIDKey.from_public_key_b58( - self.key.verkey, KeyType.BLS12381G2 + self.key.verkey, BLS12381G2 ).key_id - self.key_pair = WalletKeyPair(wallet=self.wallet, key_type=KeyType.BLS12381G2) + self.key_pair = WalletKeyPair(wallet=self.wallet, 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 613aec46ab..88dca016d3 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 @@ -29,19 +29,19 @@ async def setUp(self): self.profile = InMemoryProfile.test_profile() self.wallet = InMemoryWallet(self.profile) self.key = await self.wallet.create_signing_key( - key_type=KeyType.ED25519, seed=self.test_seed + key_type=ED25519, seed=self.test_seed ) self.verification_method = DIDKey.from_public_key_b58( - self.key.verkey, KeyType.ED25519 + self.key.verkey, ED25519 ).key_id self.sign_key_pair = WalletKeyPair( wallet=self.wallet, - key_type=KeyType.ED25519, + key_type=ED25519, public_key_base58=self.key.verkey, ) self.verify_key_pair = WalletKeyPair( - wallet=self.wallet, key_type=KeyType.ED25519 + wallet=self.wallet, key_type=ED25519 ) async def test_sign_ld_proofs(self): 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 15d9ea5e90..b1369f9602 100644 --- a/aries_cloudagent/vc/ld_proofs/tests/test_ld_proofs.py +++ b/aries_cloudagent/vc/ld_proofs/tests/test_ld_proofs.py @@ -40,18 +40,18 @@ async def setUp(self): self.wallet = InMemoryWallet(self.profile) self.ed25519_key_info = await self.wallet.create_signing_key( - key_type=KeyType.ED25519, seed=self.test_seed + key_type=ED25519, seed=self.test_seed ) self.ed25519_verification_method = DIDKey.from_public_key_b58( - self.ed25519_key_info.verkey, KeyType.ED25519 + self.ed25519_key_info.verkey, ED25519 ).key_id self.bls12381g2_key_info = await self.wallet.create_signing_key( - key_type=KeyType.BLS12381G2, seed=self.test_seed + key_type=BLS12381G2, seed=self.test_seed ) self.bls12381g2_verification_method = DIDKey.from_public_key_b58( - self.bls12381g2_key_info.verkey, KeyType.BLS12381G2 + self.bls12381g2_key_info.verkey, BLS12381G2 ).key_id async def test_sign_Ed25519Signature2018(self): @@ -62,7 +62,7 @@ async def test_sign_Ed25519Signature2018(self): verification_method=self.ed25519_verification_method, key_pair=WalletKeyPair( wallet=self.wallet, - key_type=KeyType.ED25519, + key_type=ED25519, public_key_base58=self.ed25519_key_info.verkey, ), date=datetime(2019, 12, 11, 3, 50, 55, 0, timezone.utc), @@ -79,7 +79,7 @@ async def test_sign_Ed25519Signature2018(self): async def test_verify_Ed25519Signature2018(self): # Verification requires lot less input parameters suite = Ed25519Signature2018( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=KeyType.ED25519), + key_pair=WalletKeyPair(wallet=self.wallet, key_type=ED25519), ) result = await verify( @@ -100,7 +100,7 @@ async def test_sign_BbsBlsSignature2020(self): verification_method=self.bls12381g2_verification_method, key_pair=WalletKeyPair( wallet=self.wallet, - key_type=KeyType.BLS12381G2, + key_type=BLS12381G2, public_key_base58=self.bls12381g2_key_info.verkey, ), date=datetime(2019, 12, 11, 3, 50, 55, 0), @@ -128,7 +128,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=KeyType.BLS12381G2), + key_pair=WalletKeyPair(wallet=self.wallet, key_type=BLS12381G2), ) result = await verify( @@ -144,7 +144,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=KeyType.BLS12381G2), + key_pair=WalletKeyPair(wallet=self.wallet, key_type=BLS12381G2), ) result = await derive( @@ -160,7 +160,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=KeyType.BLS12381G2), + key_pair=WalletKeyPair(wallet=self.wallet, 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 707dec1e6b..cbc8aa795a 100644 --- a/aries_cloudagent/vc/tests/test_bbs_mattr_interop.py +++ b/aries_cloudagent/vc/tests/test_bbs_mattr_interop.py @@ -45,23 +45,23 @@ async def setUp(self): "secret": b58_to_bytes(private_key_base58), "verkey": public_key_base58, "metadata": {}, - "key_type": KeyType.BLS12381G2, + "key_type": BLS12381G2, } self.signature_issuer_suite = BbsBlsSignature2020( verification_method="did:example:489398593#test", key_pair=WalletKeyPair( wallet=self.wallet, - key_type=KeyType.BLS12381G2, + key_type=BLS12381G2, public_key_base58=public_key_base58, ), ) self.signature_suite = BbsBlsSignature2020( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=KeyType.BLS12381G2), + key_pair=WalletKeyPair(wallet=self.wallet, key_type=BLS12381G2), ) self.proof_suite = BbsBlsSignatureProof2020( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=KeyType.BLS12381G2) + key_pair=WalletKeyPair(wallet=self.wallet, 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 8fe29c799f..121c76d50d 100644 --- a/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py +++ b/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py @@ -37,18 +37,18 @@ async def setUp(self): self.wallet = InMemoryWallet(self.profile) self.ed25519_key_info = await self.wallet.create_signing_key( - key_type=KeyType.ED25519, seed=self.test_seed + key_type=ED25519, seed=self.test_seed ) self.ed25519_verification_method = DIDKey.from_public_key_b58( - self.ed25519_key_info.verkey, KeyType.ED25519 + self.ed25519_key_info.verkey, ED25519 ).key_id self.bls12381g2_key_info = await self.wallet.create_signing_key( - key_type=KeyType.BLS12381G2, seed=self.test_seed + key_type=BLS12381G2, seed=self.test_seed ) self.bls12381g2_verification_method = DIDKey.from_public_key_b58( - self.bls12381g2_key_info.verkey, KeyType.BLS12381G2 + self.bls12381g2_key_info.verkey, BLS12381G2 ).key_id self.presentation_challenge = "2b1bbff6-e608-4368-bf84-67471b27e41c" @@ -61,7 +61,7 @@ async def test_issue_Ed25519Signature2018(self): verification_method=self.ed25519_verification_method, key_pair=WalletKeyPair( wallet=self.wallet, - key_type=KeyType.ED25519, + key_type=ED25519, public_key_base58=self.ed25519_key_info.verkey, ), date=datetime.strptime("2019-12-11T03:50:55Z", "%Y-%m-%dT%H:%M:%SZ"), @@ -103,7 +103,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=KeyType.ED25519), + key_pair=WalletKeyPair(wallet=self.wallet, key_type=ED25519), ) verified = await verify_credential( credential=CREDENTIAL_ISSUED, @@ -135,7 +135,7 @@ async def test_issue_BbsBlsSignature2020(self): verification_method=self.bls12381g2_verification_method, key_pair=WalletKeyPair( wallet=self.wallet, - key_type=KeyType.BLS12381G2, + key_type=BLS12381G2, public_key_base58=self.bls12381g2_key_info.verkey, ), date=datetime.strptime("2019-12-11T03:50:55Z", "%Y-%m-%dT%H:%M:%SZ"), @@ -158,7 +158,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=KeyType.BLS12381G2), + key_pair=WalletKeyPair(wallet=self.wallet, key_type=BLS12381G2), ) result = await verify_credential( credential=CREDENTIAL_ISSUED_BBS, @@ -185,7 +185,7 @@ async def test_create_presentation_x_invalid_credential_structures(self): verification_method=self.ed25519_verification_method, key_pair=WalletKeyPair( wallet=self.wallet, - key_type=KeyType.ED25519, + key_type=ED25519, public_key_base58=self.ed25519_key_info.verkey, ), date=datetime.strptime("2020-12-11T03:50:55Z", "%Y-%m-%dT%H:%M:%SZ"), @@ -218,7 +218,7 @@ async def test_sign_presentation_bbsbls(self): verification_method=self.bls12381g2_verification_method, key_pair=WalletKeyPair( wallet=self.wallet, - key_type=KeyType.BLS12381G2, + key_type=BLS12381G2, public_key_base58=self.bls12381g2_key_info.verkey, ), date=datetime.strptime("2020-12-11T03:50:55Z", "%Y-%m-%dT%H:%M:%SZ"), @@ -235,7 +235,7 @@ async def test_sign_presentation_bbsbls(self): async def test_verify_presentation(self): suite = Ed25519Signature2018( - key_pair=WalletKeyPair(wallet=self.wallet, key_type=KeyType.ED25519), + key_pair=WalletKeyPair(wallet=self.wallet, key_type=ED25519), ) verification_result = await verify_presentation( presentation=PRESENTATION_SIGNED, diff --git a/aries_cloudagent/wallet/askar.py b/aries_cloudagent/wallet/askar.py index f2a5c790c6..b881dbba13 100644 --- a/aries_cloudagent/wallet/askar.py +++ b/aries_cloudagent/wallet/askar.py @@ -33,7 +33,7 @@ ) from .did_method import DIDMethod from .error import WalletError, WalletDuplicateError, WalletNotFoundError -from .key_type import KeyType +from .key_type import ED25519, KeyType from .util import b58_to_bytes, bytes_to_b58 CATEGORY_DID = "did" @@ -119,7 +119,7 @@ async def get_signing_key(self, verkey: str) -> KeyInfo: raise WalletNotFoundError("Unknown key: {}".format(verkey)) metadata = json.loads(key.metadata or "{}") # FIXME implement key types - return KeyInfo(verkey=verkey, metadata=metadata, key_type=KeyType.ED25519) + return KeyInfo(verkey=verkey, metadata=metadata, key_type=ED25519) async def replace_signing_key_metadata(self, verkey: str, metadata: dict): """ @@ -514,7 +514,7 @@ async def rotate_did_keypair_start(self, did: str, next_seed: str = None) -> str ) # create a new key to be rotated to (only did:sov/ED25519 supported for now) - keypair = _create_keypair(KeyType.ED25519, next_seed) + keypair = _create_keypair(ED25519, next_seed) verkey = bytes_to_b58(keypair.get_public_bytes()) try: await self._session.handle.insert_key( @@ -607,7 +607,7 @@ async def sign_message( return sign_message( message=message, secret=key.get_secret_bytes(), - key_type=KeyType.BLS12381G2, + key_type=BLS12381G2, ) else: @@ -650,7 +650,7 @@ async def verify_message( verkey = b58_to_bytes(from_verkey) - if key_type == KeyType.ED25519: + if key_type == ED25519: try: pk = Key.from_public_bytes(KeyAlg.ED25519, verkey) return pk.verify_signature(message, signature) @@ -730,21 +730,21 @@ async def unpack_message(self, enc_message: bytes) -> Tuple[str, str, str]: def _create_keypair(key_type: KeyType, seed: Union[str, bytes] = None) -> Key: """Instantiate a new keypair with an optional seed value.""" - if key_type == KeyType.ED25519: + if key_type == ED25519: alg = KeyAlg.ED25519 method = None - # elif key_type == KeyType.BLS12381G1: + # elif key_type == BLS12381G1: # alg = KeyAlg.BLS12_381_G1 - elif key_type == KeyType.BLS12381G2: + elif key_type == BLS12381G2: alg = KeyAlg.BLS12_381_G2 method = SeedMethod.BlsKeyGen - # elif key_type == KeyType.BLS12381G1G2: + # elif key_type == BLS12381G1G2: # alg = KeyAlg.BLS12_381_G1G2 else: raise WalletError(f"Unsupported key algorithm: {key_type}") if seed: try: - if key_type == KeyType.ED25519: + if key_type == ED25519: # not a seed - it is the secret key seed = validate_seed(seed) return Key.from_secret_bytes(alg, seed) diff --git a/aries_cloudagent/wallet/crypto.py b/aries_cloudagent/wallet/crypto.py index 5e79c3c15f..34615d908f 100644 --- a/aries_cloudagent/wallet/crypto.py +++ b/aries_cloudagent/wallet/crypto.py @@ -38,9 +38,9 @@ def create_keypair(key_type: KeyType, seed: bytes = None) -> Tuple[bytes, bytes] A tuple of (public key, secret key) """ - if key_type == KeyType.ED25519: + if key_type == ED25519: return create_ed25519_keypair(seed) - elif key_type == KeyType.BLS12381G2: + elif key_type == BLS12381G2: # This ensures python won't crash if bbs is not installed and not used return create_bls12381g2_keypair(seed) @@ -149,7 +149,7 @@ def sign_message( # Make messages list if not already for easier checking going forward messages = message if isinstance(message, list) else [message] - if key_type == KeyType.ED25519: + if key_type == ED25519: if len(messages) > 1: raise WalletError("ed25519 can only sign a single message") @@ -157,7 +157,7 @@ def sign_message( message=messages[0], secret=secret, ) - elif key_type == KeyType.BLS12381G2: + elif key_type == BLS12381G2: return sign_messages_bls12381g2(messages=messages, secret=secret) else: raise WalletError(f"Unsupported key type: {key_type.key_type}") @@ -201,14 +201,14 @@ def verify_signed_message( # Make messages list if not already for easier checking going forward messages = message if isinstance(message, list) else [message] - if key_type == KeyType.ED25519: + if key_type == ED25519: if len(messages) > 1: raise WalletError("ed25519 can only verify a single message") return verify_signed_message_ed25519( message=messages[0], signature=signature, verkey=verkey ) - elif key_type == KeyType.BLS12381G2: + elif key_type == BLS12381G2: try: return verify_signed_messages_bls12381g2( messages=messages, signature=signature, public_key=verkey diff --git a/aries_cloudagent/wallet/did_method.py b/aries_cloudagent/wallet/did_method.py index 797c26fd20..840d2836c1 100644 --- a/aries_cloudagent/wallet/did_method.py +++ b/aries_cloudagent/wallet/did_method.py @@ -3,7 +3,7 @@ from typing import List, Mapping, NamedTuple, Optional from enum import Enum -from .key_type import KeyType +from .key_type import BLS12381G2, ED25519, KeyType from .error import BaseError DIDMethodSpec = NamedTuple( @@ -20,11 +20,11 @@ class DIDMethod(Enum): """DID Method class specifying DID methods with supported key types.""" SOV = DIDMethodSpec( - method_name="sov", supported_key_types=[KeyType.ED25519], supports_rotation=True + method_name="sov", supported_key_types=[ED25519], supports_rotation=True ) KEY = DIDMethodSpec( method_name="key", - supported_key_types=[KeyType.ED25519, KeyType.BLS12381G2], + supported_key_types=[ED25519, BLS12381G2], supports_rotation=False, ) diff --git a/aries_cloudagent/wallet/indy.py b/aries_cloudagent/wallet/indy.py index 4e2406d04f..b34f041c23 100644 --- a/aries_cloudagent/wallet/indy.py +++ b/aries_cloudagent/wallet/indy.py @@ -56,7 +56,7 @@ def __did_info_from_indy_info(self, info): verkey = info["verkey"] method = DIDMethod.KEY if did.startswith("did:key") else DIDMethod.SOV - key_type = KeyType.ED25519 + key_type = ED25519 if method == DIDMethod.KEY: did = DIDKey.from_public_key_b58(info["verkey"], key_type).did @@ -83,7 +83,7 @@ def __did_info_from_key_pair_info(self, info: dict): async def __create_indy_signing_key( self, key_type: KeyType, metadata: dict, seed: str = None ) -> str: - if key_type != KeyType.ED25519: + if key_type != ED25519: raise WalletError(f"Unsupported key type: {key_type.key_type}") args = {} @@ -107,7 +107,7 @@ async def __create_indy_signing_key( async def __create_keypair_signing_key( self, key_type: KeyType, metadata: dict, seed: str = None ) -> str: - if key_type != KeyType.BLS12381G2: + if key_type != BLS12381G2: raise WalletError(f"Unsupported key type: {key_type.key_type}") public_key, secret_key = create_keypair(key_type, validate_seed(seed)) @@ -158,7 +158,7 @@ async def create_signing_key( metadata = {} # All ed25519 keys are handled by indy - if key_type == KeyType.ED25519: + if key_type == ED25519: verkey = await self.__create_indy_signing_key(key_type, metadata, seed) # All other (only bls12381g2 atm) are handled outside of indy else: @@ -173,7 +173,7 @@ async def __get_indy_signing_key(self, verkey: str) -> KeyInfo: return KeyInfo( verkey=verkey, metadata=json.loads(metadata) if metadata else {}, - key_type=KeyType.ED25519, + key_type=ED25519, ) except IndyError as x_indy: if x_indy.error_code == ErrorCode.WalletItemNotFound: @@ -246,7 +246,7 @@ async def replace_signing_key_metadata(self, verkey: str, metadata: dict): key_info = await self.get_signing_key(verkey) # All ed25519 keys are handled by indy - if key_info.key_type == KeyType.ED25519: + if key_info.key_type == ED25519: await indy.crypto.set_key_metadata( self.opened.handle, verkey, json.dumps(metadata) ) @@ -328,7 +328,7 @@ async def __create_indy_local_did( raise WalletError( f"Unsupported DID method for indy storage: {method.method_name}" ) - if key_type != KeyType.ED25519: + if key_type != ED25519: raise WalletError( f"Unsupported key type for indy storage: {key_type.key_type}" ) @@ -380,7 +380,7 @@ async def __create_keypair_local_did( raise WalletError( f"Unsupported DID method for keypair storage: {method.method_name}" ) - if key_type != KeyType.BLS12381G2: + if key_type != BLS12381G2: raise WalletError( f"Unsupported key type for keypair storage: {key_type.key_type}" ) @@ -448,7 +448,7 @@ async def create_local_did( raise WalletError("Not allowed to set DID for DID method 'key'") # All ed25519 keys are handled by indy - if key_type == KeyType.ED25519: + if key_type == ED25519: return await self.__create_indy_local_did( method, key_type, metadata, seed, did=did ) @@ -491,13 +491,13 @@ async def __get_indy_local_did( raise WalletError( f"Unsupported DID method for indy storage: {method.method_name}" ) - if key_type != KeyType.ED25519: + if key_type != ED25519: raise WalletError( f"Unsupported DID type for indy storage: {key_type.key_type}" ) # key type is always ed25519, method not always key - if method == DIDMethod.KEY and key_type == KeyType.ED25519: + if method == DIDMethod.KEY and key_type == ED25519: did_key = DIDKey.from_did(did) # Ed25519 did:keys are masked indy dids so transform to indy @@ -521,7 +521,7 @@ async def __get_keypair_local_did( raise WalletError( f"Unsupported DID method for keypair storage: {method.method_name}" ) - if key_type != KeyType.BLS12381G2: + if key_type != BLS12381G2: raise WalletError( f"Unsupported DID type for keypair storage: {key_type.key_type}" ) @@ -549,14 +549,14 @@ async def get_local_did(self, did: str) -> DIDInfo: """ method = DIDMethod.from_did(did) - key_type = KeyType.ED25519 + key_type = ED25519 # If did key, the key type can differ if method == DIDMethod.KEY: did_key = DIDKey.from_did(did) key_type = did_key.key_type - if key_type == KeyType.ED25519: + if key_type == ED25519: return await self.__get_indy_local_did(method, key_type, did) else: return await self.__get_keypair_local_did(method, key_type, did) @@ -596,7 +596,7 @@ async def replace_local_did_metadata(self, did: str, metadata: dict): did_info = await self.get_local_did(did) # throw exception if undefined # ed25519 keys are handled by indy - if did_info.key_type == KeyType.ED25519: + if did_info.key_type == ED25519: try: await indy.did.set_did_metadata( self.opened.handle, did, json.dumps(metadata) @@ -785,7 +785,7 @@ async def sign_message(self, message: bytes, from_verkey: str) -> bytes: key_info = await self.get_local_did_for_verkey(from_verkey) # ed25519 keys are handled by indy - if key_info.key_type == KeyType.ED25519: + if key_info.key_type == ED25519: try: result = await indy.crypto.crypto_sign( self.opened.handle, from_verkey, message @@ -837,7 +837,7 @@ async def verify_message( raise WalletError("Message not provided") # ed25519 keys are handled by indy - if key_type == KeyType.ED25519: + if key_type == ED25519: try: result = await indy.crypto.crypto_verify( from_verkey, message, signature diff --git a/aries_cloudagent/wallet/routes.py b/aries_cloudagent/wallet/routes.py index eb18163fcb..bb6fa58236 100644 --- a/aries_cloudagent/wallet/routes.py +++ b/aries_cloudagent/wallet/routes.py @@ -41,7 +41,7 @@ from .did_method import DIDMethod from .did_posture import DIDPosture from .error import WalletError, WalletNotFoundError -from .key_type import KeyType +from .key_type import BLS12381G2, ED25519, KeyType from .util import EVENT_LISTENER_PATTERN LOGGER = logging.getLogger(__name__) @@ -71,9 +71,9 @@ class DIDSchema(OpenAPISchema): ) key_type = fields.Str( description="Key type associated with the DID", - example=KeyType.ED25519.key_type, + example=ED25519.key_type, validate=validate.OneOf( - [KeyType.ED25519.key_type, KeyType.BLS12381G2.key_type] + [ED25519.key_type, BLS12381G2.key_type] ), ) @@ -142,9 +142,9 @@ class DIDListQueryStringSchema(OpenAPISchema): ) key_type = fields.Str( required=False, - example=KeyType.ED25519.key_type, + example=ED25519.key_type, validate=validate.OneOf( - [KeyType.ED25519.key_type, KeyType.BLS12381G2.key_type] + [ED25519.key_type, BLS12381G2.key_type] ), description="Key type to query for.", ) @@ -161,9 +161,9 @@ class DIDCreateOptionsSchema(OpenAPISchema): key_type = fields.Str( required=True, - example=KeyType.ED25519.key_type, + example=ED25519.key_type, validate=validate.OneOf( - [KeyType.ED25519.key_type, KeyType.BLS12381G2.key_type] + [ED25519.key_type, BLS12381G2.key_type] ), ) @@ -353,10 +353,7 @@ async def wallet_create_did(request: web.BaseRequest): body = {} # set default method and key type for backwards compat - key_type = ( - KeyType.from_key_type(body.get("options", {}).get("key_type")) - or KeyType.ED25519 - ) + key_type = KeyType.from_key_type(body.get("options", {}).get("key_type")) or ED25519 method = DIDMethod.from_method(body.get("method")) or DIDMethod.SOV if not method.supports_key_type(key_type): diff --git a/aries_cloudagent/wallet/tests/test_crypto.py b/aries_cloudagent/wallet/tests/test_crypto.py index 66f6fc770a..2e72c3b70f 100644 --- a/aries_cloudagent/wallet/tests/test_crypto.py +++ b/aries_cloudagent/wallet/tests/test_crypto.py @@ -3,7 +3,7 @@ from unittest import mock, TestCase -from ..key_type import KeyType +from ..key_type import ED25519 from ..error import WalletError from ...utils.jwe import JweRecipient from ..util import str_to_b64 @@ -33,7 +33,7 @@ def test_seeds_keys(self): assert len(test_module.seed_to_did(SEED)) in (22, 23) (public_key, secret_key) = test_module.create_keypair( - test_module.KeyType.ED25519 + test_module.ED25519 ) assert public_key assert secret_key @@ -156,28 +156,26 @@ def test_extract_pack_recipients_x(self): def test_sign_ed25519_x_multiple_messages(self): with self.assertRaises(WalletError) as context: - test_module.sign_message( - [b"message1", b"message2"], b"secret", KeyType.ED25519 - ) + test_module.sign_message([b"message1", b"message2"], b"secret", ED25519) assert "ed25519 can only sign a single message" in str(context.exception) def test_sign_x_unsupported_key_type(self): with self.assertRaises(WalletError) as context: test_module.sign_message( - [b"message1", b"message2"], b"secret", KeyType.BLS12381G1 + [b"message1", b"message2"], b"secret", BLS12381G1 ) assert "Unsupported key type: bls12381g1" in str(context.exception) def test_verify_ed25519_x_multiple_messages(self): with self.assertRaises(WalletError) as context: test_module.verify_signed_message( - [b"message1", b"message2"], b"signature", b"verkey", KeyType.ED25519 + [b"message1", b"message2"], b"signature", b"verkey", ED25519 ) assert "ed25519 can only verify a single message" in str(context.exception) def test_verify_x_unsupported_key_type(self): with self.assertRaises(WalletError) as context: test_module.verify_signed_message( - [b"message1", b"message2"], b"signature", b"verkey", KeyType.BLS12381G1 + [b"message1", b"message2"], b"signature", b"verkey", BLS12381G1 ) assert "Unsupported key type: bls12381g1" in str(context.exception) diff --git a/aries_cloudagent/wallet/tests/test_did_method.py b/aries_cloudagent/wallet/tests/test_did_method.py index 2134d01555..834ac63fb9 100644 --- a/aries_cloudagent/wallet/tests/test_did_method.py +++ b/aries_cloudagent/wallet/tests/test_did_method.py @@ -25,46 +25,46 @@ class TestKeyType(TestCase): def test_from_multicodec_name(self): - assert KeyType.from_multicodec_name(ED25519_MULTICODEC_NAME) == KeyType.ED25519 - assert KeyType.from_multicodec_name(X25519_MULTICODEC_NAME) == KeyType.X25519 + assert KeyType.from_multicodec_name(ED25519_MULTICODEC_NAME) == ED25519 + assert KeyType.from_multicodec_name(X25519_MULTICODEC_NAME) == X25519 assert ( KeyType.from_multicodec_name(BLS12381G1_MULTICODEC_NAME) - == KeyType.BLS12381G1 + == BLS12381G1 ) assert ( KeyType.from_multicodec_name(BLS12381G2_MULTICODEC_NAME) - == KeyType.BLS12381G2 + == BLS12381G2 ) assert ( KeyType.from_multicodec_name(BLS12381G1G2_MULTICODEC_NAME) - == KeyType.BLS12381G1G2 + == BLS12381G1G2 ) assert KeyType.from_multicodec_name("non-existing") == None def test_from_key_type(self): - assert KeyType.from_key_type(ED25519_KEY_NAME) == KeyType.ED25519 - assert KeyType.from_key_type(X25519_KEY_NAME) == KeyType.X25519 - assert KeyType.from_key_type(BLS12381G1_KEY_NAME) == KeyType.BLS12381G1 - assert KeyType.from_key_type(BLS12381G2_KEY_NAME) == KeyType.BLS12381G2 - assert KeyType.from_key_type(BLS12381G1G2_KEY_NAME) == KeyType.BLS12381G1G2 + assert KeyType.from_key_type(ED25519_KEY_NAME) == ED25519 + assert KeyType.from_key_type(X25519_KEY_NAME) == X25519 + assert KeyType.from_key_type(BLS12381G1_KEY_NAME) == BLS12381G1 + assert KeyType.from_key_type(BLS12381G2_KEY_NAME) == BLS12381G2 + assert KeyType.from_key_type(BLS12381G1G2_KEY_NAME) == BLS12381G1G2 assert KeyType.from_key_type("non-existing") == None def test_from_multicodec_prefix(self): - assert KeyType.from_multicodec_prefix(ED25519_PREFIX_BYTES) == KeyType.ED25519 - assert KeyType.from_multicodec_prefix(X25519_PREFIX_BYTES) == KeyType.X25519 + assert KeyType.from_multicodec_prefix(ED25519_PREFIX_BYTES) == ED25519 + assert KeyType.from_multicodec_prefix(X25519_PREFIX_BYTES) == X25519 assert ( KeyType.from_multicodec_prefix(BLS12381G1_PREFIX_BYTES) - == KeyType.BLS12381G1 + == BLS12381G1 ) assert ( KeyType.from_multicodec_prefix(BLS12381G2_PREFIX_BYTES) - == KeyType.BLS12381G2 + == BLS12381G2 ) assert ( KeyType.from_multicodec_prefix(BLS12381G1G2_PREFIX_BYTES) - == KeyType.BLS12381G1G2 + == BLS12381G1G2 ) assert KeyType.from_multicodec_prefix(b"\xef\x01") == None @@ -74,31 +74,31 @@ def test_from_prefixed_bytes(self): KeyType.from_prefixed_bytes( b"".join([ED25519_PREFIX_BYTES, b"random-bytes"]) ) - == KeyType.ED25519 + == ED25519 ) assert ( KeyType.from_prefixed_bytes( b"".join([X25519_PREFIX_BYTES, b"random-bytes"]) ) - == KeyType.X25519 + == X25519 ) assert ( KeyType.from_prefixed_bytes( b"".join([BLS12381G1_PREFIX_BYTES, b"random-bytes"]) ) - == KeyType.BLS12381G1 + == BLS12381G1 ) assert ( KeyType.from_prefixed_bytes( b"".join([BLS12381G2_PREFIX_BYTES, b"random-bytes"]) ) - == KeyType.BLS12381G2 + == BLS12381G2 ) assert ( KeyType.from_prefixed_bytes( b"".join([BLS12381G1G2_PREFIX_BYTES, b"random-bytes"]) ) - == KeyType.BLS12381G1G2 + == BLS12381G1G2 ) assert ( KeyType.from_prefixed_bytes(b"".join([b"\xef\x01", b"other-random-bytes"])) @@ -106,7 +106,7 @@ def test_from_prefixed_bytes(self): ) def test_properties(self): - key_type = KeyType.ED25519 + key_type = ED25519 assert key_type.key_type == ED25519_KEY_NAME assert key_type.multicodec_name == ED25519_MULTICODEC_NAME diff --git a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py index 6554336908..97cdcea8cb 100644 --- a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py +++ b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py @@ -4,7 +4,7 @@ from ...core.in_memory import InMemoryProfile from ...messaging.decorators.signature_decorator import SignatureDecorator from ...wallet.in_memory import InMemoryWallet -from ...wallet.key_type import KeyType +from ...wallet.key_type import BLS12381G2, ED25519, KeyType from ...wallet.did_method import DIDMethod from ...wallet.error import ( WalletError, @@ -45,56 +45,56 @@ class TestInMemoryWallet: @pytest.mark.asyncio async def test_create_signing_key_ed25519_random(self, wallet: InMemoryWallet): assert str(wallet) - info = await wallet.create_signing_key(KeyType.ED25519) + info = await wallet.create_signing_key(ED25519) assert info and info.verkey @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_create_signing_key_bls12381g2_random(self, wallet: InMemoryWallet): assert str(wallet) - info = await wallet.create_signing_key(KeyType.BLS12381G2) + info = await wallet.create_signing_key(BLS12381G2) assert info and info.verkey @pytest.mark.asyncio async def test_create_signing_key_ed25519_seeded(self, wallet: InMemoryWallet): - info = await wallet.create_signing_key(KeyType.ED25519, self.test_seed) + info = await wallet.create_signing_key(ED25519, self.test_seed) assert info.verkey == self.test_ed25519_verkey with pytest.raises(WalletDuplicateError): - await wallet.create_signing_key(KeyType.ED25519, self.test_seed) + await wallet.create_signing_key(ED25519, self.test_seed) with pytest.raises(WalletError): - await wallet.create_signing_key(KeyType.ED25519, "invalid-seed", None) + await wallet.create_signing_key(ED25519, "invalid-seed", None) @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_create_signing_key_bls12381g2_seeded(self, wallet: InMemoryWallet): - info = await wallet.create_signing_key(KeyType.BLS12381G2, self.test_seed) + info = await wallet.create_signing_key(BLS12381G2, self.test_seed) assert info.verkey == self.test_bls12381g2_verkey with pytest.raises(WalletDuplicateError): - await wallet.create_signing_key(KeyType.BLS12381G2, self.test_seed) + await wallet.create_signing_key(BLS12381G2, self.test_seed) with pytest.raises(WalletError): - await wallet.create_signing_key(KeyType.BLS12381G2, "invalid-seed", None) + await wallet.create_signing_key(BLS12381G2, "invalid-seed", None) @pytest.mark.asyncio async def test_create_signing_key_unsupported_key_type( self, wallet: InMemoryWallet ): with pytest.raises(WalletError): - await wallet.create_signing_key(KeyType.X25519) + await wallet.create_signing_key(X25519) with pytest.raises(WalletError): - await wallet.create_signing_key(KeyType.BLS12381G1) + await wallet.create_signing_key(BLS12381G1) with pytest.raises(WalletError): - await wallet.create_signing_key(KeyType.BLS12381G1G2) + await wallet.create_signing_key(BLS12381G1G2) @pytest.mark.asyncio async def test_signing_key_metadata(self, wallet: InMemoryWallet): info = await wallet.create_signing_key( - KeyType.ED25519, self.test_seed, self.test_metadata + ED25519, self.test_seed, self.test_metadata ) assert info.metadata == self.test_metadata info2 = await wallet.get_signing_key(self.test_ed25519_verkey) @@ -117,7 +117,7 @@ async def test_signing_key_metadata(self, wallet: InMemoryWallet): @pytest.mark.ursa_bbs_signatures async def test_signing_key_metadata_bls(self, wallet: InMemoryWallet): info = await wallet.create_signing_key( - KeyType.BLS12381G2, self.test_seed, self.test_metadata + BLS12381G2, self.test_seed, self.test_metadata ) assert info.metadata == self.test_metadata info2 = await wallet.get_signing_key(self.test_bls12381g2_verkey) @@ -130,19 +130,19 @@ async def test_signing_key_metadata_bls(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_create_local_sov_random(self, wallet: InMemoryWallet): - info = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519, None, None) + info = await wallet.create_local_did(DIDMethod.SOV, ED25519, None, None) assert info and info.did and info.verkey @pytest.mark.asyncio async def test_create_local_key_random_ed25519(self, wallet: InMemoryWallet): - info = await wallet.create_local_did(DIDMethod.KEY, KeyType.ED25519, None, None) + info = await wallet.create_local_did(DIDMethod.KEY, ED25519, None, None) assert info and info.did and info.verkey @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_create_local_key_random_bls12381g2(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.KEY, KeyType.BLS12381G2, None, None + DIDMethod.KEY, BLS12381G2, None, None ) assert info and info.did and info.verkey @@ -151,61 +151,57 @@ async def test_create_local_incorrect_key_type_for_did_method( self, wallet: InMemoryWallet ): with pytest.raises(WalletError): - await wallet.create_local_did(DIDMethod.SOV, KeyType.BLS12381G2, None, None) + await wallet.create_local_did(DIDMethod.SOV, BLS12381G2, None, None) @pytest.mark.asyncio async def test_create_local_sov_seeded(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, None + DIDMethod.SOV, ED25519, self.test_seed, None ) assert info.did == self.test_sov_did assert info.verkey == self.test_ed25519_verkey # should not raise WalletDuplicateError - same verkey - await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, None - ) + await wallet.create_local_did(DIDMethod.SOV, ED25519, self.test_seed, None) with pytest.raises(WalletError): _ = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, "invalid-seed", None + DIDMethod.SOV, ED25519, "invalid-seed", None ) @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_create_local_key_seeded_bls12381g2(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.KEY, KeyType.BLS12381G2, self.test_seed, None + DIDMethod.KEY, BLS12381G2, self.test_seed, None ) assert info.did == self.test_key_bls12381g2_did assert info.verkey == self.test_bls12381g2_verkey # should not raise WalletDuplicateError - same verkey await wallet.create_local_did( - DIDMethod.KEY, KeyType.BLS12381G2, self.test_seed, None + DIDMethod.KEY, BLS12381G2, self.test_seed, None ) with pytest.raises(WalletError): _ = await wallet.create_local_did( - DIDMethod.KEY, KeyType.BLS12381G2, "invalid-seed", None + DIDMethod.KEY, BLS12381G2, "invalid-seed", None ) @pytest.mark.asyncio async def test_create_local_key_seeded_ed25519(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.KEY, KeyType.ED25519, self.test_seed, None + DIDMethod.KEY, ED25519, self.test_seed, None ) assert info.did == self.test_key_ed25519_did assert info.verkey == self.test_ed25519_verkey # should not raise WalletDuplicateError - same verkey - await wallet.create_local_did( - DIDMethod.KEY, KeyType.ED25519, self.test_seed, None - ) + await wallet.create_local_did(DIDMethod.KEY, ED25519, self.test_seed, None) with pytest.raises(WalletError): _ = await wallet.create_local_did( - DIDMethod.KEY, KeyType.ED25519, "invalid-seed", None + DIDMethod.KEY, ED25519, "invalid-seed", None ) @pytest.mark.asyncio @@ -217,9 +213,9 @@ async def test_rotate_did_keypair(self, wallet: InMemoryWallet): await wallet.rotate_did_keypair_apply(self.test_sov_did) info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, self.test_sov_did + DIDMethod.SOV, ED25519, self.test_seed, self.test_sov_did ) - key_info = await wallet.create_local_did(DIDMethod.KEY, KeyType.ED25519) + key_info = await wallet.create_local_did(DIDMethod.KEY, ED25519) with pytest.raises(WalletError): await wallet.rotate_did_keypair_apply(self.test_sov_did) @@ -239,25 +235,25 @@ async def test_rotate_did_keypair(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_create_local_with_did(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, None, self.test_sov_did + DIDMethod.SOV, ED25519, None, self.test_sov_did ) assert info.did == self.test_sov_did with pytest.raises(WalletDuplicateError): await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, None, self.test_sov_did + DIDMethod.SOV, ED25519, None, self.test_sov_did ) with pytest.raises(WalletError) as context: await wallet.create_local_did( - DIDMethod.KEY, KeyType.ED25519, None, "did:sov:random" + DIDMethod.KEY, ED25519, None, "did:sov:random" ) assert "Not allowed to set DID for DID method 'key'" in str(context.value) @pytest.mark.asyncio async def test_local_verkey(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, self.test_sov_did + DIDMethod.SOV, ED25519, self.test_seed, self.test_sov_did ) assert info.did == self.test_sov_did assert info.verkey == self.test_ed25519_verkey @@ -273,7 +269,7 @@ async def test_local_verkey(self, wallet: InMemoryWallet): @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_local_verkey_bls12381g2(self, wallet: InMemoryWallet): - await wallet.create_local_did(DIDMethod.KEY, KeyType.BLS12381G2, self.test_seed) + await wallet.create_local_did(DIDMethod.KEY, BLS12381G2, self.test_seed) bls_info_get = await wallet.get_local_did_for_verkey( self.test_bls12381g2_verkey ) @@ -289,7 +285,7 @@ async def test_local_verkey_bls12381g2(self, wallet: InMemoryWallet): async def test_local_metadata(self, wallet: InMemoryWallet): info = await wallet.create_local_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, self.test_seed, self.test_sov_did, self.test_metadata, @@ -319,7 +315,7 @@ async def test_local_metadata(self, wallet: InMemoryWallet): async def test_local_metadata_bbs(self, wallet: InMemoryWallet): info = await wallet.create_local_did( DIDMethod.KEY, - KeyType.BLS12381G2, + BLS12381G2, self.test_seed, None, self.test_metadata, @@ -339,7 +335,7 @@ async def test_local_metadata_bbs(self, wallet: InMemoryWallet): async def test_create_public_did(self, wallet: InMemoryWallet): info = await wallet.create_local_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, self.test_seed, self.test_sov_did, self.test_metadata, @@ -351,7 +347,7 @@ async def test_create_public_did(self, wallet: InMemoryWallet): info_public = await wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) assert info_public.metadata.get("posted") posted = await wallet.get_posted_dids() @@ -360,7 +356,7 @@ async def test_create_public_did(self, wallet: InMemoryWallet): # test replace info_replace = await wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) assert info_replace.metadata.get("posted") info_check = await wallet.get_local_did(info_public.did) @@ -377,7 +373,7 @@ async def test_create_public_did_x_not_sov(self, wallet: InMemoryWallet): with pytest.raises(WalletError) as context: await wallet.create_public_did( DIDMethod.KEY, - KeyType.ED25519, + ED25519, ) assert "Setting public DID is only allowed for did:sov DIDs" in str( context.value @@ -390,7 +386,7 @@ async def test_create_public_did_x_unsupported_key_type_method( with pytest.raises(WalletError) as context: await wallet.create_public_did( DIDMethod.SOV, - KeyType.BLS12381G2, + BLS12381G2, ) assert "Invalid key type" in str(context.value) @@ -398,7 +394,7 @@ async def test_create_public_did_x_unsupported_key_type_method( async def test_set_public_did(self, wallet: InMemoryWallet): info = await wallet.create_local_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, self.test_seed, self.test_sov_did, self.test_metadata, @@ -413,7 +409,7 @@ async def test_set_public_did(self, wallet: InMemoryWallet): assert info_same.did == info.did assert info_same.metadata.get("posted") - info_new = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + info_new = await wallet.create_local_did(DIDMethod.SOV, ED25519) assert info_new.did != info_same.did loc = await wallet.get_local_did(self.test_sov_did) @@ -430,7 +426,7 @@ async def test_set_public_did(self, wallet: InMemoryWallet): async def test_set_public_did_x_not_sov(self, wallet: InMemoryWallet): info = await wallet.create_local_did( DIDMethod.KEY, - KeyType.ED25519, + ED25519, ) with pytest.raises(WalletError) as context: await wallet.set_public_did(info.did) @@ -441,28 +437,24 @@ async def test_set_public_did_x_not_sov(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_sign_verify(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, self.test_sov_did + DIDMethod.SOV, ED25519, self.test_seed, self.test_sov_did ) message_bin = self.test_message.encode("ascii") signature = await wallet.sign_message(message_bin, info.verkey) assert signature == self.test_signature verify = await wallet.verify_message( - message_bin, signature, info.verkey, KeyType.ED25519 + message_bin, signature, info.verkey, ED25519 ) assert verify bad_sig = b"x" + signature[1:] - verify = await wallet.verify_message( - message_bin, bad_sig, info.verkey, KeyType.ED25519 - ) + verify = await wallet.verify_message(message_bin, bad_sig, info.verkey, ED25519) assert not verify bad_msg = b"x" + message_bin[1:] - verify = await wallet.verify_message( - bad_msg, signature, info.verkey, KeyType.ED25519 - ) + verify = await wallet.verify_message(bad_msg, signature, info.verkey, ED25519) assert not verify verify = await wallet.verify_message( - message_bin, signature, self.test_target_verkey, KeyType.ED25519 + message_bin, signature, self.test_target_verkey, ED25519 ) assert not verify @@ -478,46 +470,46 @@ async def test_sign_verify(self, wallet: InMemoryWallet): assert "Verkey not provided" in str(excinfo.value) with pytest.raises(WalletError) as excinfo: - await wallet.verify_message(message_bin, signature, None, KeyType.ED25519) + await wallet.verify_message(message_bin, signature, None, ED25519) assert "Verkey not provided" in str(excinfo.value) with pytest.raises(WalletError) as excinfo: - await wallet.verify_message(message_bin, None, info.verkey, KeyType.ED25519) + await wallet.verify_message(message_bin, None, info.verkey, ED25519) assert "Signature not provided" in str(excinfo.value) with pytest.raises(WalletError) as excinfo: - await wallet.verify_message(None, message_bin, info.verkey, KeyType.ED25519) + await wallet.verify_message(None, message_bin, info.verkey, ED25519) assert "Message not provided" in str(excinfo.value) @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_sign_verify_bbs(self, wallet: InMemoryWallet): info = await wallet.create_local_did( - DIDMethod.KEY, KeyType.BLS12381G2, self.test_seed + DIDMethod.KEY, BLS12381G2, self.test_seed ) message_bin = self.test_message.encode("ascii") signature = await wallet.sign_message(message_bin, info.verkey) assert signature verify = await wallet.verify_message( - message_bin, signature, info.verkey, KeyType.BLS12381G2 + message_bin, signature, info.verkey, BLS12381G2 ) assert verify bad_msg = b"x" + message_bin[1:] verify = await wallet.verify_message( - bad_msg, signature, info.verkey, KeyType.BLS12381G2 + bad_msg, signature, info.verkey, BLS12381G2 ) assert not verify with pytest.raises(WalletError): bad_sig = b"x" + signature[1:] verify = await wallet.verify_message( - message_bin, bad_sig, info.verkey, KeyType.BLS12381G2 + message_bin, bad_sig, info.verkey, BLS12381G2 ) with pytest.raises(WalletError): await wallet.verify_message( - message_bin, signature, self.test_target_verkey, KeyType.BLS12381G2 + message_bin, signature, self.test_target_verkey, BLS12381G2 ) with pytest.raises(WalletError): @@ -533,26 +525,26 @@ async def test_sign_verify_bbs(self, wallet: InMemoryWallet): with pytest.raises(WalletError) as excinfo: await wallet.verify_message( - message_bin, signature, None, KeyType.BLS12381G2 + message_bin, signature, None, BLS12381G2 ) assert "Verkey not provided" in str(excinfo.value) with pytest.raises(WalletError) as excinfo: await wallet.verify_message( - message_bin, None, info.verkey, KeyType.BLS12381G2 + message_bin, None, info.verkey, BLS12381G2 ) assert "Signature not provided" in str(excinfo.value) with pytest.raises(WalletError) as excinfo: await wallet.verify_message( - None, message_bin, info.verkey, KeyType.BLS12381G2 + None, message_bin, info.verkey, BLS12381G2 ) assert "Message not provided" in str(excinfo.value) @pytest.mark.asyncio async def test_pack_unpack(self, wallet: InMemoryWallet): await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, self.test_sov_did + DIDMethod.SOV, ED25519, self.test_seed, self.test_sov_did ) packed_anon = await wallet.pack_message( @@ -568,7 +560,7 @@ async def test_pack_unpack(self, wallet: InMemoryWallet): assert "Message not provided" in str(excinfo.value) await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_target_seed, self.test_target_did + DIDMethod.SOV, ED25519, self.test_target_seed, self.test_target_did ) packed_auth = await wallet.pack_message( self.test_message, [self.test_target_verkey], self.test_ed25519_verkey @@ -587,7 +579,7 @@ async def test_pack_unpack(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_signature_round_trip(self, wallet: InMemoryWallet): - key_info = await wallet.create_signing_key(KeyType.ED25519) + key_info = await wallet.create_signing_key(ED25519) msg = {"test": "signed field"} timestamp = int(time.time()) sig = await SignatureDecorator.create(msg, key_info.verkey, wallet, timestamp) @@ -601,7 +593,7 @@ async def test_signature_round_trip(self, wallet: InMemoryWallet): async def test_set_did_endpoint_x_not_sov(self, wallet: InMemoryWallet): info = await wallet.create_local_did( DIDMethod.KEY, - KeyType.ED25519, + ED25519, ) with pytest.raises(WalletError) as context: await wallet.set_did_endpoint( diff --git a/aries_cloudagent/wallet/tests/test_indy_wallet.py b/aries_cloudagent/wallet/tests/test_indy_wallet.py index 6044a6a658..7d05d78233 100644 --- a/aries_cloudagent/wallet/tests/test_indy_wallet.py +++ b/aries_cloudagent/wallet/tests/test_indy_wallet.py @@ -17,7 +17,7 @@ from ...indy.sdk.profile import IndySdkProfile, IndySdkProfileManager from ...indy.sdk.wallet_setup import IndyWalletConfig from ...ledger.endpoint_type import EndpointType -from ...wallet.key_type import KeyType +from ...wallet.key_type import ED25519, KeyType from ...wallet.did_method import DIDMethod from ...ledger.indy import IndySdkLedgerPool @@ -67,7 +67,7 @@ class TestIndySdkWallet(test_in_memory_wallet.TestInMemoryWallet): @pytest.mark.asyncio async def test_rotate_did_keypair_x(self, wallet: IndySdkWallet): info = await wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed, self.test_sov_did + DIDMethod.SOV, ED25519, self.test_seed, self.test_sov_did ) with async_mock.patch.object( @@ -99,7 +99,7 @@ async def test_create_signing_key_x(self, wallet: IndySdkWallet): test_module.ErrorCode.CommonIOError, {"message": "outlier"} ) with pytest.raises(test_module.WalletError) as excinfo: - await wallet.create_signing_key(KeyType.ED25519) + await wallet.create_signing_key(ED25519) assert "outlier" in str(excinfo.value) @pytest.mark.asyncio @@ -111,7 +111,7 @@ async def test_create_local_did_x(self, wallet: IndySdkWallet): test_module.ErrorCode.CommonIOError, {"message": "outlier"} ) with pytest.raises(test_module.WalletError) as excinfo: - await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519) + await wallet.create_local_did(DIDMethod.SOV, ED25519) assert "outlier" in str(excinfo.value) @pytest.mark.asyncio @@ -121,7 +121,7 @@ async def test_set_did_endpoint_ledger(self, wallet: IndySdkWallet): ) info_pub = await wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) await wallet.set_did_endpoint(info_pub.did, "https://example.com", mock_ledger) mock_ledger.update_endpoint_for_did.assert_called_once_with( @@ -147,7 +147,7 @@ async def test_set_did_endpoint_ledger_with_routing_keys( mock_ledger = async_mock.MagicMock( read_only=False, update_endpoint_for_did=async_mock.CoroutineMock() ) - info_pub = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519) + info_pub = await wallet.create_public_did(DIDMethod.SOV, ED25519) await wallet.set_did_endpoint( info_pub.did, "https://example.com", mock_ledger, routing_keys=routing_keys ) @@ -168,7 +168,7 @@ async def test_set_did_endpoint_readonly_ledger(self, wallet: IndySdkWallet): ) info_pub = await wallet.create_public_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) await wallet.set_did_endpoint(info_pub.did, "https://example.com", mock_ledger) mock_ledger.update_endpoint_for_did.assert_not_called() @@ -207,7 +207,7 @@ async def test_get_local_did_x(self, wallet: IndySdkWallet): async def test_replace_local_did_metadata_x(self, wallet: IndySdkWallet): info = await wallet.create_local_did( DIDMethod.SOV, - KeyType.ED25519, + ED25519, self.test_seed, self.test_sov_did, self.test_metadata, @@ -239,7 +239,7 @@ async def test_verify_message_x(self, wallet: IndySdkWallet): b"hello world", b"signature", self.test_ed25519_verkey, - KeyType.ED25519, + ED25519, ) assert "outlier" in str(excinfo.value) @@ -247,7 +247,7 @@ async def test_verify_message_x(self, wallet: IndySdkWallet): test_module.ErrorCode.CommonInvalidStructure ) assert not await wallet.verify_message( - b"hello world", b"signature", self.test_ed25519_verkey, KeyType.ED25519 + b"hello world", b"signature", self.test_ed25519_verkey, ED25519 ) @pytest.mark.asyncio @@ -282,14 +282,12 @@ async def test_compare_pack_unpack(self, in_memory_wallet, wallet: IndySdkWallet """ Ensure that python-based pack/unpack is compatible with indy-sdk implementation """ - await in_memory_wallet.create_local_did( - DIDMethod.SOV, KeyType.ED25519, self.test_seed - ) + await in_memory_wallet.create_local_did(DIDMethod.SOV, ED25519, self.test_seed) py_packed = await in_memory_wallet.pack_message( self.test_message, [self.test_verkey], self.test_verkey ) - await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519, self.test_seed) + await wallet.create_local_did(DIDMethod.SOV, ED25519, self.test_seed) packed = await wallet.pack_message( self.test_message, [self.test_verkey], self.test_verkey ) @@ -820,7 +818,7 @@ async def test_postgres_wallet_works(self): opened = await postgres_wallet.create_wallet() wallet = IndySdkWallet(opened) - await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519, self.test_seed) + await wallet.create_local_did(DIDMethod.SOV, ED25519, self.test_seed) py_packed = await wallet.pack_message( self.test_message, [self.test_verkey], self.test_verkey ) @@ -862,7 +860,7 @@ async def test_postgres_wallet_scheme_works(self): assert "Wallet was not removed" in str(excinfo.value) wallet = IndySdkWallet(opened) - await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519, self.test_seed) + await wallet.create_local_did(DIDMethod.SOV, ED25519, self.test_seed) py_packed = await wallet.pack_message( self.test_message, [self.test_verkey], self.test_verkey ) @@ -899,7 +897,7 @@ async def test_postgres_wallet_scheme2_works(self): opened = await postgres_wallet.create_wallet() wallet = IndySdkWallet(opened) - await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519, self.test_seed) + await wallet.create_local_did(DIDMethod.SOV, ED25519, self.test_seed) py_packed = await wallet.pack_message( self.test_message, [self.test_verkey], self.test_verkey ) diff --git a/aries_cloudagent/wallet/tests/test_key_pair.py b/aries_cloudagent/wallet/tests/test_key_pair.py index b81062d856..843cae21af 100644 --- a/aries_cloudagent/wallet/tests/test_key_pair.py +++ b/aries_cloudagent/wallet/tests/test_key_pair.py @@ -23,7 +23,7 @@ async def test_create_key_pair(self): await self.key_pair_mgr.store_key_pair( public_key=self.test_public_key, secret_key=self.test_secret, - key_type=KeyType.ED25519, + key_type=ED25519, ) verkey = bytes_to_b58(self.test_public_key) @@ -34,17 +34,17 @@ async def test_create_key_pair(self): value = json.loads(record.value) - assert record.tags == {"verkey": verkey, "key_type": KeyType.ED25519.key_type} + assert record.tags == {"verkey": verkey, "key_type": ED25519.key_type} assert value["verkey"] == verkey assert value["secret_key"] == bytes_to_b58(self.test_secret) assert value["metadata"] == {} - assert value["key_type"] == KeyType.ED25519.key_type + assert value["key_type"] == ED25519.key_type async def test_get_key_pair(self): await self.key_pair_mgr.store_key_pair( public_key=self.test_public_key, secret_key=self.test_secret, - key_type=KeyType.ED25519, + key_type=ED25519, ) verkey = bytes_to_b58(self.test_public_key) @@ -54,7 +54,7 @@ async def test_get_key_pair(self): assert key_pair["verkey"] == verkey assert key_pair["secret_key"] == bytes_to_b58(self.test_secret) assert key_pair["metadata"] == {} - assert key_pair["key_type"] == KeyType.ED25519.key_type + assert key_pair["key_type"] == ED25519.key_type async def test_get_key_pair_x_not_found(self): with self.assertRaises(StorageNotFoundError): @@ -64,7 +64,7 @@ async def test_delete_key_pair(self): await self.key_pair_mgr.store_key_pair( public_key=self.test_public_key, secret_key=self.test_secret, - key_type=KeyType.ED25519, + key_type=ED25519, ) verkey = bytes_to_b58(self.test_public_key) @@ -86,7 +86,7 @@ async def test_update_key_pair_metadata(self): await self.key_pair_mgr.store_key_pair( public_key=self.test_public_key, secret_key=self.test_secret, - key_type=KeyType.ED25519, + key_type=ED25519, metadata={"some": "data"}, ) diff --git a/aries_cloudagent/wallet/tests/test_key_type.py b/aries_cloudagent/wallet/tests/test_key_type.py index 0dc025a099..984ebcbd22 100644 --- a/aries_cloudagent/wallet/tests/test_key_type.py +++ b/aries_cloudagent/wallet/tests/test_key_type.py @@ -2,10 +2,10 @@ from ...core.error import BaseError from ..did_method import DIDMethod -from ..key_type import KeyType +from ..key_type import BLS12381G2, ED25519, KeyType SOV_DID_METHOD_NAME = "sov" -SOV_SUPPORTED_KEY_TYPES = [KeyType.ED25519] +SOV_SUPPORTED_KEY_TYPES = [ED25519] KEY_DID_METHOD_NAME = "key" @@ -37,5 +37,5 @@ def test_properties(self): assert method.supported_key_types == SOV_SUPPORTED_KEY_TYPES assert method.supports_rotation == True - assert method.supports_key_type(KeyType.ED25519) == True - assert method.supports_key_type(KeyType.BLS12381G2) == False + assert method.supports_key_type(ED25519) == True + assert method.supports_key_type(BLS12381G2) == False diff --git a/aries_cloudagent/wallet/tests/test_routes.py b/aries_cloudagent/wallet/tests/test_routes.py index c6adb4b5dc..c6a017b0ab 100644 --- a/aries_cloudagent/wallet/tests/test_routes.py +++ b/aries_cloudagent/wallet/tests/test_routes.py @@ -72,7 +72,7 @@ def test_format_did_info(self): self.test_verkey, DIDPosture.WALLET_ONLY.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) result = test_module.format_did_info(did_info) assert ( @@ -86,7 +86,7 @@ def test_format_did_info(self): self.test_verkey, {"posted": True, "public": True}, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) result = test_module.format_did_info(did_info) assert result["posture"] == DIDPosture.PUBLIC.moniker @@ -96,7 +96,7 @@ def test_format_did_info(self): self.test_verkey, {"posted": True, "public": False}, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) result = test_module.format_did_info(did_info) assert result["posture"] == DIDPosture.POSTED.moniker @@ -110,7 +110,7 @@ async def test_create_did(self): self.test_verkey, DIDPosture.WALLET_ONLY.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) result = await test_module.wallet_create_did(self.request) json_response.assert_called_once_with( @@ -119,7 +119,7 @@ async def test_create_did(self): "did": self.test_did, "verkey": self.test_verkey, "posture": DIDPosture.WALLET_ONLY.moniker, - "key_type": KeyType.ED25519.key_type, + "key_type": ED25519.key_type, "method": DIDMethod.SOV.method_name, } } @@ -148,14 +148,14 @@ async def test_did_list(self): self.test_verkey, DIDPosture.WALLET_ONLY.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ), DIDInfo( self.test_posted_did, self.test_posted_verkey, DIDPosture.POSTED.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ), ] result = await test_module.wallet_did_list(self.request) @@ -166,14 +166,14 @@ async def test_did_list(self): "did": self.test_posted_did, "verkey": self.test_posted_verkey, "posture": DIDPosture.POSTED.moniker, - "key_type": KeyType.ED25519.key_type, + "key_type": ED25519.key_type, "method": DIDMethod.SOV.method_name, }, { "did": self.test_did, "verkey": self.test_verkey, "posture": DIDPosture.WALLET_ONLY.moniker, - "key_type": KeyType.ED25519.key_type, + "key_type": ED25519.key_type, "method": DIDMethod.SOV.method_name, }, ] @@ -192,7 +192,7 @@ async def test_did_list_filter_public(self): self.test_verkey, DIDPosture.PUBLIC.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) self.wallet.get_posted_dids.return_value = [ DIDInfo( @@ -200,7 +200,7 @@ async def test_did_list_filter_public(self): self.test_posted_verkey, DIDPosture.POSTED.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) ] result = await test_module.wallet_did_list(self.request) @@ -211,7 +211,7 @@ async def test_did_list_filter_public(self): "did": self.test_did, "verkey": self.test_verkey, "posture": DIDPosture.PUBLIC.moniker, - "key_type": KeyType.ED25519.key_type, + "key_type": ED25519.key_type, "method": DIDMethod.SOV.method_name, } ] @@ -230,7 +230,7 @@ async def test_did_list_filter_posted(self): self.test_verkey, DIDPosture.PUBLIC.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) self.wallet.get_posted_dids.return_value = [ DIDInfo( @@ -241,7 +241,7 @@ async def test_did_list_filter_posted(self): "public": False, }, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) ] result = await test_module.wallet_did_list(self.request) @@ -252,7 +252,7 @@ async def test_did_list_filter_posted(self): "did": self.test_posted_did, "verkey": self.test_posted_verkey, "posture": DIDPosture.POSTED.moniker, - "key_type": KeyType.ED25519.key_type, + "key_type": ED25519.key_type, "method": DIDMethod.SOV.method_name, } ] @@ -271,7 +271,7 @@ async def test_did_list_filter_did(self): self.test_verkey, DIDPosture.WALLET_ONLY.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) result = await test_module.wallet_did_list(self.request) json_response.assert_called_once_with( @@ -281,7 +281,7 @@ async def test_did_list_filter_did(self): "did": self.test_did, "verkey": self.test_verkey, "posture": DIDPosture.WALLET_ONLY.moniker, - "key_type": KeyType.ED25519.key_type, + "key_type": ED25519.key_type, "method": DIDMethod.SOV.method_name, } ] @@ -311,7 +311,7 @@ async def test_did_list_filter_verkey(self): self.test_verkey, DIDPosture.WALLET_ONLY.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) result = await test_module.wallet_did_list(self.request) json_response.assert_called_once_with( @@ -321,7 +321,7 @@ async def test_did_list_filter_verkey(self): "did": self.test_did, "verkey": self.test_verkey, "posture": DIDPosture.WALLET_ONLY.moniker, - "key_type": KeyType.ED25519.key_type, + "key_type": ED25519.key_type, "method": DIDMethod.SOV.method_name, } ] @@ -350,7 +350,7 @@ async def test_get_public_did(self): self.test_verkey, DIDPosture.PUBLIC.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) result = await test_module.wallet_get_public_did(self.request) json_response.assert_called_once_with( @@ -359,7 +359,7 @@ async def test_get_public_did(self): "did": self.test_did, "verkey": self.test_verkey, "posture": DIDPosture.PUBLIC.moniker, - "key_type": KeyType.ED25519.key_type, + "key_type": ED25519.key_type, "method": DIDMethod.SOV.method_name, } } @@ -397,7 +397,7 @@ async def test_set_public_did(self): self.test_verkey, DIDPosture.PUBLIC.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) result = await test_module.wallet_set_public_did(self.request) self.wallet.set_public_did.assert_awaited_once() @@ -407,7 +407,7 @@ async def test_set_public_did(self): "did": self.test_did, "verkey": self.test_verkey, "posture": DIDPosture.PUBLIC.moniker, - "key_type": KeyType.ED25519.key_type, + "key_type": ED25519.key_type, "method": DIDMethod.SOV.method_name, } } @@ -495,7 +495,7 @@ async def test_set_public_did_x(self): self.test_verkey, DIDPosture.PUBLIC.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) self.wallet.set_public_did.side_effect = test_module.WalletError() with self.assertRaises(test_module.web.HTTPBadRequest): @@ -526,7 +526,7 @@ async def test_set_public_did_no_wallet_did(self): self.test_verkey, DIDPosture.PUBLIC.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) self.wallet.set_public_did.side_effect = test_module.WalletNotFoundError() with self.assertRaises(test_module.web.HTTPNotFound): @@ -558,7 +558,7 @@ async def test_set_public_did_update_endpoint(self): self.test_verkey, {**DIDPosture.PUBLIC.metadata, "endpoint": "https://endpoint.com"}, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) result = await test_module.wallet_set_public_did(self.request) self.wallet.set_public_did.assert_awaited_once() @@ -568,7 +568,7 @@ async def test_set_public_did_update_endpoint(self): "did": self.test_did, "verkey": self.test_verkey, "posture": DIDPosture.PUBLIC.moniker, - "key_type": KeyType.ED25519.key_type, + "key_type": ED25519.key_type, "method": DIDMethod.SOV.method_name, } } @@ -606,7 +606,7 @@ async def test_set_public_did_update_endpoint_use_default_update_in_wallet(self) self.test_verkey, DIDPosture.PUBLIC.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) self.wallet.get_local_did.return_value = did_info self.wallet.set_public_did.return_value = did_info @@ -626,7 +626,7 @@ async def test_set_public_did_update_endpoint_use_default_update_in_wallet(self) "did": self.test_did, "verkey": self.test_verkey, "posture": DIDPosture.PUBLIC.moniker, - "key_type": KeyType.ED25519.key_type, + "key_type": ED25519.key_type, "method": DIDMethod.SOV.method_name, } } @@ -652,14 +652,14 @@ async def test_set_did_endpoint(self): self.test_verkey, {"public": False, "endpoint": "http://old-endpoint.ca"}, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) self.wallet.get_public_did.return_value = DIDInfo( self.test_did, self.test_verkey, DIDPosture.PUBLIC.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) with async_mock.patch.object( @@ -681,14 +681,14 @@ async def test_set_did_endpoint_public_did_no_ledger(self): self.test_verkey, {"public": False, "endpoint": "http://old-endpoint.ca"}, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) self.wallet.get_public_did.return_value = DIDInfo( self.test_did, self.test_verkey, DIDPosture.PUBLIC.metadata, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) self.wallet.set_did_endpoint.side_effect = test_module.LedgerConfigError() @@ -741,7 +741,7 @@ async def test_get_did_endpoint(self): self.test_verkey, {"public": False, "endpoint": "http://old-endpoint.ca"}, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) with async_mock.patch.object( @@ -789,7 +789,7 @@ async def test_rotate_did_keypair(self): "verkey", {"public": False}, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) ) self.wallet.rotate_did_keypair_start = async_mock.AsyncMock() @@ -824,7 +824,7 @@ async def test_rotate_did_keypair_did_not_local(self): "verkey", {"posted": True, "public": True}, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) ) with self.assertRaises(test_module.web.HTTPBadRequest): @@ -839,7 +839,7 @@ async def test_rotate_did_keypair_x(self): "verkey", {"public": False}, DIDMethod.SOV, - KeyType.ED25519, + ED25519, ) ) self.wallet.rotate_did_keypair_start = async_mock.AsyncMock( From 430202a97a1744ee7633948ff847032e07821101 Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Thu, 22 Sep 2022 13:02:42 -0600 Subject: [PATCH 13/22] static imports Signed-off-by: Adam Burdett --- .../messaging/decorators/tests/test_signature_decorator.py | 2 +- aries_cloudagent/messaging/jsonld/credential.py | 2 +- aries_cloudagent/messaging/jsonld/tests/test_credential.py | 2 +- aries_cloudagent/messaging/jsonld/tests/test_routes.py | 2 +- aries_cloudagent/messaging/tests/test_agent_message.py | 2 +- aries_cloudagent/multitenant/tests/test_base.py | 2 +- aries_cloudagent/protocols/connections/v1_0/manager.py | 2 +- .../v1_0/messages/tests/test_connection_response.py | 2 +- .../protocols/connections/v1_0/tests/test_manager.py | 2 +- .../protocols/coordinate_mediation/v1_0/manager.py | 2 +- .../protocols/coordinate_mediation/v1_0/normalization.py | 2 +- .../protocols/coordinate_mediation/v1_0/route_manager.py | 2 +- .../didexchange/v1_0/handlers/tests/test_request_handler.py | 2 +- .../didexchange/v1_0/handlers/tests/test_response_handler.py | 2 +- aries_cloudagent/protocols/didexchange/v1_0/manager.py | 2 +- .../protocols/didexchange/v1_0/messages/tests/test_request.py | 2 +- .../didexchange/v1_0/messages/tests/test_response.py | 2 +- .../protocols/didexchange/v1_0/tests/test_manager.py | 2 +- .../protocols/endorse_transaction/v1_0/tests/test_manager.py | 2 +- .../protocols/endorse_transaction/v1_0/tests/test_routes.py | 2 +- .../protocols/introduction/v0_1/tests/test_service.py | 2 +- .../issue_credential/v2_0/formats/ld_proof/handler.py | 2 +- .../v2_0/formats/ld_proof/tests/test_handler.py | 4 ++-- .../protocols/issue_credential/v2_0/tests/test_routes.py | 4 ---- .../out_of_band/v1_0/messages/tests/test_invitation.py | 2 +- .../protocols/out_of_band/v1_0/tests/test_manager.py | 2 +- .../protocols/present_proof/dif/pres_exch_handler.py | 2 +- .../protocols/present_proof/v2_0/formats/dif/handler.py | 2 +- aries_cloudagent/transport/tests/test_pack_format.py | 2 +- aries_cloudagent/utils/tests/test_outofband.py | 2 +- aries_cloudagent/vc/ld_proofs/tests/test_ld_proofs.py | 2 +- aries_cloudagent/vc/tests/test_bbs_mattr_interop.py | 2 +- aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py | 2 +- aries_cloudagent/wallet/askar.py | 2 +- aries_cloudagent/wallet/crypto.py | 2 +- aries_cloudagent/wallet/indy.py | 2 +- aries_cloudagent/wallet/tests/test_crypto.py | 2 +- aries_cloudagent/wallet/tests/test_did_method.py | 2 +- aries_cloudagent/wallet/tests/test_in_memory_wallet.py | 2 +- aries_cloudagent/wallet/tests/test_indy_wallet.py | 2 +- aries_cloudagent/wallet/tests/test_key_pair.py | 2 +- aries_cloudagent/wallet/tests/test_key_type.py | 2 +- aries_cloudagent/wallet/tests/test_routes.py | 2 +- 43 files changed, 43 insertions(+), 47 deletions(-) diff --git a/aries_cloudagent/messaging/decorators/tests/test_signature_decorator.py b/aries_cloudagent/messaging/decorators/tests/test_signature_decorator.py index 4eca03663f..de863ca4b9 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_signature_decorator.py +++ b/aries_cloudagent/messaging/decorators/tests/test_signature_decorator.py @@ -1,6 +1,6 @@ from asynctest import TestCase as AsyncTestCase -from ....wallet.key_type import ED25519, KeyType +from ....wallet.key_type import ED25519 from ....core.in_memory import InMemoryProfile from ....protocols.trustping.v1_0.messages.ping import Ping from ....wallet.in_memory import InMemoryWallet diff --git a/aries_cloudagent/messaging/jsonld/credential.py b/aries_cloudagent/messaging/jsonld/credential.py index c584a83502..5c693a0b63 100644 --- a/aries_cloudagent/messaging/jsonld/credential.py +++ b/aries_cloudagent/messaging/jsonld/credential.py @@ -5,7 +5,7 @@ from ...did.did_key import DIDKey from ...vc.ld_proofs import DocumentLoader from ...wallet.base import BaseWallet -from ...wallet.key_type import KeyType +from ...wallet.key_type import ED25519 from ...wallet.util import b64_to_bytes, b64_to_str, bytes_to_b64, str_to_b64 from .create_verify_data import create_verify_data diff --git a/aries_cloudagent/messaging/jsonld/tests/test_credential.py b/aries_cloudagent/messaging/jsonld/tests/test_credential.py index d613ece328..3046388533 100644 --- a/aries_cloudagent/messaging/jsonld/tests/test_credential.py +++ b/aries_cloudagent/messaging/jsonld/tests/test_credential.py @@ -13,7 +13,7 @@ from ....vc.ld_proofs import DocumentLoader from ....wallet.base import BaseWallet from ....wallet.in_memory import InMemoryWallet -from ....wallet.key_type import ED25519, KeyType +from ....wallet.key_type import ED25519 from .. import credential as test_module from ..create_verify_data import DroppedAttributeError diff --git a/aries_cloudagent/messaging/jsonld/tests/test_routes.py b/aries_cloudagent/messaging/jsonld/tests/test_routes.py index 84b66fc341..ff8ce0b8a1 100644 --- a/aries_cloudagent/messaging/jsonld/tests/test_routes.py +++ b/aries_cloudagent/messaging/jsonld/tests/test_routes.py @@ -16,7 +16,7 @@ from ....wallet.base import BaseWallet from ....wallet.did_method import DIDMethod from ....wallet.error import WalletError -from ....wallet.key_type import KeyType +from ....wallet.key_type import ED25519 from ..error import ( BadJWSHeaderError, DroppedAttributeError, diff --git a/aries_cloudagent/messaging/tests/test_agent_message.py b/aries_cloudagent/messaging/tests/test_agent_message.py index 2c4f9f4021..947328da63 100644 --- a/aries_cloudagent/messaging/tests/test_agent_message.py +++ b/aries_cloudagent/messaging/tests/test_agent_message.py @@ -4,7 +4,7 @@ from ...core.in_memory import InMemoryProfile from ...protocols.didcomm_prefix import DIDCommPrefix -from ...wallet.key_type import KeyType +from ...wallet.key_type import ED25519 from ..agent_message import AgentMessage, AgentMessageSchema from ..decorators.signature_decorator import SignatureDecorator diff --git a/aries_cloudagent/multitenant/tests/test_base.py b/aries_cloudagent/multitenant/tests/test_base.py index fa29fc34e3..1c3022104e 100644 --- a/aries_cloudagent/multitenant/tests/test_base.py +++ b/aries_cloudagent/multitenant/tests/test_base.py @@ -20,7 +20,7 @@ from ...wallet.did_info import DIDInfo from ...wallet.did_method import DIDMethod from ...wallet.in_memory import InMemoryWallet -from ...wallet.key_type import KeyType +from ...wallet.key_type import ED25519 from ...wallet.models.wallet_record import WalletRecord from ..base import BaseMultitenantManager, MultitenantManagerError from ..error import WalletKeyMissingError diff --git a/aries_cloudagent/protocols/connections/v1_0/manager.py b/aries_cloudagent/protocols/connections/v1_0/manager.py index 9fa1f897a0..fe65f09dd9 100644 --- a/aries_cloudagent/protocols/connections/v1_0/manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/manager.py @@ -21,7 +21,7 @@ from ....wallet.did_info import DIDInfo from ....wallet.did_method import DIDMethod from ....wallet.error import WalletNotFoundError -from ....wallet.key_type import ED25519, KeyType +from ....wallet.key_type import ED25519 from ....wallet.util import bytes_to_b58 from ...coordinate_mediation.v1_0.manager import MediationManager from ...discovery.v2_0.manager import V20DiscoveryMgr diff --git a/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_response.py b/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_response.py index 2973ade36c..fd47e9c896 100644 --- a/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_response.py +++ b/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_response.py @@ -2,7 +2,7 @@ from asynctest import TestCase as AsyncTestCase -from ......wallet.key_type import ED25519, KeyType +from ......wallet.key_type import ED25519 from ......connections.models.diddoc import ( DIDDoc, PublicKey, diff --git a/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py index 4437ab0d86..2dc670224f 100644 --- a/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py @@ -26,7 +26,7 @@ from .....wallet.did_method import DIDMethod from .....wallet.error import WalletNotFoundError from .....wallet.in_memory import InMemoryWallet -from .....wallet.key_type import KeyType +from .....wallet.key_type import ED25519 from ....coordinate_mediation.v1_0.manager import MediationManager from ....coordinate_mediation.v1_0.route_manager import RouteManager from ....coordinate_mediation.v1_0.messages.mediate_request import MediationRequest diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py index 7a67b57369..913643c1f0 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py @@ -12,7 +12,7 @@ from ....wallet.base import BaseWallet from ....wallet.did_info import DIDInfo from ....wallet.did_method import DIDMethod -from ....wallet.key_type import KeyType +from ....wallet.key_type import ED25519 from ...routing.v1_0.manager import RoutingManager from ...routing.v1_0.models.route_record import RouteRecord from ...routing.v1_0.models.route_update import RouteUpdate diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/normalization.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/normalization.py index c105aa05d5..d699565367 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/normalization.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/normalization.py @@ -1,6 +1,6 @@ """Normalization methods used while transitioning to DID:Key method.""" from ....did.did_key import DIDKey -from ....wallet.key_type import KeyType +from ....wallet.key_type import ED25519 def normalize_from_did_key(key: str): diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/route_manager.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/route_manager.py index 4e03d929a9..7d935a6995 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/route_manager.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/route_manager.py @@ -15,7 +15,7 @@ from ....wallet.base import BaseWallet from ....wallet.did_info import DIDInfo from ....wallet.did_method import DIDMethod -from ....wallet.key_type import KeyType +from ....wallet.key_type import ED25519 from ...routing.v1_0.models.route_record import RouteRecord from .manager import MediationManager from .messages.keylist_update import KeylistUpdate diff --git a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py index 34acf504ba..d9b7d583b0 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py @@ -9,7 +9,7 @@ Service, ) from ......core.in_memory import InMemoryProfile -from ......wallet.key_type import KeyType +from ......wallet.key_type import ED25519 from ......wallet.did_method import DIDMethod from ......messaging.decorators.attach_decorator import AttachDecorator from ......messaging.request_context import RequestContext diff --git a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_response_handler.py b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_response_handler.py index 79e0af0782..2ab4f79919 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_response_handler.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_response_handler.py @@ -13,7 +13,7 @@ from ......messaging.request_context import RequestContext from ......messaging.responder import MockResponder from ......transport.inbound.receipt import MessageReceipt -from ......wallet.key_type import KeyType +from ......wallet.key_type import ED25519 from ......wallet.did_method import DIDMethod from .....problem_report.v1_0.message import ProblemReport diff --git a/aries_cloudagent/protocols/didexchange/v1_0/manager.py b/aries_cloudagent/protocols/didexchange/v1_0/manager.py index 12e6726b87..890a1cc8f8 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/manager.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/manager.py @@ -26,7 +26,7 @@ from ....wallet.did_method import DIDMethod from ....wallet.did_posture import DIDPosture from ....wallet.error import WalletError -from ....wallet.key_type import KeyType +from ....wallet.key_type import ED25519 from ...coordinate_mediation.v1_0.manager import MediationManager from ...discovery.v2_0.manager import V20DiscoveryMgr from ...out_of_band.v1_0.messages.invitation import ( diff --git a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py index b3dae6e2a9..5f55a1cc22 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py @@ -9,7 +9,7 @@ Service, ) from ......wallet.did_method import DIDMethod -from ......wallet.key_type import KeyType +from ......wallet.key_type import ED25519 from ......core.in_memory import InMemoryProfile from ......messaging.decorators.attach_decorator import AttachDecorator diff --git a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py index 78b8443255..e8043de420 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py @@ -9,7 +9,7 @@ Service, ) from ......wallet.did_method import DIDMethod -from ......wallet.key_type import KeyType +from ......wallet.key_type import ED25519 from ......core.in_memory import InMemoryProfile from ......messaging.decorators.attach_decorator import AttachDecorator diff --git a/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py index 8cdbcbc316..de1ea64a4d 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py @@ -29,7 +29,7 @@ from .....wallet.error import WalletError from .....wallet.in_memory import InMemoryWallet from .....wallet.did_method import DIDMethod -from .....wallet.key_type import KeyType +from .....wallet.key_type import ED25519 from .....did.did_key import DIDKey from .....connections.base_manager import BaseConnectionManagerError diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py index 12f898b3be..c0a6cc3b11 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py @@ -17,7 +17,7 @@ from .....wallet.base import BaseWallet from .....wallet.did_info import DIDInfo from .....wallet.did_method import DIDMethod -from .....wallet.key_type import KeyType +from .....wallet.key_type import ED25519 from ..manager import TransactionManager, TransactionManagerError from ..messages.messages_attach import MessagesAttach diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py index 4d40885c0d..6bbc0fc8c2 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py @@ -10,7 +10,7 @@ from .....wallet.base import BaseWallet from .....wallet.did_info import DIDInfo from .....wallet.did_method import DIDMethod -from .....wallet.key_type import KeyType +from .....wallet.key_type import ED25519 from ..models.transaction_record import TransactionRecord from .. import routes as test_module diff --git a/aries_cloudagent/protocols/introduction/v0_1/tests/test_service.py b/aries_cloudagent/protocols/introduction/v0_1/tests/test_service.py index 5947030e4b..ea758821a8 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/tests/test_service.py +++ b/aries_cloudagent/protocols/introduction/v0_1/tests/test_service.py @@ -5,7 +5,7 @@ from .....messaging.request_context import RequestContext from .....messaging.responder import MockResponder from .....did.did_key import DIDKey -from .....wallet.key_type import KeyType +from .....wallet.key_type import ED25519 from ....didcomm_prefix import DIDCommPrefix from ....out_of_band.v1_0.message_types import INVITATION as OOB_INVITATION 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 66177376a2..9863f018d0 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 @@ -35,7 +35,7 @@ from ......vc.ld_proofs.constants import SECURITY_CONTEXT_BBS_URL from ......wallet.base import BaseWallet, DIDInfo from ......wallet.error import WalletNotFoundError -from ......wallet.key_type import KeyType +from ......wallet.key_type import BLS12381G2, ED25519 from ...message_types import ( ATTACHMENT_FORMAT, diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py index 53ea35b095..8283379059 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py @@ -26,7 +26,7 @@ ) from .......vc.ld_proofs.constants import SECURITY_CONTEXT_BBS_URL from .......vc.tests.document_loader import custom_document_loader -from .......wallet.key_type import KeyType +from .......wallet.key_type import BLS12381G1G2, ED25519 from .......wallet.error import WalletNotFoundError from .......wallet.did_method import DIDMethod from .......wallet.base import BaseWallet @@ -230,7 +230,7 @@ async def test_assert_can_issue_with_id_and_proof_type(self): verkey="verkey", metadata={}, method=DIDMethod.SOV, - key_type=BLS12381G2, + key_type=BLS12381G1G2, ) mock_did_info.return_value = invalid_did_info with self.assertRaises(V20CredFormatError) as context: diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_routes.py b/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_routes.py index 3c72c33e75..7a689b66b4 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_routes.py @@ -2,10 +2,6 @@ from asynctest import mock as async_mock, TestCase as AsyncTestCase from .....admin.request_context import AdminRequestContext -from .....wallet.key_type import KeyType -from .....wallet.did_method import DIDMethod -from .....wallet.base import BaseWallet -from .....wallet.did_info import DIDInfo from .. import routes as test_module from ..formats.indy.handler import IndyCredFormatHandler diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/messages/tests/test_invitation.py b/aries_cloudagent/protocols/out_of_band/v1_0/messages/tests/test_invitation.py index f1e215744c..60b3298c4f 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/messages/tests/test_invitation.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/messages/tests/test_invitation.py @@ -4,7 +4,7 @@ from ......messaging.models.base import BaseModelError from ......did.did_key import DIDKey -from ......wallet.key_type import KeyType +from ......wallet.key_type import ED25519 from .....connections.v1_0.message_types import ARIES_PROTOCOL as CONN_PROTO from .....didcomm_prefix import DIDCommPrefix diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py index 1f082ba6df..7bbce062ef 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py @@ -67,7 +67,7 @@ from .....wallet.did_info import DIDInfo, KeyInfo from .....wallet.did_method import DIDMethod from .....wallet.in_memory import InMemoryWallet -from .....wallet.key_type import ED25519, KeyType +from .....wallet.key_type import ED25519 from ....connections.v1_0.messages.connection_invitation import ConnectionInvitation from ....didcomm_prefix import DIDCommPrefix from ....issue_credential.v1_0.message_types import CREDENTIAL_OFFER 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 79a1aa8deb..813dbe287d 100644 --- a/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py +++ b/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py @@ -40,7 +40,7 @@ from ....vc.vc_ld.prove import sign_presentation, create_presentation, derive_credential from ....wallet.base import BaseWallet, DIDInfo from ....wallet.error import WalletError, WalletNotFoundError -from ....wallet.key_type import KeyType +from ....wallet.key_type import BLS12381G2, ED25519 from .pres_exch import ( PresentationDefinition, 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 c69b906085..a55912c1e3 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,7 @@ ) from ......vc.vc_ld.verify import verify_presentation from ......wallet.base import BaseWallet -from ......wallet.key_type import KeyType +from ......wallet.key_type import ED25519, BLS12381G2 from .....problem_report.v1_0.message import ProblemReport diff --git a/aries_cloudagent/transport/tests/test_pack_format.py b/aries_cloudagent/transport/tests/test_pack_format.py index e9d9e5c0e2..b0ea56408f 100644 --- a/aries_cloudagent/transport/tests/test_pack_format.py +++ b/aries_cloudagent/transport/tests/test_pack_format.py @@ -9,7 +9,7 @@ from ...protocols.didcomm_prefix import DIDCommPrefix from ...wallet.base import BaseWallet from ...wallet.error import WalletError -from ...wallet.key_type import KeyType +from ...wallet.key_type import ED25519 from ...wallet.did_method import DIDMethod from .. import pack_format as test_module diff --git a/aries_cloudagent/utils/tests/test_outofband.py b/aries_cloudagent/utils/tests/test_outofband.py index e8f519479c..4305394c30 100644 --- a/aries_cloudagent/utils/tests/test_outofband.py +++ b/aries_cloudagent/utils/tests/test_outofband.py @@ -1,7 +1,7 @@ from asynctest import TestCase from ...protocols.out_of_band.v1_0.messages.invitation import InvitationMessage -from ...wallet.key_type import KeyType +from ...wallet.key_type import ED25519 from ...wallet.did_method import DIDMethod from ...wallet.did_info import DIDInfo 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 b1369f9602..0143cfe17f 100644 --- a/aries_cloudagent/vc/ld_proofs/tests/test_ld_proofs.py +++ b/aries_cloudagent/vc/ld_proofs/tests/test_ld_proofs.py @@ -4,7 +4,7 @@ from asynctest import TestCase -from ....wallet.key_type import KeyType +from ....wallet.key_type import BLS12381G2, ED25519 from ....did.did_key import DIDKey from ....wallet.in_memory import InMemoryWallet from ....core.in_memory import InMemoryProfile diff --git a/aries_cloudagent/vc/tests/test_bbs_mattr_interop.py b/aries_cloudagent/vc/tests/test_bbs_mattr_interop.py index cbc8aa795a..d9f4dde009 100644 --- a/aries_cloudagent/vc/tests/test_bbs_mattr_interop.py +++ b/aries_cloudagent/vc/tests/test_bbs_mattr_interop.py @@ -1,7 +1,7 @@ from asynctest import TestCase import pytest -from ...wallet.key_type import KeyType +from ...wallet.key_type import BLS12381G2 from ...wallet.util import b58_to_bytes from ...wallet.in_memory import InMemoryWallet from ...core.in_memory import InMemoryProfile 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 121c76d50d..3c3643ec1a 100644 --- a/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py +++ b/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py @@ -3,7 +3,7 @@ import pytest -from ....wallet.key_type import KeyType +from ....wallet.key_type import BLS12381G2, ED25519 from ....did.did_key import DIDKey from ....wallet.in_memory import InMemoryWallet from ....core.in_memory import InMemoryProfile diff --git a/aries_cloudagent/wallet/askar.py b/aries_cloudagent/wallet/askar.py index b881dbba13..b8b26bee93 100644 --- a/aries_cloudagent/wallet/askar.py +++ b/aries_cloudagent/wallet/askar.py @@ -33,7 +33,7 @@ ) from .did_method import DIDMethod from .error import WalletError, WalletDuplicateError, WalletNotFoundError -from .key_type import ED25519, KeyType +from .key_type import BLS12381G2, ED25519, KeyType from .util import b58_to_bytes, bytes_to_b58 CATEGORY_DID = "did" diff --git a/aries_cloudagent/wallet/crypto.py b/aries_cloudagent/wallet/crypto.py index 34615d908f..f44e9cff77 100644 --- a/aries_cloudagent/wallet/crypto.py +++ b/aries_cloudagent/wallet/crypto.py @@ -14,7 +14,7 @@ from ..utils.jwe import JweRecipient, b64url, JweEnvelope, from_b64url from .error import WalletError from .util import bytes_to_b58, b64_to_bytes, b58_to_bytes, random_seed -from .key_type import KeyType +from .key_type import ED25519, BLS12381G2, KeyType from .bbs import ( create_bls12381g2_keypair, verify_signed_messages_bls12381g2, diff --git a/aries_cloudagent/wallet/indy.py b/aries_cloudagent/wallet/indy.py index b34f041c23..9e28e9fbca 100644 --- a/aries_cloudagent/wallet/indy.py +++ b/aries_cloudagent/wallet/indy.py @@ -33,7 +33,7 @@ from .did_method import DIDMethod from .error import WalletError, WalletDuplicateError, WalletNotFoundError from .key_pair import KeyPairStorageManager -from .key_type import KeyType +from .key_type import BLS12381G2, ED25519, KeyType from .util import b58_to_bytes, bytes_to_b58, bytes_to_b64 diff --git a/aries_cloudagent/wallet/tests/test_crypto.py b/aries_cloudagent/wallet/tests/test_crypto.py index 2e72c3b70f..f682e40673 100644 --- a/aries_cloudagent/wallet/tests/test_crypto.py +++ b/aries_cloudagent/wallet/tests/test_crypto.py @@ -3,7 +3,7 @@ from unittest import mock, TestCase -from ..key_type import ED25519 +from ..key_type import BLS12381G1, ED25519 from ..error import WalletError from ...utils.jwe import JweRecipient from ..util import str_to_b64 diff --git a/aries_cloudagent/wallet/tests/test_did_method.py b/aries_cloudagent/wallet/tests/test_did_method.py index 834ac63fb9..6bd147777f 100644 --- a/aries_cloudagent/wallet/tests/test_did_method.py +++ b/aries_cloudagent/wallet/tests/test_did_method.py @@ -1,7 +1,7 @@ from unittest import TestCase -from ..key_type import KeyType +from ..key_type import BLS12381G1, BLS12381G1G2, BLS12381G2, ED25519, X25519, KeyType ED25519_PREFIX_BYTES = b"\xed\x01" BLS12381G1_PREFIX_BYTES = b"\xea\x01" diff --git a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py index 97cdcea8cb..fd550cbf1f 100644 --- a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py +++ b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py @@ -4,7 +4,7 @@ from ...core.in_memory import InMemoryProfile from ...messaging.decorators.signature_decorator import SignatureDecorator from ...wallet.in_memory import InMemoryWallet -from ...wallet.key_type import BLS12381G2, ED25519, KeyType +from ...wallet.key_type import BLS12381G2, ED25519 from ...wallet.did_method import DIDMethod from ...wallet.error import ( WalletError, diff --git a/aries_cloudagent/wallet/tests/test_indy_wallet.py b/aries_cloudagent/wallet/tests/test_indy_wallet.py index 7d05d78233..7a1c22903b 100644 --- a/aries_cloudagent/wallet/tests/test_indy_wallet.py +++ b/aries_cloudagent/wallet/tests/test_indy_wallet.py @@ -17,7 +17,7 @@ from ...indy.sdk.profile import IndySdkProfile, IndySdkProfileManager from ...indy.sdk.wallet_setup import IndyWalletConfig from ...ledger.endpoint_type import EndpointType -from ...wallet.key_type import ED25519, KeyType +from ...wallet.key_type import ED25519 from ...wallet.did_method import DIDMethod from ...ledger.indy import IndySdkLedgerPool diff --git a/aries_cloudagent/wallet/tests/test_key_pair.py b/aries_cloudagent/wallet/tests/test_key_pair.py index 843cae21af..6d0ddccb67 100644 --- a/aries_cloudagent/wallet/tests/test_key_pair.py +++ b/aries_cloudagent/wallet/tests/test_key_pair.py @@ -4,7 +4,7 @@ from ...storage.error import StorageNotFoundError from ..util import bytes_to_b58 -from ..key_type import KeyType +from ..key_type import ED25519 from ...core.in_memory import InMemoryProfile from ...storage.in_memory import InMemoryStorage from ..key_pair import KeyPairStorageManager, KEY_PAIR_STORAGE_TYPE diff --git a/aries_cloudagent/wallet/tests/test_key_type.py b/aries_cloudagent/wallet/tests/test_key_type.py index 984ebcbd22..69c77a80fa 100644 --- a/aries_cloudagent/wallet/tests/test_key_type.py +++ b/aries_cloudagent/wallet/tests/test_key_type.py @@ -2,7 +2,7 @@ from ...core.error import BaseError from ..did_method import DIDMethod -from ..key_type import BLS12381G2, ED25519, KeyType +from ..key_type import BLS12381G2, ED25519 SOV_DID_METHOD_NAME = "sov" SOV_SUPPORTED_KEY_TYPES = [ED25519] diff --git a/aries_cloudagent/wallet/tests/test_routes.py b/aries_cloudagent/wallet/tests/test_routes.py index c6a017b0ab..c657a99780 100644 --- a/aries_cloudagent/wallet/tests/test_routes.py +++ b/aries_cloudagent/wallet/tests/test_routes.py @@ -9,7 +9,7 @@ from ...ledger.base import BaseLedger from ...protocols.coordinate_mediation.v1_0.route_manager import RouteManager from ...wallet.did_method import DIDMethod -from ...wallet.key_type import KeyType +from ...wallet.key_type import ED25519 from ..base import BaseWallet from ..did_info import DIDInfo from ..did_posture import DIDPosture From 9a80789730da57a506e33677cbdcf7a7950a649e Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Thu, 22 Sep 2022 13:31:08 -0600 Subject: [PATCH 14/22] use keytype registry Signed-off-by: Adam Burdett --- aries_cloudagent/config/default_context.py | 2 + aries_cloudagent/did/did_key.py | 16 +++- .../did/tests/test_did_key_bls12381g1.py | 4 +- .../did/tests/test_did_key_bls12381g1g2.py | 4 +- .../did/tests/test_did_key_bls12381g2.py | 4 +- .../present_proof/v2_0/formats/dif/handler.py | 4 +- .../tests/test_bbs_bls_signature_2020.py | 4 +- .../tests/test_ed25519_signature_2018.py | 4 +- aries_cloudagent/wallet/indy.py | 6 +- aries_cloudagent/wallet/key_type.py | 4 - aries_cloudagent/wallet/routes.py | 38 +++++----- aries_cloudagent/wallet/tests/test_crypto.py | 8 +- .../wallet/tests/test_did_method.py | 74 ++++++++----------- .../wallet/tests/test_in_memory_wallet.py | 24 ++---- 14 files changed, 83 insertions(+), 113 deletions(-) diff --git a/aries_cloudagent/config/default_context.py b/aries_cloudagent/config/default_context.py index 0c5f90cac2..4c8483f5ee 100644 --- a/aries_cloudagent/config/default_context.py +++ b/aries_cloudagent/config/default_context.py @@ -22,6 +22,7 @@ from ..transport.wire_format import BaseWireFormat from ..utils.stats import Collector from ..utils.dependencies import is_indy_sdk_module_installed +from ..wallet.key_type import KeyTypes class DefaultContextBuilder(ContextBuilder): @@ -51,6 +52,7 @@ async def build_context(self) -> InjectionContext: # Global did resolver context.injector.bind_instance(DIDResolver, DIDResolver([])) + context.injector.bind_instance(KeyTypes, KeyTypes()) await self.bind_providers(context) await self.load_plugins(context) diff --git a/aries_cloudagent/did/did_key.py b/aries_cloudagent/did/did_key.py index c85a66fc8b..3a74971612 100644 --- a/aries_cloudagent/did/did_key.py +++ b/aries_cloudagent/did/did_key.py @@ -1,7 +1,15 @@ """DID Key class and resolver methods.""" from ..wallet.crypto import ed25519_pk_to_curve25519 -from ..wallet.key_type import BLS12381G1G2, ED25519, KeyType, BLS12381G1, X25519, BLS12381G2 +from ..wallet.key_type import ( + BLS12381G1G2, + ED25519, + KeyType, + BLS12381G1, + X25519, + BLS12381G2, + KeyTypes, +) from ..wallet.util import b58_to_bytes, bytes_to_b58 from ..vc.ld_proofs.constants import DID_V1_CONTEXT_URL @@ -31,7 +39,7 @@ def from_public_key_b58(cls, public_key: str, key_type: KeyType) -> "DIDKey": return cls.from_public_key(public_key_bytes, key_type) @classmethod - def from_fingerprint(cls, fingerprint: str) -> "DIDKey": + def from_fingerprint(cls, fingerprint: str, key_types=None) -> "DIDKey": """Initialize new DIDKey instance from multibase encoded fingerprint. The fingerprint contains both the public key and key type. @@ -43,7 +51,9 @@ def from_fingerprint(cls, fingerprint: str) -> "DIDKey": key_bytes_with_prefix = b58_to_bytes(fingerprint[1:]) # Get associated key type with prefixed bytes - key_type = KeyType.from_prefixed_bytes(key_bytes_with_prefix) + if not key_types: + key_types = KeyTypes() + key_type = key_types.from_prefixed_bytes(key_bytes_with_prefix) if not key_type: raise Exception( diff --git a/aries_cloudagent/did/tests/test_did_key_bls12381g1.py b/aries_cloudagent/did/tests/test_did_key_bls12381g1.py index b110bc2b2f..f5b84b3bd0 100644 --- a/aries_cloudagent/did/tests/test_did_key_bls12381g1.py +++ b/aries_cloudagent/did/tests/test_did_key_bls12381g1.py @@ -29,9 +29,7 @@ def test_bls12381g1_from_public_key(self): assert did_key.did == TEST_BLS12381G1_DID def test_bls12381g1_from_public_key_b58(self): - did_key = DIDKey.from_public_key_b58( - TEST_BLS12381G1_BASE58_KEY, BLS12381G1 - ) + did_key = DIDKey.from_public_key_b58(TEST_BLS12381G1_BASE58_KEY, BLS12381G1) assert did_key.did == TEST_BLS12381G1_DID diff --git a/aries_cloudagent/did/tests/test_did_key_bls12381g1g2.py b/aries_cloudagent/did/tests/test_did_key_bls12381g1g2.py index 3b5a21c8cd..f5ed77e64d 100644 --- a/aries_cloudagent/did/tests/test_did_key_bls12381g1g2.py +++ b/aries_cloudagent/did/tests/test_did_key_bls12381g1g2.py @@ -36,9 +36,7 @@ def test_bls12381g1g2_from_public_key(self): assert did_key.did == TEST_BLS12381G1G2_DID def test_bls12381g1g2_from_public_key_b58(self): - did_key = DIDKey.from_public_key_b58( - TEST_BLS12381G1G2_BASE58_KEY, BLS12381G1G2 - ) + did_key = DIDKey.from_public_key_b58(TEST_BLS12381G1G2_BASE58_KEY, BLS12381G1G2) assert did_key.did == TEST_BLS12381G1G2_DID diff --git a/aries_cloudagent/did/tests/test_did_key_bls12381g2.py b/aries_cloudagent/did/tests/test_did_key_bls12381g2.py index ddd1259b97..0eb4b4c8f4 100644 --- a/aries_cloudagent/did/tests/test_did_key_bls12381g2.py +++ b/aries_cloudagent/did/tests/test_did_key_bls12381g2.py @@ -24,9 +24,7 @@ def test_bls12381g2_from_public_key(self): assert did_key.did == TEST_BLS12381G2_DID def test_bls12381g2_from_public_key_b58(self): - did_key = DIDKey.from_public_key_b58( - TEST_BLS12381G2_BASE58_KEY, BLS12381G2 - ) + did_key = DIDKey.from_public_key_b58(TEST_BLS12381G2_BASE58_KEY, BLS12381G2) assert did_key.did == TEST_BLS12381G2_DID 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 a55912c1e3..5459213d3f 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 @@ -61,9 +61,7 @@ class DIFPresFormatHandler(V20PresFormatHandler): if BbsBlsSignature2020.BBS_SUPPORTED: ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING[BbsBlsSignature2020] = BLS12381G2 - ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING[ - BbsBlsSignatureProof2020 - ] = BLS12381G2 + ISSUE_SIGNATURE_SUITE_KEY_TYPE_MAPPING[BbsBlsSignatureProof2020] = BLS12381G2 async def _get_all_suites(self, wallet: BaseWallet): """Get all supported suites for verifying presentation.""" 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 7fac62baad..de3efe4475 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 @@ -41,9 +41,7 @@ async def setUp(self): 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(wallet=self.wallet, key_type=BLS12381G2) async def test_sign_ld_proofs(self): signed = await sign( 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 88dca016d3..46e9b02558 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 @@ -40,9 +40,7 @@ async def setUp(self): 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(wallet=self.wallet, key_type=ED25519) async def test_sign_ld_proofs(self): signed = await sign( diff --git a/aries_cloudagent/wallet/indy.py b/aries_cloudagent/wallet/indy.py index 9e28e9fbca..7e02feb6e9 100644 --- a/aries_cloudagent/wallet/indy.py +++ b/aries_cloudagent/wallet/indy.py @@ -33,7 +33,7 @@ from .did_method import DIDMethod from .error import WalletError, WalletDuplicateError, WalletNotFoundError from .key_pair import KeyPairStorageManager -from .key_type import BLS12381G2, ED25519, KeyType +from .key_type import BLS12381G2, ED25519, KeyType, KeyTypes from .util import b58_to_bytes, bytes_to_b58, bytes_to_b64 @@ -71,7 +71,9 @@ def __did_info_from_key_pair_info(self, info: dict): # this needs to change if other did methods are added method = DIDMethod.from_method(info["metadata"].get("method", "key")) - key_type = KeyType.from_key_type(info["key_type"]) + # TODO: inject context to support keytype registry + key_types = KeyTypes() + key_type = key_types.from_key_type(info["key_type"]) if method == DIDMethod.KEY: did = DIDKey.from_public_key_b58(info["verkey"], key_type).did diff --git a/aries_cloudagent/wallet/key_type.py b/aries_cloudagent/wallet/key_type.py index 901da168c5..bb8f2c6718 100644 --- a/aries_cloudagent/wallet/key_type.py +++ b/aries_cloudagent/wallet/key_type.py @@ -28,10 +28,6 @@ def multicodec_prefix(self) -> bytes: return self._prefix -class KeyTypeException(BaseException): - """Key type exception.""" - - # NOTE: the py_multicodec library is outdated. We use hardcoded prefixes here # until this PR gets released: https://github.com/multiformats/py-multicodec/pull/14 # multicodec is also not used now, but may be used again if py_multicodec is updated diff --git a/aries_cloudagent/wallet/routes.py b/aries_cloudagent/wallet/routes.py index bb6fa58236..b3c9ff80df 100644 --- a/aries_cloudagent/wallet/routes.py +++ b/aries_cloudagent/wallet/routes.py @@ -41,7 +41,7 @@ from .did_method import DIDMethod from .did_posture import DIDPosture from .error import WalletError, WalletNotFoundError -from .key_type import BLS12381G2, ED25519, KeyType +from .key_type import BLS12381G2, ED25519, KeyType, KeyTypes from .util import EVENT_LISTENER_PATTERN LOGGER = logging.getLogger(__name__) @@ -72,9 +72,7 @@ class DIDSchema(OpenAPISchema): key_type = fields.Str( description="Key type associated with the DID", example=ED25519.key_type, - validate=validate.OneOf( - [ED25519.key_type, BLS12381G2.key_type] - ), + validate=validate.OneOf([ED25519.key_type, BLS12381G2.key_type]), ) @@ -143,9 +141,7 @@ class DIDListQueryStringSchema(OpenAPISchema): key_type = fields.Str( required=False, example=ED25519.key_type, - validate=validate.OneOf( - [ED25519.key_type, BLS12381G2.key_type] - ), + validate=validate.OneOf([ED25519.key_type, BLS12381G2.key_type]), description="Key type to query for.", ) @@ -162,9 +158,7 @@ class DIDCreateOptionsSchema(OpenAPISchema): key_type = fields.Str( required=True, example=ED25519.key_type, - validate=validate.OneOf( - [ED25519.key_type, BLS12381G2.key_type] - ), + validate=validate.OneOf([ED25519.key_type, BLS12381G2.key_type]), ) @@ -246,9 +240,10 @@ async def wallet_did_list(request: web.BaseRequest): filter_verkey = request.query.get("verkey") filter_method = DIDMethod.from_method(request.query.get("method")) filter_posture = DIDPosture.get(request.query.get("posture")) - filter_key_type = KeyType.from_key_type(request.query.get("key_type")) results = [] async with context.session() as session: + key_types = session.inject(KeyTypes) + filter_key_type = key_types.from_key_type(request.query.get("key_type", "")) wallet = session.inject_or(BaseWallet) if not wallet: raise web.HTTPForbidden(reason="No wallet available") @@ -353,21 +348,26 @@ async def wallet_create_did(request: web.BaseRequest): body = {} # set default method and key type for backwards compat - key_type = KeyType.from_key_type(body.get("options", {}).get("key_type")) or ED25519 method = DIDMethod.from_method(body.get("method")) or DIDMethod.SOV - if not method.supports_key_type(key_type): - raise web.HTTPForbidden( - reason=( - f"method {method.method_name} does not" - f" support key type {key_type.key_type}" - ) - ) seed = body.get("seed") or None if seed and not context.settings.get("wallet.allow_insecure_seed"): raise web.HTTPBadRequest(reason="Seed support is not enabled") info = None async with context.session() as session: + key_types = session.inject(KeyTypes) + # set default method and key type for backwards compat + key_type = ( + key_types.from_key_type(body.get("options", {}).get("key_type", "")) + or ED25519 + ) + if not method.supports_key_type(key_type): + raise web.HTTPForbidden( + reason=( + f"method {method.method_name} does not" + f" support key type {key_type.key_type}" + ) + ) wallet = session.inject_or(BaseWallet) if not wallet: raise web.HTTPForbidden(reason="No wallet available") diff --git a/aries_cloudagent/wallet/tests/test_crypto.py b/aries_cloudagent/wallet/tests/test_crypto.py index f682e40673..43b0d03452 100644 --- a/aries_cloudagent/wallet/tests/test_crypto.py +++ b/aries_cloudagent/wallet/tests/test_crypto.py @@ -32,9 +32,7 @@ def test_validate_seed(self): def test_seeds_keys(self): assert len(test_module.seed_to_did(SEED)) in (22, 23) - (public_key, secret_key) = test_module.create_keypair( - test_module.ED25519 - ) + (public_key, secret_key) = test_module.create_keypair(test_module.ED25519) assert public_key assert secret_key @@ -161,9 +159,7 @@ def test_sign_ed25519_x_multiple_messages(self): def test_sign_x_unsupported_key_type(self): with self.assertRaises(WalletError) as context: - test_module.sign_message( - [b"message1", b"message2"], b"secret", BLS12381G1 - ) + test_module.sign_message([b"message1", b"message2"], b"secret", BLS12381G1) assert "Unsupported key type: bls12381g1" in str(context.exception) def test_verify_ed25519_x_multiple_messages(self): diff --git a/aries_cloudagent/wallet/tests/test_did_method.py b/aries_cloudagent/wallet/tests/test_did_method.py index 6bd147777f..a952844383 100644 --- a/aries_cloudagent/wallet/tests/test_did_method.py +++ b/aries_cloudagent/wallet/tests/test_did_method.py @@ -1,7 +1,7 @@ from unittest import TestCase -from ..key_type import BLS12381G1, BLS12381G1G2, BLS12381G2, ED25519, X25519, KeyType +from ..key_type import BLS12381G1, BLS12381G1G2, BLS12381G2, ED25519, X25519, KeyTypes ED25519_PREFIX_BYTES = b"\xed\x01" BLS12381G1_PREFIX_BYTES = b"\xea\x01" @@ -24,84 +24,72 @@ class TestKeyType(TestCase): def test_from_multicodec_name(self): - - assert KeyType.from_multicodec_name(ED25519_MULTICODEC_NAME) == ED25519 - assert KeyType.from_multicodec_name(X25519_MULTICODEC_NAME) == X25519 - assert ( - KeyType.from_multicodec_name(BLS12381G1_MULTICODEC_NAME) - == BLS12381G1 - ) - assert ( - KeyType.from_multicodec_name(BLS12381G2_MULTICODEC_NAME) - == BLS12381G2 - ) + key_types = KeyTypes() + assert key_types.from_multicodec_name(ED25519_MULTICODEC_NAME) == ED25519 + assert key_types.from_multicodec_name(X25519_MULTICODEC_NAME) == X25519 + assert key_types.from_multicodec_name(BLS12381G1_MULTICODEC_NAME) == BLS12381G1 + assert key_types.from_multicodec_name(BLS12381G2_MULTICODEC_NAME) == BLS12381G2 assert ( - KeyType.from_multicodec_name(BLS12381G1G2_MULTICODEC_NAME) - == BLS12381G1G2 + key_types.from_multicodec_name(BLS12381G1G2_MULTICODEC_NAME) == BLS12381G1G2 ) - assert KeyType.from_multicodec_name("non-existing") == None + assert key_types.from_multicodec_name("non-existing") == None def test_from_key_type(self): - - assert KeyType.from_key_type(ED25519_KEY_NAME) == ED25519 - assert KeyType.from_key_type(X25519_KEY_NAME) == X25519 - assert KeyType.from_key_type(BLS12381G1_KEY_NAME) == BLS12381G1 - assert KeyType.from_key_type(BLS12381G2_KEY_NAME) == BLS12381G2 - assert KeyType.from_key_type(BLS12381G1G2_KEY_NAME) == BLS12381G1G2 - assert KeyType.from_key_type("non-existing") == None + key_types = KeyTypes() + assert key_types.from_key_type(ED25519_KEY_NAME) == ED25519 + assert key_types.from_key_type(X25519_KEY_NAME) == X25519 + assert key_types.from_key_type(BLS12381G1_KEY_NAME) == BLS12381G1 + assert key_types.from_key_type(BLS12381G2_KEY_NAME) == BLS12381G2 + assert key_types.from_key_type(BLS12381G1G2_KEY_NAME) == BLS12381G1G2 + assert key_types.from_key_type("non-existing") == None def test_from_multicodec_prefix(self): - - assert KeyType.from_multicodec_prefix(ED25519_PREFIX_BYTES) == ED25519 - assert KeyType.from_multicodec_prefix(X25519_PREFIX_BYTES) == X25519 + key_types = KeyTypes() + assert key_types.from_multicodec_prefix(ED25519_PREFIX_BYTES) == ED25519 + assert key_types.from_multicodec_prefix(X25519_PREFIX_BYTES) == X25519 + assert key_types.from_multicodec_prefix(BLS12381G1_PREFIX_BYTES) == BLS12381G1 + assert key_types.from_multicodec_prefix(BLS12381G2_PREFIX_BYTES) == BLS12381G2 assert ( - KeyType.from_multicodec_prefix(BLS12381G1_PREFIX_BYTES) - == BLS12381G1 + key_types.from_multicodec_prefix(BLS12381G1G2_PREFIX_BYTES) == BLS12381G1G2 ) - assert ( - KeyType.from_multicodec_prefix(BLS12381G2_PREFIX_BYTES) - == BLS12381G2 - ) - assert ( - KeyType.from_multicodec_prefix(BLS12381G1G2_PREFIX_BYTES) - == BLS12381G1G2 - ) - assert KeyType.from_multicodec_prefix(b"\xef\x01") == None + assert key_types.from_multicodec_prefix(b"\xef\x01") == None def test_from_prefixed_bytes(self): - + key_types = KeyTypes() assert ( - KeyType.from_prefixed_bytes( + key_types.from_prefixed_bytes( b"".join([ED25519_PREFIX_BYTES, b"random-bytes"]) ) == ED25519 ) assert ( - KeyType.from_prefixed_bytes( + key_types.from_prefixed_bytes( b"".join([X25519_PREFIX_BYTES, b"random-bytes"]) ) == X25519 ) assert ( - KeyType.from_prefixed_bytes( + key_types.from_prefixed_bytes( b"".join([BLS12381G1_PREFIX_BYTES, b"random-bytes"]) ) == BLS12381G1 ) assert ( - KeyType.from_prefixed_bytes( + key_types.from_prefixed_bytes( b"".join([BLS12381G2_PREFIX_BYTES, b"random-bytes"]) ) == BLS12381G2 ) assert ( - KeyType.from_prefixed_bytes( + key_types.from_prefixed_bytes( b"".join([BLS12381G1G2_PREFIX_BYTES, b"random-bytes"]) ) == BLS12381G1G2 ) assert ( - KeyType.from_prefixed_bytes(b"".join([b"\xef\x01", b"other-random-bytes"])) + key_types.from_prefixed_bytes( + b"".join([b"\xef\x01", b"other-random-bytes"]) + ) == None ) diff --git a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py index fd550cbf1f..bfcf2e0581 100644 --- a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py +++ b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py @@ -141,9 +141,7 @@ async def test_create_local_key_random_ed25519(self, wallet: InMemoryWallet): @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_create_local_key_random_bls12381g2(self, wallet: InMemoryWallet): - info = await wallet.create_local_did( - DIDMethod.KEY, BLS12381G2, None, None - ) + info = await wallet.create_local_did(DIDMethod.KEY, BLS12381G2, None, None) assert info and info.did and info.verkey @pytest.mark.asyncio @@ -179,9 +177,7 @@ async def test_create_local_key_seeded_bls12381g2(self, wallet: InMemoryWallet): assert info.verkey == self.test_bls12381g2_verkey # should not raise WalletDuplicateError - same verkey - await wallet.create_local_did( - DIDMethod.KEY, BLS12381G2, self.test_seed, None - ) + await wallet.create_local_did(DIDMethod.KEY, BLS12381G2, self.test_seed, None) with pytest.raises(WalletError): _ = await wallet.create_local_did( @@ -484,9 +480,7 @@ async def test_sign_verify(self, wallet: InMemoryWallet): @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_sign_verify_bbs(self, wallet: InMemoryWallet): - info = await wallet.create_local_did( - DIDMethod.KEY, BLS12381G2, self.test_seed - ) + info = await wallet.create_local_did(DIDMethod.KEY, BLS12381G2, self.test_seed) message_bin = self.test_message.encode("ascii") signature = await wallet.sign_message(message_bin, info.verkey) assert signature @@ -524,21 +518,15 @@ async def test_sign_verify_bbs(self, wallet: InMemoryWallet): assert "Verkey not provided" in str(excinfo.value) with pytest.raises(WalletError) as excinfo: - await wallet.verify_message( - message_bin, signature, None, BLS12381G2 - ) + await wallet.verify_message(message_bin, signature, None, BLS12381G2) assert "Verkey not provided" in str(excinfo.value) with pytest.raises(WalletError) as excinfo: - await wallet.verify_message( - message_bin, None, info.verkey, BLS12381G2 - ) + await wallet.verify_message(message_bin, None, info.verkey, BLS12381G2) assert "Signature not provided" in str(excinfo.value) with pytest.raises(WalletError) as excinfo: - await wallet.verify_message( - None, message_bin, info.verkey, BLS12381G2 - ) + await wallet.verify_message(None, message_bin, info.verkey, BLS12381G2) assert "Message not provided" in str(excinfo.value) @pytest.mark.asyncio From b4a6fd94088f1bfed3a0f369f284bb09407cb51a Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Thu, 22 Sep 2022 17:05:26 -0600 Subject: [PATCH 15/22] some passing tests Signed-off-by: Adam Burdett --- .../issue_credential/v2_0/formats/ld_proof/handler.py | 7 +++---- .../v2_0/formats/ld_proof/tests/test_handler.py | 4 ++-- .../present_proof/dif/tests/test_pres_exch_handler.py | 2 ++ .../vc/ld_proofs/crypto/tests/test_wallet_key_pair.py | 2 ++ .../ld_proofs/suites/tests/test_bbs_bls_signature_2020.py | 2 ++ .../suites/tests/test_bbs_bls_signature_proof_2020.py | 2 ++ .../ld_proofs/suites/tests/test_ed25519_signature_2018.py | 2 ++ aries_cloudagent/wallet/routes.py | 2 +- aries_cloudagent/wallet/tests/test_in_memory_wallet.py | 2 +- 9 files changed, 17 insertions(+), 8 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 9863f018d0..2f3c8f7985 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 @@ -1,5 +1,6 @@ """V2.0 issue-credential linked data proof credential format handler.""" + from ......vc.ld_proofs.error import LinkedDataProofException from ......vc.ld_proofs.check import get_properties_without_context import logging @@ -73,10 +74,8 @@ SIGNATURE_SUITE_KEY_TYPE_MAPPING[BbsBlsSignature2020] = BLS12381G2 -PROOF_TYPE_SIGNATURE_SUITE_MAPPING = { - suite.signature_type: suite - for suite, key_type in SIGNATURE_SUITE_KEY_TYPE_MAPPING.items() -} +PROOF_TYPE_SIGNATURE_SUITE_MAPPING = {suite.signature_type: suite for suite in SIGNATURE_SUITE_KEY_TYPE_MAPPING} + KEY_TYPE_SIGNATURE_SUITE_MAPPING = { key_type: suite for suite, key_type in SIGNATURE_SUITE_KEY_TYPE_MAPPING.items() diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py index 8283379059..8417b2f405 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py @@ -26,7 +26,7 @@ ) from .......vc.ld_proofs.constants import SECURITY_CONTEXT_BBS_URL from .......vc.tests.document_loader import custom_document_loader -from .......wallet.key_type import BLS12381G1G2, ED25519 +from .......wallet.key_type import BLS12381G1G2, BLS12381G2, ED25519 from .......wallet.error import WalletNotFoundError from .......wallet.did_method import DIDMethod from .......wallet.base import BaseWallet @@ -230,7 +230,7 @@ async def test_assert_can_issue_with_id_and_proof_type(self): verkey="verkey", metadata={}, method=DIDMethod.SOV, - key_type=BLS12381G1G2, + key_type=BLS12381G2, ) mock_did_info.return_value = invalid_did_info with self.assertRaises(V20CredFormatError) as context: diff --git a/aries_cloudagent/protocols/present_proof/dif/tests/test_pres_exch_handler.py b/aries_cloudagent/protocols/present_proof/dif/tests/test_pres_exch_handler.py index 110252fd97..78be6ffab7 100644 --- a/aries_cloudagent/protocols/present_proof/dif/tests/test_pres_exch_handler.py +++ b/aries_cloudagent/protocols/present_proof/dif/tests/test_pres_exch_handler.py @@ -6,6 +6,8 @@ import mock as async_mock import pytest +from aries_cloudagent.wallet.key_type import BLS12381G2, ED25519 + from .....core.in_memory import InMemoryProfile from .....did.did_key import DIDKey from .....resolver.did_resolver import DIDResolver 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 4ae0a83753..6c82afad01 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 @@ -1,5 +1,7 @@ from asynctest import TestCase, mock as async_mock +from aries_cloudagent.wallet.key_type import ED25519 + from .....wallet.key_pair import KeyType from ...error import LinkedDataProofException 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 de3efe4475..bb3bc4d523 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 @@ -1,6 +1,8 @@ from asynctest import TestCase, mock as async_mock import pytest +from aries_cloudagent.wallet.key_type import BLS12381G2 + from .....did.did_key import DIDKey from .....wallet.key_pair import KeyType from .....wallet.in_memory import InMemoryWallet 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 e60f923983..67d027d770 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 @@ -1,6 +1,8 @@ from asynctest import TestCase, mock as async_mock import pytest +from aries_cloudagent.wallet.key_type import BLS12381G2 + from .....did.did_key import DIDKey from .....wallet.key_pair import KeyType from .....wallet.in_memory import InMemoryWallet 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 46e9b02558..60bf0389f6 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 @@ -1,5 +1,7 @@ from asynctest import TestCase +from aries_cloudagent.wallet.key_type import ED25519 + from .....did.did_key import DIDKey from .....wallet.key_pair import KeyType diff --git a/aries_cloudagent/wallet/routes.py b/aries_cloudagent/wallet/routes.py index b3c9ff80df..fad1efd2fc 100644 --- a/aries_cloudagent/wallet/routes.py +++ b/aries_cloudagent/wallet/routes.py @@ -41,7 +41,7 @@ from .did_method import DIDMethod from .did_posture import DIDPosture from .error import WalletError, WalletNotFoundError -from .key_type import BLS12381G2, ED25519, KeyType, KeyTypes +from .key_type import BLS12381G2, ED25519, KeyTypes from .util import EVENT_LISTENER_PATTERN LOGGER = logging.getLogger(__name__) diff --git a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py index bfcf2e0581..b5a68d5207 100644 --- a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py +++ b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py @@ -4,7 +4,7 @@ from ...core.in_memory import InMemoryProfile from ...messaging.decorators.signature_decorator import SignatureDecorator from ...wallet.in_memory import InMemoryWallet -from ...wallet.key_type import BLS12381G2, ED25519 +from ...wallet.key_type import BLS12381G1, BLS12381G1G2, BLS12381G2, ED25519, X25519 from ...wallet.did_method import DIDMethod from ...wallet.error import ( WalletError, From 0c3382372c1fa4c71241c17a490ae50a2615ad7a Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Thu, 22 Sep 2022 17:11:02 -0600 Subject: [PATCH 16/22] passing unit tests Signed-off-by: Adam Burdett --- aries_cloudagent/wallet/tests/test_routes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aries_cloudagent/wallet/tests/test_routes.py b/aries_cloudagent/wallet/tests/test_routes.py index c657a99780..103a68d0b3 100644 --- a/aries_cloudagent/wallet/tests/test_routes.py +++ b/aries_cloudagent/wallet/tests/test_routes.py @@ -9,7 +9,7 @@ from ...ledger.base import BaseLedger from ...protocols.coordinate_mediation.v1_0.route_manager import RouteManager from ...wallet.did_method import DIDMethod -from ...wallet.key_type import ED25519 +from ...wallet.key_type import ED25519, KeyTypes from ..base import BaseWallet from ..did_info import DIDInfo from ..did_posture import DIDPosture @@ -23,6 +23,7 @@ def setUp(self): self.context = AdminRequestContext.test_context( self.session_inject, self.profile ) + self.context.injector.bind_instance(KeyTypes,KeyTypes()) self.request_dict = { "context": self.context, "outbound_message_router": async_mock.AsyncMock(), From 4764863959a405d10883c25c52a9cc1359816c12 Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Thu, 22 Sep 2022 17:11:46 -0600 Subject: [PATCH 17/22] formatting Signed-off-by: Adam Burdett --- .../issue_credential/v2_0/formats/ld_proof/handler.py | 4 +++- aries_cloudagent/wallet/tests/test_routes.py | 2 +- 2 files changed, 4 insertions(+), 2 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 2f3c8f7985..b67f9b7def 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 @@ -74,7 +74,9 @@ SIGNATURE_SUITE_KEY_TYPE_MAPPING[BbsBlsSignature2020] = BLS12381G2 -PROOF_TYPE_SIGNATURE_SUITE_MAPPING = {suite.signature_type: suite for suite in SIGNATURE_SUITE_KEY_TYPE_MAPPING} +PROOF_TYPE_SIGNATURE_SUITE_MAPPING = { + suite.signature_type: suite for suite in SIGNATURE_SUITE_KEY_TYPE_MAPPING +} KEY_TYPE_SIGNATURE_SUITE_MAPPING = { diff --git a/aries_cloudagent/wallet/tests/test_routes.py b/aries_cloudagent/wallet/tests/test_routes.py index 103a68d0b3..1cfd36e773 100644 --- a/aries_cloudagent/wallet/tests/test_routes.py +++ b/aries_cloudagent/wallet/tests/test_routes.py @@ -23,7 +23,7 @@ def setUp(self): self.context = AdminRequestContext.test_context( self.session_inject, self.profile ) - self.context.injector.bind_instance(KeyTypes,KeyTypes()) + self.context.injector.bind_instance(KeyTypes, KeyTypes()) self.request_dict = { "context": self.context, "outbound_message_router": async_mock.AsyncMock(), From 4065c7842c73d5d1babec476a5683d8ca3e33006 Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Mon, 26 Sep 2022 11:44:12 -0600 Subject: [PATCH 18/22] move load did entry for registry injection Signed-off-by: Adam Burdett --- aries_cloudagent/wallet/askar.py | 35 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/aries_cloudagent/wallet/askar.py b/aries_cloudagent/wallet/askar.py index b8b26bee93..62a3d0bb7c 100644 --- a/aries_cloudagent/wallet/askar.py +++ b/aries_cloudagent/wallet/askar.py @@ -33,7 +33,7 @@ ) from .did_method import DIDMethod from .error import WalletError, WalletDuplicateError, WalletNotFoundError -from .key_type import BLS12381G2, ED25519, KeyType +from .key_type import BLS12381G2, ED25519, KeyType, KeyTypes from .util import b58_to_bytes, bytes_to_b58 CATEGORY_DID = "did" @@ -257,7 +257,7 @@ async def get_local_dids(self) -> Sequence[DIDInfo]: ret = [] for item in await self._session.handle.fetch_all(CATEGORY_DID): - ret.append(_load_did_entry(item)) + ret.append(self._load_did_entry(item)) return ret async def get_local_did(self, did: str) -> DIDInfo: @@ -284,7 +284,7 @@ async def get_local_did(self, did: str) -> DIDInfo: raise WalletError("Error when fetching local DID") from err if not did: raise WalletNotFoundError("Unknown DID: {}".format(did)) - return _load_did_entry(did) + return self._load_did_entry(did) async def get_local_did_for_verkey(self, verkey: str) -> DIDInfo: """ @@ -308,7 +308,7 @@ async def get_local_did_for_verkey(self, verkey: str) -> DIDInfo: except AskarError as err: raise WalletError("Error when fetching local DID for verkey") from err if dids: - return _load_did_entry(dids[0]) + return self._load_did_entry(dids[0]) raise WalletNotFoundError("No DID defined for verkey: {}".format(verkey)) async def replace_local_did_metadata(self, did: str, metadata: dict): @@ -403,7 +403,7 @@ async def set_public_did(self, did: Union[str, DIDInfo]) -> DIDInfo: raise WalletError("Error when fetching local DID") from err if not item: raise WalletNotFoundError("Unknown DID: {}".format(did)) - info = _load_did_entry(item) + info = self._load_did_entry(item) else: info = did item = None @@ -727,6 +727,19 @@ async def unpack_message(self, enc_message: bytes) -> Tuple[str, str, str]: raise WalletError("Exception when unpacking message") from err return unpacked_json.decode("utf-8"), sender, recipient + def _load_did_entry(self, entry: Entry) -> DIDInfo: + """Convert a DID record into the expected DIDInfo format.""" + did_info = entry.value_json + key_types: KeyTypes = self._session.inject(KeyTypes) + return DIDInfo( + did=did_info["did"], + verkey=did_info["verkey"], + metadata=did_info.get("metadata"), + method=DIDMethod.from_method(did_info.get("method", "sov")), + key_type=key_types.from_key_type(did_info.get("verkey_type", "ed25519")) + or ED25519, + ) + def _create_keypair(key_type: KeyType, seed: Union[str, bytes] = None) -> Key: """Instantiate a new keypair with an optional seed value.""" @@ -755,15 +768,3 @@ def _create_keypair(key_type: KeyType, seed: Union[str, bytes] = None) -> Key: raise WalletError("Invalid seed for key generation") from None else: return Key.generate(alg) - - -def _load_did_entry(entry: Entry) -> DIDInfo: - """Convert a DID record into the expected DIDInfo format.""" - did_info = entry.value_json - return DIDInfo( - did=did_info["did"], - verkey=did_info["verkey"], - metadata=did_info.get("metadata"), - method=DIDMethod.from_method(did_info.get("method", "sov")), - key_type=KeyType.from_key_type(did_info.get("verkey_type", "ed25519")), - ) From a4cbef1d2db3e1fa1aa8dac50d93165f0929f3de Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Mon, 26 Sep 2022 12:03:23 -0600 Subject: [PATCH 19/22] add registry to indy wallet Signed-off-by: Adam Burdett --- aries_cloudagent/wallet/indy.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aries_cloudagent/wallet/indy.py b/aries_cloudagent/wallet/indy.py index 7e02feb6e9..b91ce355df 100644 --- a/aries_cloudagent/wallet/indy.py +++ b/aries_cloudagent/wallet/indy.py @@ -192,10 +192,12 @@ async def __get_keypair_signing_key(self, verkey: str) -> KeyInfo: try: key_pair_mgr = KeyPairStorageManager(IndySdkStorage(self.opened)) key_pair = await key_pair_mgr.get_key_pair(verkey) + # TODO: inject context to support more keytypes + key_types = KeyTypes() return KeyInfo( verkey=verkey, metadata=key_pair["metadata"], - key_type=KeyType.from_key_type(key_pair["key_type"]), + key_type=key_types.from_key_type(key_pair["key_type"]) or BLS12381G2, ) except (StorageNotFoundError): raise WalletNotFoundError(f"Unknown key: {verkey}") From 55ab05977d1006601077dbbd63d8d78a68d36e8a Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Mon, 26 Sep 2022 14:32:26 -0600 Subject: [PATCH 20/22] default SOV method Signed-off-by: Adam Burdett --- aries_cloudagent/wallet/askar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aries_cloudagent/wallet/askar.py b/aries_cloudagent/wallet/askar.py index ae5f7c76be..195866817b 100644 --- a/aries_cloudagent/wallet/askar.py +++ b/aries_cloudagent/wallet/askar.py @@ -735,7 +735,7 @@ def _load_did_entry(self, entry: Entry) -> DIDInfo: did=did_info["did"], verkey=did_info["verkey"], metadata=did_info.get("metadata"), - method=did_methods.from_method(did_info.get("method", "sov")), + method=did_methods.from_method(did_info.get("method", "sov")) or SOV, key_type=KeyType.from_key_type(did_info.get("verkey_type", "ed25519")), ) From 2cebc373aec36218f0ee54e551573a086db3b7b4 Mon Sep 17 00:00:00 2001 From: Adam Burdett Date: Thu, 13 Oct 2022 10:11:49 -0600 Subject: [PATCH 21/22] happy flake8 Signed-off-by: Adam Burdett --- aries_cloudagent/config/default_context.py | 3 +- aries_cloudagent/core/tests/test_conductor.py | 13 ++++---- .../decorators/tests/test_attach_decorator.py | 13 +++++--- .../protocols/connections/v1_0/manager.py | 8 ++--- .../handlers/tests/test_request_handler.py | 4 +-- .../v1_0/messages/tests/test_request.py | 3 +- .../v1_0/messages/tests/test_response.py | 3 +- .../didexchange/v1_0/tests/test_manager.py | 6 ++-- .../transport/tests/test_pack_format.py | 3 +- .../utils/tests/test_outofband.py | 4 +-- aries_cloudagent/wallet/routes.py | 1 - .../wallet/tests/test_in_memory_wallet.py | 30 +++++-------------- .../wallet/tests/test_indy_wallet.py | 3 +- 13 files changed, 35 insertions(+), 59 deletions(-) diff --git a/aries_cloudagent/config/default_context.py b/aries_cloudagent/config/default_context.py index 72159ece64..360f103fa1 100644 --- a/aries_cloudagent/config/default_context.py +++ b/aries_cloudagent/config/default_context.py @@ -70,8 +70,7 @@ async def bind_providers(self, context: InjectionContext): # so it can be shared by all wallet instances. If we set it in the indy sdk # profile provider it could mean other wallets won't have access to the provider if is_indy_sdk_module_installed(): - from ..ledger.indy import (IndySdkLedgerPool, - IndySdkLedgerPoolProvider) + from ..ledger.indy import IndySdkLedgerPool, IndySdkLedgerPoolProvider context.injector.bind_provider( IndySdkLedgerPool, diff --git a/aries_cloudagent/core/tests/test_conductor.py b/aries_cloudagent/core/tests/test_conductor.py index 22ab676930..85992f0d75 100644 --- a/aries_cloudagent/core/tests/test_conductor.py +++ b/aries_cloudagent/core/tests/test_conductor.py @@ -8,18 +8,19 @@ from ...config.injection_context import InjectionContext from ...connections.models.conn_record import ConnRecord from ...connections.models.connection_target import ConnectionTarget -from ...connections.models.diddoc import (DIDDoc, PublicKey, PublicKeyType, - Service) +from ...connections.models.diddoc import DIDDoc, PublicKey, PublicKeyType, Service from ...core.event_bus import EventBus, MockEventBus from ...core.in_memory import InMemoryProfileManager from ...core.profile import ProfileManager from ...core.protocol_registry import ProtocolRegistry from ...multitenant.base import BaseMultitenantManager from ...multitenant.manager import MultitenantManager -from ...protocols.coordinate_mediation.mediation_invite_store import \ - MediationInviteRecord -from ...protocols.coordinate_mediation.v1_0.models.mediation_record import \ - MediationRecord +from ...protocols.coordinate_mediation.mediation_invite_store import ( + MediationInviteRecord, +) +from ...protocols.coordinate_mediation.v1_0.models.mediation_record import ( + MediationRecord, +) from ...resolver.did_resolver import DIDResolver from ...storage.base import BaseStorage from ...storage.error import StorageNotFoundError diff --git a/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py b/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py index f86197d02e..c0f1f26169 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py +++ b/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py @@ -12,10 +12,15 @@ from ....wallet.indy import IndySdkWallet from ....wallet.key_type import ED25519 from ....wallet.util import b64_to_bytes, bytes_to_b64 -from ..attach_decorator import (AttachDecorator, AttachDecoratorData, - AttachDecoratorData1JWS, - AttachDecoratorDataJWS, - AttachDecoratorDataJWSHeader, did_key, raw_key) +from ..attach_decorator import ( + AttachDecorator, + AttachDecoratorData, + AttachDecoratorData1JWS, + AttachDecoratorDataJWS, + AttachDecoratorDataJWSHeader, + did_key, + raw_key, +) KID = "did:sov:LjgpST2rjsoxYegQDRm7EL#keys-4" INDY_CRED = { diff --git a/aries_cloudagent/protocols/connections/v1_0/manager.py b/aries_cloudagent/protocols/connections/v1_0/manager.py index f262b6baf7..23c8057645 100644 --- a/aries_cloudagent/protocols/connections/v1_0/manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/manager.py @@ -828,9 +828,7 @@ async def create_static_connection( async with self.profile.session() as session: wallet = session.inject(BaseWallet) # seed and DID optional - my_info = await wallet.create_local_did( - SOV, ED25519, my_seed, my_did - ) + my_info = await wallet.create_local_did(SOV, ED25519, my_seed, my_did) # must provide their DID and verkey if the seed is not known if (not their_did or not their_verkey) and not their_seed: @@ -842,9 +840,7 @@ async def create_static_connection( if not their_verkey: their_verkey_bin, _ = create_keypair(ED25519, their_seed.encode()) their_verkey = bytes_to_b58(their_verkey_bin) - their_info = DIDInfo( - their_did, their_verkey, {}, method=SOV, key_type=ED25519 - ) + their_info = DIDInfo(their_did, their_verkey, {}, method=SOV, key_type=ED25519) # Create connection record connection = ConnRecord( diff --git a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py index ad35aa636c..8f8c4381b1 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py @@ -87,9 +87,7 @@ async def setUp(self): await self.conn_rec.save(self.session) wallet = self.session.wallet - self.did_info = await wallet.create_local_did( - method=SOV, key_type=ED25519 - ) + self.did_info = await wallet.create_local_did(method=SOV, key_type=ED25519) self.did_doc_attach = AttachDecorator.data_base64(self.did_doc().serialize()) await self.did_doc_attach.data.sign(self.did_info.verkey, wallet) diff --git a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py index 5a2e4abaee..37569858e6 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py @@ -2,8 +2,7 @@ from asynctest import TestCase as AsyncTestCase -from ......connections.models.diddoc import (DIDDoc, PublicKey, PublicKeyType, - Service) +from ......connections.models.diddoc import DIDDoc, PublicKey, PublicKeyType, Service from ......core.in_memory import InMemoryProfile from ......messaging.decorators.attach_decorator import AttachDecorator from ......wallet.did_method import SOV diff --git a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py index ca3cbcea07..59657ef2dc 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_response.py @@ -2,8 +2,7 @@ from asynctest import TestCase as AsyncTestCase -from ......connections.models.diddoc import (DIDDoc, PublicKey, PublicKeyType, - Service) +from ......connections.models.diddoc import DIDDoc, PublicKey, PublicKeyType, Service from ......core.in_memory import InMemoryProfile from ......messaging.decorators.attach_decorator import AttachDecorator from ......wallet.did_method import SOV diff --git a/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py index 839d9cd139..18f87d6b30 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py @@ -9,8 +9,7 @@ from .....connections.base_manager import BaseConnectionManagerError from .....connections.models.conn_record import ConnRecord from .....connections.models.connection_target import ConnectionTarget -from .....connections.models.diddoc import (DIDDoc, PublicKey, PublicKeyType, - Service) +from .....connections.models.diddoc import DIDDoc, PublicKey, PublicKeyType, Service from .....core.in_memory import InMemoryProfile from .....core.oob_processor import OobMessageProcessor from .....did.did_key import DIDKey @@ -30,8 +29,7 @@ from .....wallet.in_memory import InMemoryWallet from .....wallet.key_type import ED25519 from ....coordinate_mediation.v1_0.manager import MediationManager -from ....coordinate_mediation.v1_0.models.mediation_record import \ - MediationRecord +from ....coordinate_mediation.v1_0.models.mediation_record import MediationRecord from ....coordinate_mediation.v1_0.route_manager import RouteManager from ....didcomm_prefix import DIDCommPrefix from ....discovery.v2_0.manager import V20DiscoveryMgr diff --git a/aries_cloudagent/transport/tests/test_pack_format.py b/aries_cloudagent/transport/tests/test_pack_format.py index 16f5bcc0b2..02a7712e1c 100644 --- a/aries_cloudagent/transport/tests/test_pack_format.py +++ b/aries_cloudagent/transport/tests/test_pack_format.py @@ -12,8 +12,7 @@ from ...wallet.error import WalletError from ...wallet.key_type import ED25519 from .. import pack_format as test_module -from ..error import (RecipientKeysError, WireFormatEncodeError, - WireFormatParseError) +from ..error import RecipientKeysError, WireFormatEncodeError, WireFormatParseError from ..pack_format import PackWireFormat diff --git a/aries_cloudagent/utils/tests/test_outofband.py b/aries_cloudagent/utils/tests/test_outofband.py index 9e2975fcc5..6e3821ff57 100644 --- a/aries_cloudagent/utils/tests/test_outofband.py +++ b/aries_cloudagent/utils/tests/test_outofband.py @@ -10,9 +10,7 @@ class TestOutOfBand(TestCase): test_did = "55GkHamhTU1ZbTbV2ab9DE" test_verkey = "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx" - test_did_info = DIDInfo( - test_did, test_verkey, None, method=SOV, key_type=ED25519 - ) + test_did_info = DIDInfo(test_did, test_verkey, None, method=SOV, key_type=ED25519) def test_serialize_oob(self): invi = InvitationMessage( diff --git a/aries_cloudagent/wallet/routes.py b/aries_cloudagent/wallet/routes.py index 7fe07a00a1..26362dc703 100644 --- a/aries_cloudagent/wallet/routes.py +++ b/aries_cloudagent/wallet/routes.py @@ -354,7 +354,6 @@ async def wallet_create_did(request: web.BaseRequest): # set default method and key type for backwards compat - seed = body.get("seed") or None if seed and not context.settings.get("wallet.allow_insecure_seed"): raise web.HTTPBadRequest(reason="Seed support is not enabled") diff --git a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py index c06f889b4a..ecb3c97263 100644 --- a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py +++ b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py @@ -5,11 +5,9 @@ from ...core.in_memory import InMemoryProfile from ...messaging.decorators.signature_decorator import SignatureDecorator from ...wallet.did_method import KEY, SOV, DIDMethods -from ...wallet.error import (WalletDuplicateError, WalletError, - WalletNotFoundError) +from ...wallet.error import WalletDuplicateError, WalletError, WalletNotFoundError from ...wallet.in_memory import InMemoryWallet -from ...wallet.key_type import (BLS12381G1, BLS12381G1G2, BLS12381G2, ED25519, - X25519) +from ...wallet.key_type import BLS12381G1, BLS12381G1G2, BLS12381G2, ED25519, X25519 @pytest.fixture() @@ -160,16 +158,12 @@ async def test_create_local_sov_seeded(self, wallet: InMemoryWallet): await wallet.create_local_did(SOV, ED25519, self.test_seed, None) with pytest.raises(WalletError): - _ = await wallet.create_local_did( - SOV, ED25519, "invalid-seed", None - ) + _ = await wallet.create_local_did(SOV, ED25519, "invalid-seed", None) @pytest.mark.asyncio @pytest.mark.ursa_bbs_signatures async def test_create_local_key_seeded_bls12381g2(self, wallet: InMemoryWallet): - info = await wallet.create_local_did( - KEY, BLS12381G2, self.test_seed, None - ) + info = await wallet.create_local_did(KEY, BLS12381G2, self.test_seed, None) assert info.did == self.test_key_bls12381g2_did assert info.verkey == self.test_bls12381g2_verkey @@ -177,9 +171,7 @@ async def test_create_local_key_seeded_bls12381g2(self, wallet: InMemoryWallet): await wallet.create_local_did(KEY, BLS12381G2, self.test_seed, None) with pytest.raises(WalletError): - _ = await wallet.create_local_did( - KEY, BLS12381G2, "invalid-seed", None - ) + _ = await wallet.create_local_did(KEY, BLS12381G2, "invalid-seed", None) @pytest.mark.asyncio async def test_create_local_key_seeded_ed25519(self, wallet: InMemoryWallet): @@ -191,9 +183,7 @@ async def test_create_local_key_seeded_ed25519(self, wallet: InMemoryWallet): await wallet.create_local_did(KEY, ED25519, self.test_seed, None) with pytest.raises(WalletError): - _ = await wallet.create_local_did( - KEY, ED25519, "invalid-seed", None - ) + _ = await wallet.create_local_did(KEY, ED25519, "invalid-seed", None) @pytest.mark.asyncio async def test_rotate_did_keypair(self, wallet: InMemoryWallet): @@ -227,9 +217,7 @@ async def test_rotate_did_keypair(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_create_local_with_did(self, wallet: InMemoryWallet): - info = await wallet.create_local_did( - SOV, ED25519, None, self.test_sov_did - ) + info = await wallet.create_local_did(SOV, ED25519, None, self.test_sov_did) assert info.did == self.test_sov_did with pytest.raises(WalletDuplicateError): @@ -524,9 +512,7 @@ async def test_sign_verify_bbs(self, wallet: InMemoryWallet): @pytest.mark.asyncio async def test_pack_unpack(self, wallet: InMemoryWallet): - await wallet.create_local_did( - SOV, ED25519, self.test_seed, self.test_sov_did - ) + await wallet.create_local_did(SOV, ED25519, self.test_seed, self.test_sov_did) packed_anon = await wallet.pack_message( self.test_message, [self.test_ed25519_verkey] diff --git a/aries_cloudagent/wallet/tests/test_indy_wallet.py b/aries_cloudagent/wallet/tests/test_indy_wallet.py index 46f43c802b..8dfe821e58 100644 --- a/aries_cloudagent/wallet/tests/test_indy_wallet.py +++ b/aries_cloudagent/wallet/tests/test_indy_wallet.py @@ -10,8 +10,7 @@ from asynctest import mock as async_mock from ...config.injection_context import InjectionContext -from ...core.error import (ProfileDuplicateError, ProfileError, - ProfileNotFoundError) +from ...core.error import ProfileDuplicateError, ProfileError, ProfileNotFoundError from ...core.in_memory import InMemoryProfile from ...indy.sdk import wallet_setup as test_setup_module from ...indy.sdk.profile import IndySdkProfile, IndySdkProfileManager From cbf78019d037922becb521308f7ea8ea52025614 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Tue, 25 Oct 2022 10:26:51 -0400 Subject: [PATCH 22/22] chore: type hints on init for methods and key types Signed-off-by: Daniel Bluhm --- aries_cloudagent/wallet/did_method.py | 2 +- aries_cloudagent/wallet/key_type.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aries_cloudagent/wallet/did_method.py b/aries_cloudagent/wallet/did_method.py index 861ad002ba..af971ea019 100644 --- a/aries_cloudagent/wallet/did_method.py +++ b/aries_cloudagent/wallet/did_method.py @@ -9,7 +9,7 @@ class DIDMethod: """Class to represent a did method.""" - def __init__(self, name, key_types, rotation) -> None: + def __init__(self, name: str, key_types: List[KeyType], rotation: bool = False): """Construct did method class.""" self._method_name: str = name self._supported_key_types: List[KeyType] = key_types diff --git a/aries_cloudagent/wallet/key_type.py b/aries_cloudagent/wallet/key_type.py index bb8f2c6718..9e16bb1dde 100644 --- a/aries_cloudagent/wallet/key_type.py +++ b/aries_cloudagent/wallet/key_type.py @@ -6,7 +6,7 @@ class KeyType: """Key Type class.""" - def __init__(self, key_type, multicodec_name, multicodec_prefix: bytes) -> None: + def __init__(self, key_type: str, multicodec_name: str, multicodec_prefix: bytes): """Construct key type.""" self._type: str = key_type self._name: str = multicodec_name