did-btcr2-js

ADR 140: The Resolver Checks the Genesis Id and Compares With the DID Under Resolution

Context

The specification (Data Structures, Genesis Document) says: “A Genesis Document is a DID document (data structure) with the identifier set to the placeholder value (did:btcr2:_).” The specification (Resolve, Establish current_document) replaces the placeholder with did to make current_document. The specification uses did, the DID under resolution, in each later step:

  1. Check update.proof: “update.proof.capability equals the capability URN that Data Integrity Config (data structure) specifies for did” and “update.proof.invocationTarget equals did”.
  2. Apply update: “Verify that current_document conforms to DID Core v1.1 and that current_document.id equals did.”
  3. Process CAS Beacon: “Read update_hash from the announcement entry keyed by did.”
  4. SMT Proof Verification: “hash(did) denotes hash() over the UTF-8 bytes of the DID string.”

Resolver.external checked the hash of the genesis document and replaced the placeholder. It did not check the id of the genesis document. Thus a genesis document with the id of another DID made a current_document whose id was not did. The resolver then used current_document.id where the specification uses did:

An example: the controller of an x1 DID copies the initial document of a k1 DID as the genesis document. The x1 DID resolves to a document whose id is the k1 DID. An update that the k1 DID signed also applies to the x1 DID. The result breaks DID Resolution v1: “The value of id in the resolved DID document MUST be string equal to the DID that was resolved.”

Decision

1. The genesis document must have the placeholder id

Resolver.external refuses a genesis document whose id is not did:btcr2:_. The check runs after the hash check, in the order of the specification: Process Sidecar Data checks the hash, and Establish current_document replaces the placeholder. The check looks at the top-level id only. A document that has the placeholder as its id gets the DID as its id from the replacement.

2. The error is INVALID_DID_DOCUMENT

The specification names no error code for this step. The resolver raises a ResolveError of type INVALID_DID_DOCUMENT, with the data { id }. The message is Invalid genesis document: the id must be "did:btcr2:_", got <id>. The same step raises INVALID_DID_DOCUMENT if the result is not a conformant DID document. The DID is well formed, and the hash of the document matches its genesis bytes. Thus the fault is in the document, not in the DID.

3. The resolver compares with the DID under resolution

The Resolver constructor encodes the DID once from the DID components and keeps it as #did. The value is the same string that Resolver.external and Resolver.deterministic write as the document id. The resolver uses #did in each place where the specification uses did:

4. Two uses of current_document.id stay

applyUpdate still gives currentDocument.id to Appendix.absoluteDidUrl for the verification method id and to Appendix.capabilityInvocationEntry. These lookups find a verification method in current_document. A relative DID URL in the document is relative to the document id. After the checks of this ADR, the id equals did on each path of DidBtcr2.resolve, so the change has no effect there. A test that changed the absoluteDidUrl argument to did found no difference.

Alternatives

Consequences

Implementation

References