@did-btcr2/method (PATCH: the hash in update_hash_history keeps each nested member named proof); @did-btcr2/api (PATCH: the browser bundle holds the method package)The resolver hashes the unsigned form of each BTCR2 Signed Update at two algorithm steps of the specification (Resolve):
update. “Create unsigned_update by removing the proof property from update, hash it with the JSON Document Hashing algorithm, and append the hash to update_hash_history.”update_hash_history for the targetVersionId of the update.The specification (Data Structures) defines a BTCR2 Signed Update as the properties of a BTCR2 Unsigned Update “and one additional property”, proof. Thus both steps remove only that top-level property.
The two steps of the resolver did not agree:
JSONUtils.deleteKeys(update, ['proof']). That function removes each key named proof at each depth, also inside the value of a patch operation.proof.A patch can add a member named proof, for example in a service:
[
{
"op": "add",
"path": "/service/-",
"value": { "id": "did:btcr2:k1...#nested", "type": "LinkedDomains", "serviceEndpoint": "https://example.com", "proof": { "value": "a" } }
}
]
For such an update, the two steps computed different hashes. If two Beacon Signals announced the same update, the resolver applied the update at the first signal. At the second signal, the hash did not match the history entry, and the resolver raised LATE_PUBLISHING. The DID did not resolve past that point.
Resolver.unsignedUpdateHash removes the top-level proof property with an object rest destructure. Then it hashes the result with canonicalHashBytes. The Apply step and the Confirm Duplicate step both call this function.
The specification uses the same words at the two steps. One function makes sure that the two steps cannot compute different hashes again.
proof is data of the updateThe hash keeps each member named proof below the top level. The member is part of the patch, and the signature of the update covers it. Thus two updates that differ only in a nested proof member have different hashes. A duplicate check that compares them raises LATE_PUBLISHING.
JSONUtils.deleteKeys stays in the common packageThe resolver does not call JSONUtils.deleteKeys any more. No other source file in the packages calls it. This ADR does not remove the function from the common package, because its removal is a MAJOR change of the common package. A separate change removes it.
proof property. Also, two updates that differ only in a nested proof member then get the same hash, and the resolver confirms one as a duplicate of the other.proof now resolves when two or more Beacon Signals announce it. Before, the second signal raised LATE_PUBLISHING.proof member gets the same hash as before. The fix does not change the result of such a resolution.update_hash_history now holds the hash that the specification defines. A different implementation that follows the specification computes the same history.packages/method/src/core/resolver.ts: Resolver.unsignedUpdateHash; the calls in confirmDuplicate and in the Apply arm of step 6.packages/method/tests/resolver.spec.ts: the tests “the top-level proof of the update (ADR 141)”.update and Confirm Duplicate Update.