did-btcr2-js

ADR 137: A Signed Message Is an Assertion Proof That Verify Checks Against the Current DID Document

Context

A user wants to sign a text message with a did:btcr2 identifier. Another user wants to verify that the identifier signed the text. The cli had no command for this.

The did:btcr2 specification has no text about message signatures. The decision is a choice of this implementation.

The key of a message signature has other uses

The key that signs a message also does these things:

  1. It signs the updates of the DID. An update proof is a bip340-jcs-2025 Data Integrity proof with the proof purpose capabilityInvocation. The BIP340 signature is over SHA-256(SHA-256(JCS(proof config)) || SHA-256(JCS(update))).
  2. For a KEY (k) identifier, it controls the singleton beacon addresses. A P2PKH or P2WPKH input signs a 32-byte sighash with ECDSA. A P2TR input signs with the BIP341-tweaked key.

A command that signs bytes that the caller chooses is a signing oracle. A probe made a valid update proof with a raw api.kms.sign call over the hash of a malicious update. A “message” can also be a sighash. Thus a message signature must never sign bytes that the caller chooses.

Decision

1. A signed message is a closed JSON object with a Data Integrity proof

{
  "type": "BTCR2Message",
  "message": "I control this DID. 2026-10-06 nonce 7f3a",
  "proof": {
    "type": "DataIntegrityProof",
    "cryptosuite": "bip340-jcs-2025",
    "verificationMethod": "did:btcr2:k1q...#initialKey",
    "proofPurpose": "assertionMethod",
    "proofValue": "z..."
  }
}

2. The signer signs only the hash of this closed format

The signer gets SHA-256(SHA-256(JCS(cfg)) || SHA-256(JCS(doc))). cfg is the proof without proofValue. doc is { type, message }. No message path signs caller bytes, and the scheme is always bip340 with the untweaked key.

Why a message signature cannot be valid as another signature:

3. The signer is an assertionMethod method of the current DID document

signMessage uses the one method that is in assertionMethod, has the type Multikey, has the DID as its controller, and publishes the key of the signer. Zero or several matches fail. verificationMethodId selects one method.

The specification is silent on the relationship. assertionMethod is the relationship for assertions and claims (Controlled Identifiers 1.0, section 2.3.2). authentication needs a challenge protocol.

4. Verify runs five checks in order and stops at the first failure

Check The check passes if
structure The object and its proof have exactly the members of section 1, with the fixed values. proofValue is z and 64 to 88 base58btc characters.
signer proof.verificationMethod is <did>#<fragment>, where <did> is the id of the DID document.
active The DID document is not deactivated.
assertionMethod The method is in assertionMethod, its type is Multikey, its controller is the DID, and its key is a secp256k1 Multikey.
signature The BIP340 signature verifies.

Verify does not throw for a bad signed message. A failed check is in the report. The report has the message only if every check passed.

The structure check refuses a long proofValue before any decode. The time of a base58 decode grows with the square of the length, so a value of 1 MB blocks the process for minutes. A 64-byte signature has 64 to 88 characters, so the check refuses each other length.

5. The api gets two functions with no I/O

The caller resolves the document. A caller that passes an old document gets a check against that old document.

6. The cli gets message sign and message verify

btcr2 message sign -i <identifier> <message> [--signing-key <ref>] [-m <id>] [--sidecar <path>] [--min-conf <n>]
btcr2 message verify -i <identifier> <path> [--sidecar <path>] [--min-conf <n>] [--offline]

7. --offline is the escape from resolution

message verify --offline checks the message against the initial DID document. The api builds it with no I/O (getInitialDocument). The command builds no connection, so a bad connection setting does not stop it. An external (x) identifier needs its genesis document from --sidecar or from the record. The report has checkedAgainst: "initial", and a warning on stderr says that the check does not see a later key rotation or deactivation.

Without --offline, the report has checkedAgainst: "current" and the versionId of the resolution.

Alternatives

Consequences

Positive.

Negative.

Later. --challenge and --domain, a message from a file or stdin, an escape of bidi and zero-width characters in the output, BIP-322 for beacon addresses.

Implementation

References