Skip to main content

Module jwk

Module jwk 

Source
Available on crate feature did-jwk and (crate features did-jwk or did-key or did-web) only.
Expand description

did:jwk: a DID that is a base64url-encoded JSON Web Key.

The did:jwk method is a deterministic transformation of a public JWK into a DID document: the method-specific id is base64url(JWK), the document has exactly one verification method, #0, of type JsonWebKey2020, and the verification relationships follow the key’s use member (all five when it is absent, no keyAgreement for sig, only keyAgreement for enc). The method cannot update or deactivate.

§Canonical form

The method does not fix how the JWK is serialized, so one key has many valid did:jwks. The specification names the JSON Canonicalization Scheme (RFC 8785) as helpful when the DID is not stored in its serialized form, and DidJwk::did uses it: members sorted, no whitespace. The result is the DID every other JCS implementation derives for the same key, including the specification’s P-256 example. Resolution accepts any serialization, so a DID created another way still resolves; it is just not the one DidJwk::did produces. An application holding DIDs created another way, such as this crate’s before 0.2, should keep those strings rather than derive them again.

Structs§

DidJwk
The did:jwk method: a DidResolver that expands the DID and a DidProducer that encodes one public key.