feat: resolve did:key jwk_jcs-pub (multicodec 0xeb51) P-256 keys#22
feat: resolve did:key jwk_jcs-pub (multicodec 0xeb51) P-256 keys#22digitalidentitywallet-team wants to merge 1 commit into
Conversation
EUDI Wallet / OpenID4VC issuers represent P-256 keys as a JCS-normalized JWK (multicodec 0xeb51, base58 prefix z2dm/z8DK/zYqN...). Route did:key resolution by the decoded multicodec rather than the multibase string prefix: any 0xeb51 key is parsed, its coordinates normalized to 32 bytes (RFC 7518), canonicalized to the existing p256-pub (zDna) form, and resolved by the existing driver. Other multicodecs fall through unchanged. Promotes base58-universal to a direct dependency.
|
Thanks for the contribution. This will be included in the next released version ~10.1.4 I also applied a change to enforce JCS canonicalization to achieve the stated benefit from the EUDI docs
This doesn't necessarily line up with what you described as variations in key length. Not quite sure what the benefit is of allowing the issuer to use multiple variants of the same key contra to the EUDI documentation. I'm going to do a little more work today to try to understand your approach and when different variations of those keys might appear, and how they would relate to the trusted issuer identifiers registered for a workflow. |
Resolve
did:keyjwk_jcs-pub(multicodec0xeb51) P-256 keysSummary
Adds support for resolving
did:keyidentifiers that encode a P-256 publickey as a JCS-normalized JWK (multicodec
0xeb51,jwk_jcs-pub). These keys arehow EUDI Wallet / OpenID4VC issuers commonly represent their signing keys, and
OpenCred currently fails to resolve them, so credentials issued by such wallets
cannot be verified.
Motivation
OpenCred's
did:keydriver is registered only for thep256-pubmulticodec(
zDna…multibase prefix). EUDI Wallet / OpenID4VC issuers instead publishtheir P-256 keys using the
jwk_jcs-pubmulticodec (0xeb51), whose base58btcmultibase prefix is not fixed — it shifts with the encoded JWK length
(
z2dm…,z8DK…,zYqN…, …). As a result:issis such adid:keyfails signature verification with a resolver error.
logical key can surface under several different prefixes.
Approach
Route
did:keyresolution by the decoded multicodec rather than themultibase string prefix:
varint (LEB128).
0xeb51(jwk_jcs-pub), parse the embedded JWK; if itis an
EC/P-256key, normalize thex/ycoordinates to exactly 32bytes (per RFC 7518 §6.2.1.2 — some issuers serialize a coordinate with a
leading sign byte, yielding 33 bytes) and re-derive the canonical
p256-pub(
zDna…)did:keyviaEcdsaMultikey.fromJwk.Any other multicodec (including today's
zDna…keys) falls through to theexisting driver completely unchanged. The change is a thin wrapper around
didKeyDriver.get, so it adds a new key family without altering resolutionof currently-supported keys.
Backward compatibility
Fully backward compatible. Non-
0xeb51did:keyidentifiers take the originalcode path with no behavioral change; only previously-unresolvable
jwk_jcs-pubkeys are newly handled.Dependencies
Promotes
base58-universal(already present transitively) to a directdependency, used to decode the multibase payload for multicodec inspection.
Testing
Adds
test/bedrock/40-documentLoader.test.jscoverage that buildsjwk_jcs-pubdid:keyidentifiers from a sample P-256 JWK and resolves them through thedocument loader:
z2dm…(jwk_jcs-pub) identifier to a P-256 verification methodwhose document id is the canonical
p256-pub(zDna…) form.z8DK…/zYqN…variants (same key, but with 33-bytecoordinates that shift the multibase prefix) and asserts all three normalize
to the same canonical key / document id — exercising both the
multicodec routing and the coordinate normalization.