Skip to content

Commit c29d725

Browse files
committed
chore: add documentation for DIDMethods
* Augment existing swagger documentation for the `POST /wallet/did/create` route * Add `DIDMethods.md` documentation to introduce the concept of the `DIDMethods` registry and its use to register new methods. Signed-off-by: Clément Humbert <clement.humbert@sicpa.com>
1 parent aae6d83 commit c29d725

2 files changed

Lines changed: 56 additions & 2 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/wallet/routes.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,17 @@ class DIDCreateOptionsSchema(OpenAPISchema):
161161
key_type = fields.Str(
162162
required=True,
163163
example=ED25519.key_type,
164+
description="Key type to use for the DID keypair. "
165+
+ "Validated with the chosen DID method's supported key types.",
164166
validate=validate.OneOf([ED25519.key_type, BLS12381G2.key_type]),
165167
)
166168

167-
did = fields.Str(required=False, **GENERIC_DID)
169+
did = fields.Str(
170+
required=False,
171+
description="Specify final value of the did (including did:<method>: prefix)"
172+
+ "if the method supports or requires so.",
173+
**GENERIC_DID,
174+
)
168175

169176

170177
class DIDCreateSchema(OpenAPISchema):
@@ -174,12 +181,14 @@ class DIDCreateSchema(OpenAPISchema):
174181
required=False,
175182
default=SOV.method_name,
176183
example=SOV.method_name,
184+
description="Method for the requested DID."
185+
+ "Supported methods are 'key', 'sov', and any other registered method.",
177186
)
178187

179188
options = fields.Nested(
180189
DIDCreateOptionsSchema,
181190
required=False,
182-
description="To define a key type for a did:key",
191+
description="To define a key type and/or a did depending on chosen DID method.",
183192
)
184193

185194
seed = fields.Str(

0 commit comments

Comments
 (0)