DOCUMENTATION · v0.12.2

Independent verification of the P-256 `did:key` adapter

Date: 2026-11-18 Scope: PR #13 §11 — "Verify the DID with an implementation outside AI Auth and without network access." Verdict: PASS. No disagreement with the adapter was found. One disagreement exists between the task statement's prefix parenthetical and the authoritative external multicodec table (see Disagreements).

This is independent verification. The adapter and its tests were not modified. All verification primitives (base58btc, the multicodec table, and full did:key resolution) come from packages installed in a temporary directory outside this repository. No dependency was added to this repo and no manifest or lockfile was changed.

Environment#

  • Repo: the AI Auth checkout used for this run (Node v22.23.4, npm 10.9.9, darwin)
  • External workdir: a throwaway directory outside the repo, for example ${TMP:-/tmp/ai-auth-did-verify}

Exact setup commands (run outside the repo)#

TMP=${TMP:-/tmp/ai-auth-did-verify}
mkdir -p "$TMP" && cd "$TMP"
npm init -y >/dev/null
npm install multiformats@14.0.6 multicodec@3.2.1 \
  key-did-resolver@4.0.0 did-resolver@6.0.0

npm ls --depth=0 in that directory returned exactly:

PackageVersionRole
multiformats14.0.6external base58btc codec (multiformats/bases/base58)
multicodec3.2.1authoritative multicodec code/varint table (deprecated but canonical table)
key-did-resolver4.0.0independent did:key → DID-document resolver; emits publicKeyJwk for P-256
did-resolver6.0.0drives key-did-resolver via its documented Resolver API

Resolved tarballs (from the external package-lock.json): multiformats-14.0.6.tgz, multicodec-3.2.1.tgz, key-did-resolver-4.0.0.tgz, did-resolver-6.0.0.tgz, plus transitive @noble/curves@1.9.7, @noble/hashes@1.8.0, varint@6.0.0, uint8arrays@5.1.1. The external resolver uses @noble/curves, i.e. a completely separate elliptic-curve implementation from the adapter's hand-written bigint point decompression.

Rerun the verification#

cd /path/to/ai-auth
node scripts/verify-did-key.mjs \
  --modules-dir "${TMP:-/tmp/ai-auth-did-verify}/node_modules"

Observed output ended with RESULT: PASS (54/54 checks passed), exit code 0. The script generates 6 fresh P-256 keypairs per run with Node Web Crypto and checks each with all three external layers, then runs rejection cases through the adapter's public API.

Method#

  1. Generate P-256 public JWKs locally with crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"}) / exportKey("jwk").
  2. Derive DIDs with AI Auth's didKeyForPublicJwk(jwk).
  3. Decode the DID with external base58btc.decode and inspect codec bytes with external multicodec.getCode / getCodec / getVarint.
  4. Resolve the DID with external key-did-resolver (via did-resolver) and compare the returned publicKeyJwk byte-for-byte to the original JWK.
  5. Cross-check the adapter's own resolveDidKey and didKeyMatchesJwk.
  6. Rejection cases: wrong curve/kty, malformed coordinates, wrong multicodec prefixes, malformed DID, and a mismatched JWK.

Vectors (JWK → DID → external resolution)#

The first three are fixed known-answer vectors (also used by the repo's test file); the fourth is a P-256 key generated during this run (random, so not reproducible — shown as a sample of the 6 generated per run).

#xydid (from adapter)raw[0:2]external codecexternal resolver JWK == input
1igrFmi0whuihKnj9R3Om1SoMph72wUGeFaBbzG2vznsefsX5b10x8yjyrj4ny3pGfLcY7Xby1KzgqOdqnsrJIMdid:key:zDnaerx9CtbPJ1q36T5Ln5wYt3MQYeGRG5ehnPAmxcf5mDZpv80244608 / p256-pubyes
2OcPddBMXKURtwbPaaah1G75-nouisLmtL9qaaaI9DocAXuQgg5s3wXfkmz_xAyhXvWDqvvpyxaoshDekbb47sgdid:key:zDnaeUKTWUXc1HDpGfKbEK4VRpw8FJVDExddoNqfJW3kJyqzn80244608 / p256-pubyes
3OoJz7s5rDYLpXDUGYX21AA4U_wAjMl0LsCdJGLxqbNw1dTCts1IylLFZQ-y2ABHc4x7hifNanA1rXgPFTZp-tUdid:key:zDnaembgSGUhZULN2Caob4HLJPaxBh92N7rtH21TErzqf8HQo80244608 / p256-pubyes
4 (generated)5Vk6I4iK6Gl1yN7jchh9cCrXDE7rSR7Z57tE2coaUos3Pp-YbFOMKJG8ci_uTIFyvfopRhIC56-yGJq0wndSPsdid:key:zDnaey6Zh7pi5YCzQRtqbJ56zvT5tMfEkRGqYnduAd2d2aAwL80244608 / p256-pubyes

All decoded DIDs are 35 bytes (2-byte varint + 33-byte compressed SEC1 point). For every vector: adapter resolveDidKey(did) deep-equals the input JWK, didKeyMatchesJwk(did, jwk) is true, and external key-did-resolver returned a JsonWebKey2020 verification method with an identical {kty,crv,x,y}.

Multicodec prefix facts (from multicodec@3.2.1)#

ExpressionExternal result
multicodec.P256_PUB4608 = 0x1200
multicodec.getName(0x1200)"p256-pub"
multicodec.getVarint(0x1200)bytes 80 24
first two bytes of decoded DIDs80 24 (observed for all 10 keys across runs)
multicodec.getCode([0xa4,0x01])164 = 0xa4
multicodec.getCodec([0xa4,0x01])throws Code "164" not found (unmapped)
multicodec.getVarint(0x8024)bytes a4 80 02

PASS / FAIL / UNKNOWN table#

CheckResultEvidence
p256-pub numeric code is 0x1200PASSmulticodec.P256_PUB === 4608
p256-pub varint bytes are 80 24PASSgetVarint(0x1200) → 8024; decoded DIDs start 8024
Base58btc (z multibase) decodes to 35 bytesPASSexternal base58btc.decode, all keys
External codec of DID == 0x1200 / p256-pubPASSgetCode/getCodec, all keys
Full external did:key resolution == original JWKPASSdid-resolver + key-did-resolver (@noble/curves)
Adapter resolveDidKey == original JWKPASSdeep-equal for all keys
Adapter didKeyMatchesJwk(did, jwk) truePASSall keys
Wrong curve P-384 rejectedPASSadapter throws TypeError
Wrong kty OKP/Ed25519 rejectedPASSadapter throws TypeError
Malformed x coordinate rejectedPASSadapter throws TypeError
Mismatched JWK returns falsePASSdidKeyMatchesJwk
Arbitrary string / empty multibase rejectedPASSresolveDidKey("agent:abc"), resolveDidKey("did:key:z") throw
a4 01 prefix DID rejectedPASSdid:key:zHN8WVTguMDSQ94cSPLkxJ8W5u7n3ZwJDxp7P9T99KtLJCd5U → Unsupported did:key multicodec
e7 01 (secp256k1) prefix DID rejectedPASSdid:key:zQ3shovxv6i36bziX51hYbWKZCdMkFDV6bqEBNFEKMBAy4GdY → same error
ed 01 (Ed25519) prefix DID rejectedPASSdid:key:zQebfMtDLQTHTYM9JWCygruv75YDWaKGDjUYy4M688JjtkD4v → same error
Signature verification with resolved keyUNKNOWN hereExercised by sibling test file, not by this independent script; not re-run as part of this verification
Browser (btoa/atob) environmentUNKNOWN hereVerified under Node 22 only; adapter uses btoa/atob, which exist in Node 22 and browsers

Disagreements#

  1. No disagreement with the adapter. Every DID produced by didKeyForPublicJwk was confirmed by the external resolver, and every rejection behaved as expected.
  2. Disagreement with the task statement's parenthetical. The task text says "p256-pub 0x8024, varint a4 01". The authoritative external table gives the opposite: the numeric code is 0x1200, its varint bytes are 80 24, and a4 01 decodes to the unmapped code 0xa4. Interpreting 0x8024 as a numeric code yields varint a4 80 02, not a4 01. The adapter is correct; the parenthetical is not. The adapter's own header comment already documents this exact confusion.

Limitations / notes on "without network access"#

  • Package acquisition used the public npm registry (explicitly allowed by the task's "install or run packages … using npx/npm"). The verification itself is offline: scripts/verify-did-key.mjs only reads local files and imports locally installed packages; did:key is self-resolving and performs no HTTP/RPC/DNS calls. No AI Auth network or RPC code was invoked.
  • multicodec@3.2.1 is deprecated in favor of multiformats, but it is the package that exposes the canonical code/varint table used here; the base58btc used for decoding is from multiformats@14.0.6.
  • The four generated keys cited above are from one run; the script regenerates 6 random keys on each run, so exact generated vectors differ between runs while the fixed vectors and all checks remain identical.
On this page