Skip to content

Commit ea31bd7

Browse files
authored
Merge pull request openwallet-foundation#2067 from sicpa-dlab/feature/create-all-registered-dids
feat: enable creation of DIDs for all registered methods
2 parents 748ec9c + 0c93947 commit ea31bd7

27 files changed

Lines changed: 369 additions & 72 deletions

File tree

DIDMethods.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# DID methods in ACA-Py
2+
Decentralized Identifiers, or DIDs, are URIs that point to documents that describe cryptographic primitives and protocols used in decentralized identity management.
3+
DIDs include methods that describe where and how documents can be retrieved.
4+
DID methods support specific types of keys and may or may not require the holder to specify the DID itself.
5+
6+
ACA-Py provides a `DIDMethods` registry holding all the DID methods supported for storage in a wallet
7+
8+
> :warning: Askar and InMemory are the only wallets supporting this registry.
9+
10+
## Registering a DID method
11+
By default, ACA-Py supports `did:key` and `did:sov`.
12+
Plugins can register DID additional methods to make them available to holders.
13+
Here's a snippet adding support for `did:web` to the registry from a plugin `setup` method.
14+
15+
```python=
16+
WEB = DIDMethod(
17+
name="web",
18+
key_types=[ED25519, BLS12381G2],
19+
rotation=True,
20+
holder_defined_did=HolderDefinedDid.REQUIRED # did:web is not derived from key material but from a user-provided respository name
21+
)
22+
23+
async def setup(context: InjectionContext):
24+
methods = context.inject(DIDMethods)
25+
methods.register(WEB)
26+
```
27+
28+
## Creating a DID
29+
30+
`POST /wallet/did/create` can be provided with parameters for any registered DID method. Here's a follow-up to the
31+
`did:web` method example:
32+
33+
```json=
34+
{
35+
"method": "web",
36+
"options": {
37+
"did": "did:web:doma.in",
38+
"key_type": "ed25519"
39+
}
40+
}
41+
```
42+
43+
## Resolving DIDs
44+
45+
For specifics on how DIDs are resolved in ACA-Py, see: [DID Resolution](DIDResolution.md).

aries_cloudagent/core/tests/test_conductor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from ...utils.stats import Collector
3737
from ...version import __version__
3838
from ...wallet.base import BaseWallet
39-
from ...wallet.did_method import SOV
39+
from ...wallet.did_method import SOV, DIDMethods
4040
from ...wallet.key_type import ED25519
4141
from .. import conductor as test_module
4242

@@ -87,6 +87,7 @@ async def build_context(self) -> InjectionContext:
8787
context.injector.bind_instance(ProfileManager, InMemoryProfileManager())
8888
context.injector.bind_instance(ProtocolRegistry, ProtocolRegistry())
8989
context.injector.bind_instance(BaseWireFormat, self.wire_format)
90+
context.injector.bind_instance(DIDMethods, DIDMethods())
9091
context.injector.bind_instance(DIDResolver, DIDResolver([]))
9192
context.injector.bind_instance(EventBus, MockEventBus())
9293
return context

aries_cloudagent/ledger/tests/test_indy_vdr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
@pytest.fixture()
3030
def ledger():
31-
profile = InMemoryProfile.test_profile()
31+
profile = InMemoryProfile.test_profile(bind={DIDMethods: DIDMethods()})
3232
ledger = IndyVdrLedger(IndyVdrLedgerPool("test-ledger"), profile)
3333

3434
async def open():

aries_cloudagent/messaging/jsonld/tests/test_routes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from ....resolver.did_resolver import DIDResolver
1515
from ....vc.ld_proofs.document_loader import DocumentLoader
1616
from ....wallet.base import BaseWallet
17-
from ....wallet.did_method import SOV
17+
from ....wallet.did_method import SOV, DIDMethods
1818
from ....wallet.error import WalletError
1919
from ....wallet.key_type import ED25519
2020
from ..error import (
@@ -274,6 +274,7 @@ async def setUp(self):
274274
self.context.profile.context.injector.bind_instance(
275275
DocumentLoader, custom_document_loader
276276
)
277+
self.context.profile.context.injector.bind_instance(DIDMethods, DIDMethods())
277278
self.did_info = await (await self.context.session()).wallet.create_local_did(
278279
SOV, ED25519
279280
)

aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from .....storage.error import StorageNotFoundError
2424
from .....transport.inbound.receipt import MessageReceipt
2525
from .....wallet.base import DIDInfo
26-
from .....wallet.did_method import SOV
26+
from .....wallet.did_method import SOV, DIDMethods
2727
from .....wallet.error import WalletNotFoundError
2828
from .....wallet.in_memory import InMemoryWallet
2929
from .....wallet.key_type import ED25519
@@ -94,6 +94,7 @@ async def setUp(self):
9494
BaseCache: InMemoryCache(),
9595
OobMessageProcessor: self.oob_mock,
9696
RouteManager: self.route_manager,
97+
DIDMethods: DIDMethods(),
9798
},
9899
)
99100
self.context = self.profile.context

aries_cloudagent/protocols/coordinate_mediation/v1_0/handlers/tests/test_mediation_request_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from ...models.mediation_record import MediationRecord
1414

1515
from ..mediation_request_handler import MediationRequestHandler
16+
from ......wallet.did_method import DIDMethods
1617

1718
TEST_CONN_ID = "conn-id"
1819
TEST_VERKEY = "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx"
@@ -24,6 +25,7 @@ class TestMediationRequestHandler(AsyncTestCase):
2425
async def setUp(self):
2526
"""setup dependencies of messaging"""
2627
self.context = RequestContext.test_context()
28+
self.context.profile.context.injector.bind_instance(DIDMethods, DIDMethods())
2729
self.session = await self.context.session()
2830
self.context.message = MediationRequest()
2931
self.context.connection_ready = True

aries_cloudagent/protocols/coordinate_mediation/v1_0/tests/test_mediation_manager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from ..messages.mediate_grant import MediationGrant
2727
from ..messages.mediate_request import MediationRequest
2828
from ..models.mediation_record import MediationRecord
29+
from .....wallet.did_method import DIDMethods
2930

3031
TEST_CONN_ID = "conn-id"
3132
TEST_THREAD_ID = "thread-id"
@@ -42,7 +43,9 @@
4243
def profile() -> Iterable[Profile]:
4344
"""Fixture for profile used in tests."""
4445
# pylint: disable=W0621
45-
yield InMemoryProfile.test_profile(bind={EventBus: MockEventBus()})
46+
yield InMemoryProfile.test_profile(
47+
bind={EventBus: MockEventBus(), DIDMethods: DIDMethods()}
48+
)
4649

4750

4851
@pytest.fixture

aries_cloudagent/protocols/coordinate_mediation/v1_0/tests/test_routes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
from .....storage.error import StorageError, StorageNotFoundError
77
from ..models.mediation_record import MediationRecord
88
from ..route_manager import RouteManager
9+
from .....wallet.did_method import DIDMethods
910

1011

1112
class TestCoordinateMediationRoutes(AsyncTestCase):
1213
def setUp(self):
1314
self.profile = InMemoryProfile.test_profile()
15+
self.profile.context.injector.bind_instance(DIDMethods, DIDMethods())
1416
self.context = AdminRequestContext.test_context(profile=self.profile)
1517
self.outbound_message_router = async_mock.CoroutineMock()
1618
self.request_dict = {

aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_complete_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
from ...messages.problem_report_reason import ProblemReportReason
1111

1212
from .. import complete_handler as test_module
13+
from ......wallet.did_method import DIDMethods
1314

1415

1516
@pytest.fixture()
1617
def request_context() -> RequestContext:
1718
ctx = RequestContext.test_context()
19+
ctx.injector.bind_instance(DIDMethods, DIDMethods())
1820
ctx.message_receipt = MessageReceipt()
1921
yield ctx
2022

aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_invitation_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99

1010
from ...handlers.invitation_handler import InvitationHandler
1111
from ...messages.problem_report_reason import ProblemReportReason
12+
from ......wallet.did_method import DIDMethods
1213

1314

1415
@pytest.fixture()
1516
def request_context() -> RequestContext:
1617
ctx = RequestContext.test_context()
18+
ctx.injector.bind_instance(DIDMethods, DIDMethods())
1719
ctx.message_receipt = MessageReceipt()
1820
yield ctx
1921

0 commit comments

Comments
 (0)