BIP 360: Pay-to-Merkle-Root
BIP 360 proposes P2MR, an output type that works like Taproot but drops the key-path spend. It is a draft Bitcoin soft fork and the foundation of Bitcoin2x.
The idea
A Taproot (P2TR) output is a tweaked public key. You can spend it with a signature from that key (the key path) or by revealing one script from a committed tree (the script path). The key path is cheap and private, but it means a public key sits on-chain for as long as the coins are unspent, which is exactly what a long-exposure quantum attack needs.
P2MR removes the key path. The output commits directly to the Merkle root of the script tree, so the only way to spend is to reveal a leaf script and a Merkle proof. Until that moment, nothing but a hash is public.
The output
scriptPubKey: OP_2 OP_PUSHBYTES_32 <merkle_root>
hex: 52 20 <32 bytes>
address: bc1z... (bech32m, witness version 2)
example: bc1zzmv50jjgxxhww6ve4g5zpewrkjqhr06fyujpm20tuezdlxmfphcqfc80ve
Leaf and branch hashes are the same tagged hashes as BIP 341: TapLeaf over leaf_version || compact_size(len) || script, and TapBranch over the two children sorted lexicographically.
Spending
The witness is [stack items…] [leaf script] [control block], optionally followed by an annex. Validation:
- The control block must be
1 + 32·mbytes (m from 0 to 128). That is 32 bytes shorter than Taproot's, because there is no internal key. - The first byte gives the leaf version (
c[0] & 0xfe). Its lowest bit must be 1. - Hash the leaf, then walk up the tree with the m sibling hashes. The result must equal the 32-byte witness program.
- Execute the leaf script under BIP 342 tapscript rules.
Since spec version 0.12.0, a tree of depth zero (m = 0) is anyone-can-spend, so wallets must never create one, and BTCX wallet software is designed to refuse to.
Cost compared with Taproot
| Spend type | Witness for a single-key spend |
|---|---|
| P2TR key path | Signature only (about 64 bytes) |
P2MR, single leaf <pk> OP_CHECKSIG | Signature + 35-byte leaf script + 1-byte control block (about 101 bytes with Schnorr) |
| P2TR script path | Same as P2MR plus 32 extra control block bytes |
What BIP 360 does not do
BIP 360 alone protects against long-exposure attacks only. If the leaf script uses a Schnorr OP_CHECKSIG, the public key is revealed in the mempool at spend time and a fast enough quantum computer could still race the transaction. Post-quantum signatures are needed for that, and the BIP authors say they intend to propose them separately. Bitcoin2x tests that second step now, by putting ML-DSA checks in P2MR leaves.
Hybrid leaves
Because a P2MR output is a script tree, one output can carry several spending paths, for example:
root
├─ leaf A: <schnorr_pk> OP_CHECKSIG (cheap, use today)
└─ leaf B: <ml_dsa_pk> OP_CHECKSIG_PQ (post-quantum fallback)
OP_CHECKSIG_PQ is an illustrative name: the exact opcode and leaf version for post-quantum checks are not yet standardised.
A wallet can spend through leaf A while elliptic curves remain safe, and switch to leaf B if they ever stop being safe, all without moving funds to a new address.
Try it
The P2MR address tool builds the Merkle root, scriptPubKey and address from your own leaf scripts, entirely in your browser. It reproduces every construction test vector published with BIP 360.