did-btcr2-js

ADR 146: The Resolver Ignores a Sidecar SMT Proof Whose Id Does Not Decode, and a CAS Announcement Entry Must Decode to a Hash

Context

The specification reads the decoded value

Specification pull request 390 (“Key the SMT proof lookup by the decoded proof id”, merged 2026-10-09, specification main cc96c580) closes specification issue 382. It changes “Process Sidecar Data”, “Process CAS Beacon”, and “Process SMT Beacon” of “Resolve”.

The section “Process” of “Resolve” says: “Sidecar Data that the resolver did not use has no effect on the result.” “Process SMT Beacon” raises MISSING_UPDATE_DATA if smt_lookup_table has no entry for smt_root.

The body of the pull request gives the reason for the pad-bit rule. An encoder that conforms to RFC 4648 writes zero pad bits, so it never writes an id with non-zero pad bits. If the resolver ignores a bad proof, the proof cannot stop a resolution that does not need it. The lookup tables are only a SHOULD. Thus the pad-bit rule and the id check must also hold for a resolver that gets the proof another way.

RFC 4648 lets the decoder choose

RFC 4648 Section 3.5 lets a decoder refuse a value with non-zero pad bits. A lenient decoder ignores the pad bits and gets the same bytes as from the canonical value. Node Buffer is lenient. @scure/base is strict: the decode function of @did-btcr2/common and base64UrlToHash of @did-btcr2/smt refuse the value. They also refuse = padding. ADR 014 accepted the strict choice for = padding: interoperation uses byte comparison, not a lenient decoder.

The resolver threw or read a wrong hash

Resolver.sidecarData decoded the id of each sidecar proof with the strict decoder. A proof that the decoder refused stopped each resolution, also if no beacon signal needed the proof.

CASBeacon.processSignals treated an entry with a falsy value as no entry. It decoded each other value with no length check.

The table shows the results for each input. Each CAS row except the last row shows the input in sidecar.casUpdates. A string value gives the same result from the CAS.

Input Before After
An unused sidecar proof whose id has non-zero pad bits A plain Error. tryResolveDid gave INTERNAL_ERROR. Resolves
An unused sidecar proof with an =-padded id, a number id, or no id, or an item of sidecar.smtProofs that is not an object A plain Error or a TypeError Resolves
An unused sidecar proof whose id decodes to another length, for example 31 bytes Resolves. The table held the proof under a key of another length. Resolves
A needed sidecar proof whose id the strict decoder refuses, for example an id with non-zero pad bits or = padding, with no good copy A plain Error NeedSMTProof. The api raises MISSING_UPDATE_DATA.
A good copy of a needed proof, and a copy whose id the strict decoder refuses A plain Error The resolver uses the good copy
provide(NeedSMTProof) with a proof whose id has non-zero pad bits INVALID_SIGNAL_DATA MISSING_UPDATE_DATA
A caller-built map with a proof whose id has non-zero pad bits INVALID_SIGNAL_DATA NeedSMTProof
A CAS Announcement value for the DID that is '', null, 0, NaN, or false Resolves, no update MISSING_UPDATE_DATA
A CAS Announcement value for the DID that is not a string and not in the row above, for example 1, true, or an object A plain Error MISSING_UPDATE_DATA
A CAS Announcement value for the DID that is a string with non-zero pad bits or = padding A plain Error MISSING_UPDATE_DATA
A CAS Announcement value for the DID that decodes to another length, for example abc or 20 letters NeedSignedUpdate with a 2-byte or 15-byte hash MISSING_UPDATE_DATA
An own entry for the DID with the value undefined, in a caller-built casMap No update MISSING_UPDATE_DATA

Decision

1. The key of smt_lookup_table stays the hex of the decoded id

ADR 035, decision 4, stays. One function, smtProofRootHex, gives the key on each path: Resolver.sidecarData, provide(NeedSMTProof), and the root check of SMTBeacon.processSignals.

2. Resolver.sidecarData ignores each proof whose id does not decode to 32 bytes

The resolver ignores an item of sidecar.smtProofs that is not an object. It also ignores a proof whose id the strict decoder does not decode to 32 bytes. smtProofRootHex gives no value for such an id, so no smt_root can match it. The basis for an id with non-zero pad bits is the MUST of “Process Sidecar Data”. The basis for each other id is the rule for unused sidecar data. For a beacon signal that needs an ignored proof, the resolver emits NeedSMTProof.

3. A pad-bit id counts as ignored on each path

Reason: the pad-bit rule must hold for a resolver that gets the proof another way. In this library, provide() is the late sidecar channel. An ignored proof leaves smt_lookup_table with no entry for smt_root, so the code is MISSING_UPDATE_DATA.

On those two paths, each other id that does not decode stays INVALID_SIGNAL_DATA, and so does each root mismatch. Only a sans-I/O driver sees this difference from the sidecar path, because the api never calls provide(NeedSMTProof).

The pad-bit test applies at each length of the id. It reads the text before = padding. The function hasNonZeroPadBits does not decode the text, so ADR 014 still applies.

4. A CAS Announcement value for the DID must decode to a 32-byte hash

CASBeacon.processSignals skips a signal only if the announcement has no own entry for the DID (Object.hasOwn). A present value that the strict decoder does not decode to 32 bytes raises CASBeaconError of type MISSING_UPDATE_DATA. The data of the error is { did, value, announcementHash, beaconServiceId }. A value that is not a string gives the same error.

Reason: for a value that decodes to another length, the update is not available from either source. Thus “Find Beacon Signals” raises MISSING_UPDATE_DATA. For a value that does not decode, the specification names no code. A value that is not a hash cannot name a signed update. Thus the data that the signal announces is not available. An ignored SMT proof gives the same code.

5. casMap keeps the JSON form of each announcement

Resolver.sidecarData and provide(NeedCASAnnouncement) store the JSON form of each announcement in casMap. map_update_hash covers only the JSON content. JSON drops an own entry whose value is undefined, and it drops an entry that is not enumerable. Thus such an entry is not an entry for the DID, and the signal announces no update. Two announcements with one hash then give one result, in each order of sidecar.casUpdates. In provide(NeedCASAnnouncement), the shape check first refuses an announcement with an own entry whose value is undefined (INVALID_DID_UPDATE).

6. The decoders stay strict

The resolver uses no lenient decoder. A proof whose updateId has non-zero pad bits fails SMT Proof Verification: INVALID_SIGNAL_DATA. The strict choice for the CAS Announcement value and for updateId is provisional. The specification does not yet give one pad-bit rule for each base64url value.

7. The helpers are internal

The functions base64UrlHashHex, smtProofRootHex, and hasNonZeroPadBits are in packages/method/src/utils/base64url-hash.ts. index.ts does not export the module. The precedent is utils/error-cause.ts.

Alternatives

Consequences

Superseded.

Unchanged.

Implementation

References