Message signing

From claude-dev-suite/claude-dev-suite · View interactive version

Message signing is an AI agent skill from the GitHub repository claude-dev-suite/claude-dev-suite. Generic Bitcoin message signing: BIP137 (legacy P2PKH-only) and BIP322 (modern, supports any output type). Used for proof-of-ownership, withdraw verification, federated authentication, exchange KYC-free attestation. USE WHEN: implementing "sign this message with your Bitcoin address", verifying owne

How to use this skill

Skill file

Bitcoin Message Signing

Two specifications:

or compressed). Output: 65-byte recoverable ECDSA + Base64.

P2WSH, P2TR, even script-only). Output: a virtual PSBT-like

signature.

BIP137 (legacy)

prefix      = "Bitcoin Signed Message:\n"
preamble    = varint(len(prefix)) || prefix || varint(len(msg)) || msg
hash        = SHA256d(preamble)
signature   = recoverable_ecdsa_sign(privkey, hash)   # 65 bytes
encoded     = base64(signature)

Verify: recover pubkey from signature, derive P2PKH address, compare.

Limitations:

newline, others don't).

BIP322 (modern)

Generalizes signing by constructing a virtual transaction:

to_spend = transaction with:
  version=0, locktime=0,
  vin = [{ prevout: 0xffffffff..., scriptSig: OP_0 PUSH msg_hash, sequence: 0 }],
  vout = [{ value: 0, scriptPubKey: <message-target scriptPubKey> }]

to_sign = transaction with:
  version=0, locktime=0,
  vin = [{ prevout: txid_of_to_spend, vout: 0, sequence: 0 }],
  vout = [{ value: 0, scriptPubKey: OP_RETURN }]

Then sign to_sign as a normal transaction spending to_spend's

output. The signature can be:

Address types supported

BIP322 witness.

knowledge" of preimage.

Encoded forms

P2WPKH/P2WSH/P2TR.

P2SH or anything with non-witness data.

Verification flow

def verify_bip322(address, message, signature_b64):
    spk = address_to_scriptPubKey(address)
    msg_hash = bip322_hash(message)
    to_spend = build_to_spend(spk, msg_hash)
    to_sign  = build_to_sign(to_spend)
    apply_signature(to_sign, signature_b64)
    return script_executes_successfully(to_sign, vin[0])

Common use cases

before we send".

Bitcoin address you want to associate with the account.

Library support

Common bugs

same library/wallet that signed where possible.

P2PKH from the same key → semantically wrong; use BIP322 instead.

byte-identical to a real Taproot spend; some libraries default to

SIGHASH_ALL (0x01) which encodes a different sighash.

See also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.