Status: Accepted
Date: 2025-03-14
Commit: ce4da8d
did:btcr2 requires a way to hash and sign DID documents (and updates to them) deterministically: two implementations producing different byte sequences for the same logical JSON object would break every signature verification across the ecosystem. Several canonicalization choices exist:
Separately, the signature layer needs to match W3C Verifiable Credentials Data Integrity conventions so that did:btcr2 DID documents can be consumed by existing VC verifiers. The cryptosuite choice pins the type of proof that gets attached to documents and updates.
bip340-jcs-2025 suite name. Stays in JSON, reuses Bitcoin keys directly, matches W3C Data Integrity proof structure.Option 3.
@did-btcr2/common via the canonicalize() / hash() / canonicalHashBytes() / canonicalHash() pipeline. A JSON.parse(JSON.stringify(object)) round-trip normalizes class instances (via their toJSON methods) before JCS so that class-vs-POJO callers produce the same canonical form.bip340-jcs-2025: Data Integrity proof type using BIP340 Schnorr signatures over JCS-canonicalized document bytes. Implemented in @did-btcr2/cryptosuite.base64urlnopad by default (see ADR 003 for the identifier encoding, which is separate).Messages across the aggregation subsystem, beacon signals, and signed updates all hash via canonicalHashBytes(document): canonicalize to SHA-256 to raw bytes.
Positive
bip340-jcs-2025) is self-describing and collision-free with other VC Data Integrity suites.Negative
bip340-jcs-2025 is our own suite identifier; it’s not registered with any standards body. If W3C ever standardizes a JSON+Schnorr suite, we may need to add a second identifier for compatibility.JSON.parse(JSON.stringify(...)) round-trip has a well-known interaction with Uint8Array values (they serialize to index-keyed objects). The HTTP transport works around this with an explicit __bytes wire convention (see ADR 029).Explicitly accepted trade-offs
packages/common/src/canonicalization.ts: canonicalize / hash / canonicalHashBytes pipeline.packages/cryptosuite/src/: bip340-jcs-2025 proof creation + verification.