Skip to content

Commit e4e7ea5

Browse files
authored
Merge branch 'main' into feature/enable-aggr-vcs
2 parents 381315d + d0c4742 commit e4e7ea5

72 files changed

Lines changed: 1259 additions & 1219 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

aries_cloudagent/config/default_context.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
"""Classes for configuring the default injection context."""
22

3-
from .base_context import ContextBuilder
4-
from .injection_context import InjectionContext
5-
from .provider import CachedProvider, ClassProvider
6-
73
from ..cache.base import BaseCache
84
from ..cache.in_memory import InMemoryCache
95
from ..core.event_bus import EventBus
6+
from ..core.goal_code_registry import GoalCodeRegistry
107
from ..core.plugin_registry import PluginRegistry
118
from ..core.profile import ProfileManager, ProfileManagerProvider
129
from ..core.protocol_registry import ProtocolRegistry
13-
from ..core.goal_code_registry import GoalCodeRegistry
14-
from ..resolver.did_resolver import DIDResolver
15-
from ..tails.base import BaseTailsServer
16-
1710
from ..protocols.actionmenu.v1_0.base_service import BaseMenuService
1811
from ..protocols.actionmenu.v1_0.driver_service import DriverMenuService
1912
from ..protocols.didcomm_prefix import DIDCommPrefix
2013
from ..protocols.introduction.v0_1.base_service import BaseIntroductionService
2114
from ..protocols.introduction.v0_1.demo_service import DemoIntroductionService
15+
from ..resolver.did_resolver import DIDResolver
16+
from ..tails.base import BaseTailsServer
2217
from ..transport.wire_format import BaseWireFormat
23-
from ..utils.stats import Collector
2418
from ..utils.dependencies import is_indy_sdk_module_installed
19+
from ..utils.stats import Collector
20+
from ..wallet.did_method import DIDMethods
21+
from ..wallet.key_type import KeyTypes
22+
from .base_context import ContextBuilder
23+
from .injection_context import InjectionContext
24+
from .provider import CachedProvider, ClassProvider
2525

2626

2727
class DefaultContextBuilder(ContextBuilder):
@@ -51,6 +51,8 @@ async def build_context(self) -> InjectionContext:
5151

5252
# Global did resolver
5353
context.injector.bind_instance(DIDResolver, DIDResolver([]))
54+
context.injector.bind_instance(DIDMethods, DIDMethods())
55+
context.injector.bind_instance(KeyTypes, KeyTypes())
5456

5557
await self.bind_providers(context)
5658
await self.load_plugins(context)

aries_cloudagent/config/wallet.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from ..wallet.base import BaseWallet
1212
from ..wallet.crypto import seed_to_did
1313
from ..wallet.did_info import DIDInfo
14-
from ..wallet.did_method import DIDMethod
15-
from ..wallet.key_type import KeyType
14+
from ..wallet.did_method import SOV
15+
from ..wallet.key_type import ED25519
1616
from .base import ConfigError
1717
from .injection_context import InjectionContext
1818

@@ -79,7 +79,7 @@ async def wallet_config(
7979
if wallet_seed and seed_to_did(wallet_seed) != public_did:
8080
if context.settings.get("wallet.replace_public_did"):
8181
replace_did_info = await wallet.create_local_did(
82-
method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=wallet_seed
82+
method=SOV, key_type=ED25519, seed=wallet_seed
8383
)
8484
public_did = replace_did_info.did
8585
await wallet.set_public_did(public_did)
@@ -99,8 +99,8 @@ async def wallet_config(
9999
metadata = {"endpoint": endpoint} if endpoint else None
100100

101101
local_did_info = await wallet.create_local_did(
102-
method=DIDMethod.SOV,
103-
key_type=KeyType.ED25519,
102+
method=SOV,
103+
key_type=ED25519,
104104
seed=wallet_seed,
105105
metadata=metadata,
106106
)
@@ -110,7 +110,7 @@ async def wallet_config(
110110
print(f"Verkey: {local_did_info.verkey}")
111111
else:
112112
public_did_info = await wallet.create_public_did(
113-
method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=wallet_seed
113+
method=SOV, key_type=ED25519, seed=wallet_seed
114114
)
115115
public_did = public_did_info.did
116116
if provision:
@@ -128,8 +128,8 @@ async def wallet_config(
128128
test_seed = "testseed000000000000000000000001"
129129
if test_seed:
130130
await wallet.create_local_did(
131-
method=DIDMethod.SOV,
132-
key_type=KeyType.ED25519,
131+
method=SOV,
132+
key_type=ED25519,
133133
seed=test_seed,
134134
metadata={"endpoint": "1.2.3.4:8021"},
135135
)

aries_cloudagent/core/tests/test_conductor.py

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@
88
from ...config.injection_context import InjectionContext
99
from ...connections.models.conn_record import ConnRecord
1010
from ...connections.models.connection_target import ConnectionTarget
11-
from ...connections.models.diddoc import (
12-
DIDDoc,
13-
PublicKey,
14-
PublicKeyType,
15-
Service,
16-
)
11+
from ...connections.models.diddoc import DIDDoc, PublicKey, PublicKeyType, Service
1712
from ...core.event_bus import EventBus, MockEventBus
1813
from ...core.in_memory import InMemoryProfileManager
1914
from ...core.profile import ProfileManager
2015
from ...core.protocol_registry import ProtocolRegistry
16+
from ...multitenant.base import BaseMultitenantManager
17+
from ...multitenant.manager import MultitenantManager
2118
from ...protocols.coordinate_mediation.mediation_invite_store import (
2219
MediationInviteRecord,
2320
)
@@ -26,8 +23,6 @@
2623
)
2724
from ...protocols.out_of_band.v1_0.models.oob_record import OobRecord
2825
from ...resolver.did_resolver import DIDResolver
29-
from ...multitenant.base import BaseMultitenantManager
30-
from ...multitenant.manager import MultitenantManager
3126
from ...storage.base import BaseStorage
3227
from ...storage.error import StorageNotFoundError
3328
from ...transport.inbound.message import InboundMessage
@@ -36,14 +31,13 @@
3631
from ...transport.outbound.manager import QueuedOutboundMessage
3732
from ...transport.outbound.message import OutboundMessage
3833
from ...transport.outbound.status import OutboundSendStatus
39-
from ...transport.wire_format import BaseWireFormat
4034
from ...transport.pack_format import PackWireFormat
35+
from ...transport.wire_format import BaseWireFormat
4136
from ...utils.stats import Collector
4237
from ...version import __version__
4338
from ...wallet.base import BaseWallet
44-
from ...wallet.key_type import KeyType
45-
from ...wallet.did_method import DIDMethod
46-
39+
from ...wallet.did_method import SOV
40+
from ...wallet.key_type import ED25519
4741
from .. import conductor as test_module
4842

4943

@@ -132,8 +126,8 @@ async def test_startup(self):
132126

133127
wallet = session.inject(BaseWallet)
134128
await wallet.create_public_did(
135-
DIDMethod.SOV,
136-
KeyType.ED25519,
129+
SOV,
130+
ED25519,
137131
)
138132

139133
mock_inbound_mgr.return_value.setup.assert_awaited_once()
@@ -601,8 +595,8 @@ async def test_admin(self):
601595
session = await conductor.root_profile.session()
602596
wallet = session.inject(BaseWallet)
603597
await wallet.create_public_did(
604-
DIDMethod.SOV,
605-
KeyType.ED25519,
598+
SOV,
599+
ED25519,
606600
)
607601

608602
with async_mock.patch.object(
@@ -645,8 +639,8 @@ async def test_admin_startx(self):
645639
session = await conductor.root_profile.session()
646640
wallet = session.inject(BaseWallet)
647641
await wallet.create_public_did(
648-
DIDMethod.SOV,
649-
KeyType.ED25519,
642+
SOV,
643+
ED25519,
650644
)
651645

652646
with async_mock.patch.object(
@@ -717,8 +711,8 @@ async def test_start_static(self):
717711
session = await conductor.root_profile.session()
718712
wallet = session.inject(BaseWallet)
719713
await wallet.create_public_did(
720-
DIDMethod.SOV,
721-
KeyType.ED25519,
714+
SOV,
715+
ED25519,
722716
)
723717

724718
mock_mgr.return_value.create_static_connection = async_mock.AsyncMock()
@@ -887,8 +881,8 @@ async def test_print_invite_connection(self):
887881
session = await conductor.root_profile.session()
888882
wallet = session.inject(BaseWallet)
889883
await wallet.create_public_did(
890-
DIDMethod.SOV,
891-
KeyType.ED25519,
884+
SOV,
885+
ED25519,
892886
)
893887

894888
await conductor.start()
@@ -1401,8 +1395,8 @@ async def test_startup_x_version_mismatch(self):
14011395

14021396
wallet = session.inject(BaseWallet)
14031397
await wallet.create_public_did(
1404-
DIDMethod.SOV,
1405-
KeyType.ED25519,
1398+
SOV,
1399+
ED25519,
14061400
)
14071401

14081402
mock_inbound_mgr.return_value.setup.assert_awaited_once()
@@ -1438,8 +1432,8 @@ async def test_startup_x_no_storage_version(self):
14381432

14391433
wallet = session.inject(BaseWallet)
14401434
await wallet.create_public_did(
1441-
DIDMethod.SOV,
1442-
KeyType.ED25519,
1435+
SOV,
1436+
ED25519,
14431437
)
14441438

14451439
mock_inbound_mgr.return_value.setup.assert_awaited_once()

aries_cloudagent/did/did_key.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
"""DID Key class and resolver methods."""
22

33
from ..wallet.crypto import ed25519_pk_to_curve25519
4-
from ..wallet.key_type import KeyType
4+
from ..wallet.key_type import (
5+
BLS12381G1G2,
6+
ED25519,
7+
KeyType,
8+
BLS12381G1,
9+
X25519,
10+
BLS12381G2,
11+
KeyTypes,
12+
)
513
from ..wallet.util import b58_to_bytes, bytes_to_b58
614

715
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":
3139
return cls.from_public_key(public_key_bytes, key_type)
3240

3341
@classmethod
34-
def from_fingerprint(cls, fingerprint: str) -> "DIDKey":
42+
def from_fingerprint(cls, fingerprint: str, key_types=None) -> "DIDKey":
3543
"""Initialize new DIDKey instance from multibase encoded fingerprint.
3644
3745
The fingerprint contains both the public key and key type.
@@ -43,7 +51,9 @@ def from_fingerprint(cls, fingerprint: str) -> "DIDKey":
4351
key_bytes_with_prefix = b58_to_bytes(fingerprint[1:])
4452

4553
# Get associated key type with prefixed bytes
46-
key_type = KeyType.from_prefixed_bytes(key_bytes_with_prefix)
54+
if not key_types:
55+
key_types = KeyTypes()
56+
key_type = key_types.from_prefixed_bytes(key_bytes_with_prefix)
4757

4858
if not key_type:
4959
raise Exception(
@@ -169,8 +179,8 @@ def construct_did_key_bls12381g1g2(did_key: "DIDKey") -> dict:
169179
g1_public_key = did_key.public_key[:48]
170180
g2_public_key = did_key.public_key[48:]
171181

172-
bls12381g1_key = DIDKey.from_public_key(g1_public_key, KeyType.BLS12381G1)
173-
bls12381g2_key = DIDKey.from_public_key(g2_public_key, KeyType.BLS12381G2)
182+
bls12381g1_key = DIDKey.from_public_key(g1_public_key, BLS12381G1)
183+
bls12381g2_key = DIDKey.from_public_key(g2_public_key, BLS12381G2)
174184

175185
bls12381g1_key_id = f"{did_key.did}#{bls12381g1_key.fingerprint}"
176186
bls12381g2_key_id = f"{did_key.did}#{bls12381g2_key.fingerprint}"
@@ -241,7 +251,7 @@ def construct_did_key_ed25519(did_key: "DIDKey") -> dict:
241251
242252
"""
243253
curve25519 = ed25519_pk_to_curve25519(did_key.public_key)
244-
x25519 = DIDKey.from_public_key(curve25519, KeyType.X25519)
254+
x25519 = DIDKey.from_public_key(curve25519, X25519)
245255

246256
did_doc = construct_did_signature_key_base(
247257
id=did_key.did,
@@ -289,9 +299,9 @@ def construct_did_signature_key_base(
289299

290300

291301
DID_KEY_RESOLVERS = {
292-
KeyType.ED25519: construct_did_key_ed25519,
293-
KeyType.X25519: construct_did_key_x25519,
294-
KeyType.BLS12381G2: construct_did_key_bls12381g2,
295-
KeyType.BLS12381G1: construct_did_key_bls12381g1,
296-
KeyType.BLS12381G1G2: construct_did_key_bls12381g1g2,
302+
ED25519: construct_did_key_ed25519,
303+
X25519: construct_did_key_x25519,
304+
BLS12381G2: construct_did_key_bls12381g2,
305+
BLS12381G1: construct_did_key_bls12381g1,
306+
BLS12381G1G2: construct_did_key_bls12381g1g2,
297307
}

aries_cloudagent/did/tests/test_did_key_bls12381g1.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from unittest import TestCase
22

33

4-
from ...wallet.key_type import KeyType
4+
from ...wallet.key_type import BLS12381G1
55
from ...wallet.util import b58_to_bytes
66
from ..did_key import DIDKey, DID_KEY_RESOLVERS
77
from .test_dids import (
@@ -24,14 +24,12 @@
2424
class TestDIDKey(TestCase):
2525
def test_bls12381g1_from_public_key(self):
2626
key_bytes = b58_to_bytes(TEST_BLS12381G1_BASE58_KEY)
27-
did_key = DIDKey.from_public_key(key_bytes, KeyType.BLS12381G1)
27+
did_key = DIDKey.from_public_key(key_bytes, BLS12381G1)
2828

2929
assert did_key.did == TEST_BLS12381G1_DID
3030

3131
def test_bls12381g1_from_public_key_b58(self):
32-
did_key = DIDKey.from_public_key_b58(
33-
TEST_BLS12381G1_BASE58_KEY, KeyType.BLS12381G1
34-
)
32+
did_key = DIDKey.from_public_key_b58(TEST_BLS12381G1_BASE58_KEY, BLS12381G1)
3533

3634
assert did_key.did == TEST_BLS12381G1_DID
3735

@@ -53,20 +51,20 @@ def test_bls12381g1_properties(self):
5351
assert did_key.did == TEST_BLS12381G1_DID
5452
assert did_key.public_key_b58 == TEST_BLS12381G1_BASE58_KEY
5553
assert did_key.public_key == b58_to_bytes(TEST_BLS12381G1_BASE58_KEY)
56-
assert did_key.key_type == KeyType.BLS12381G1
54+
assert did_key.key_type == BLS12381G1
5755
assert did_key.key_id == TEST_BLS12381G1_KEY_ID
5856
assert did_key.prefixed_public_key == TEST_BLS12381G1_PREFIX_BYTES
5957

6058
def test_bls12381g1_diddoc(self):
6159
did_key = DIDKey.from_did(TEST_BLS12381G1_DID)
6260

63-
resolver = DID_KEY_RESOLVERS[KeyType.BLS12381G1]
61+
resolver = DID_KEY_RESOLVERS[BLS12381G1]
6462

6563
assert resolver(did_key) == did_key.did_doc
6664

6765
def test_bls12381g1_resolver(self):
6866
did_key = DIDKey.from_did(TEST_BLS12381G1_DID)
69-
resolver = DID_KEY_RESOLVERS[KeyType.BLS12381G1]
67+
resolver = DID_KEY_RESOLVERS[BLS12381G1]
7068
did_doc = resolver(did_key)
7169

7270
assert (

0 commit comments

Comments
 (0)