Binohash

Transaction Introspection Without Softforks
Robin Linus — ZeroSync, Stanford University

1 The Problem

Bitcoin Script is blind to its own transactions

Bitcoin Script cannot natively read transaction data—inputs, outputs, amounts, or any other field. There is no OP_TXHASH. This means scripts cannot trustlessly verify properties of the transaction they are part of, forcing protocols like BitVM bridges to rely on trusted oracles or accept weaker security models.

2 The Solution: Binohash

Binohash is a collision-resistant hash function for Bitcoin transactions that produces a digest directly readable in Script—without any consensus changes. Named after the binomial coefficient C(n, t) central to its construction, it achieves three properties simultaneously:

Readable Extractable in Script
~84-bit Collision resistance
Signable Lamport-compatible for BitVM

3 How It Works

The scheme operates in two stages across a single Bitcoin transaction:

S1
Transaction Pinning
Four ECDSA signature puzzles (proof-of-work constraints on signature size) lock down every transaction field. Each puzzle uses a different sighash mode—ALL, NONE, ANYONECANPAY|ALL, ANYONECANPAY|NONE—so that modifying any field forces the attacker to redo at least one 242-work puzzle.
S2a
Nonce Extraction Round 1
120 tiny (9-byte) dummy signatures are embedded in the locking script. The spender picks a subset of 8. Due to the FindAndDelete quirk in OP_CHECKMULTISIG, each different subset produces a different sighash. The spender grinds through C(120, 8) ≈ 240 subsets until finding one whose sighash satisfies a proof-of-work puzzle. The winning indices become the first half of the Binohash.
S2b
Nonce Extraction Round 2
A second pool of 120 signatures provides another ~40 bits of entropy via the same process. The combined 16 indices (8 from each round) form the full ~79-bit Binohash—readable directly from the unlocking script.

Key Insight

The grinding requires no elliptic curve math—only double SHA-256 hashing. By choosing a special private key d = rmin-1, the signature s-value simplifies to s = 2(z + 1), so checking the puzzle reduces to checking whether the sighash z has enough leading zero bits.

Demo 1 — Why Four Sighash Puzzles Pin Every Field

Click an “Attacker modifies” button. The grid lights up the sighash puzzles that would detect the change — forcing the attacker to redo at least one 242-work puzzle. No single field escapes all four.

Attacker modifies:
Field committed to by mode
ALL
NONE
ANYONECANPAY
| ALL
ANYONECANPAY
| NONE
version / this input / locktime
other inputs
outputs
Click a button above to see which puzzles detect the change.

Demo 2 — Grinding Through 120-Choose-8 Subsets

120 dummy signatures live in the locking script (shown below). FindAndDelete makes each subset of 8 produce a different sighash. Pick a toy target and grind until the sighash has enough leading zero bits. (Real Binohash targets ≈ 240; the slider caps at 222 so your browser stays responsive.)

Click Grind to iterate through subsets.

4 Bitcoin Quirks Exploited

Variable-Length ECDSA

Signature size depends on the magnitude of r and s values. Smaller values = shorter signatures, verified in Script via OP_SIZE.

Smallest Known R-Value

Rmin = 2-1G has a 21-byte x-coordinate. Finding anything smaller takes ~97 bits of work, so the spender is forced to use it.

SIGHASH_SINGLE Bug

When input_idx ≥ num_outputs, sighash returns z = 1 for any transaction. This enables 9-byte transaction-independent dummy signatures for the nonce pool.

FindAndDelete

A historical quirk: OP_CHECKMULTISIG removes selected signatures from the scriptCode before hashing, creating controllable sighash variation from subset selection.

HORS Subset Signatures

Instead of per-bit Lamport signatures (which would exceed the 201 opcode limit), subset preimage revelation signs the Binohash with only 48 opcodes.

256 Sighash Flags

All 256 sighash byte values are consensus-valid (only 6 are standard). This gives the honest spender more grinding freedom per sighash mode.

Demo 3 — ECDSA Signature Size vs r / s Magnitude

DER-encoded ECDSA signatures are variable length — the bytes used for r and s shrink with their magnitude. Move the sliders to see the byte layout react. The locking script's OP_SIZE check is what forces the spender to find a small-r / small-s signature, which requires PoW grinding. For byte-level dissection of a real DER signature, see the DER Autopsy tool.

DER header r (marker / length / bytes) s (marker / length / bytes) sighash flag

5 Performance & Cost

~84 bits Collision resistance
~44.6 bits Honest work
~3.8 hrs 10× RTX 4090
<$15 Cloud GPU cost
Metric Basic (W=42) High Security (W=50)
Collision resistance ~84 bits ~92 bits
Honest work ~44.6 bits ~52.6 bits
GPU time (10× RTX 4090) ~3.8 hours ~40 days
Cloud cost (vast.ai) <$15 ~$3,100
Script size ~8 KB (locking script)
Transaction fee ~$40 at current rates

6 Primary Use Case: BitVM Bridges

Trustless Bridge Verification

BitVM bridges need to verify transaction properties—e.g., "Did this peg-out transaction actually pay the right address?" or "Did the rollup sequencer publish the correct state diff?" By Lamport-signing the Binohash in Script and feeding it into BitVM's off-chain verification, operators can prove transaction properties without trusted oracles.

The Bridge Flow

1
Rollup state diffs are published on Bitcoin as a chain of transactions (data availability layer).
2
The operator creates a ReadTx that spends both a Binohash output and the DA chain's read output. The Binohash transitively commits to the entire rollup state history.
3
The Binohash is Lamport-signed and fed into BitVM, which verifies the transaction properties off-chain via SNARK verification.
4
Collision resistance (~84 bits) prevents an attacker from executing one transaction on-chain but presenting a different one to BitVM.

7 Security Analysis

Attack: Skipping Transaction Pinning

An attacker could try using only ANYONECANPAY|NONE for the puzzle signature, bypassing pinning entirely. This would reduce security to ~42 bits. Mitigation: BitVM verifies the full transaction off-chain and rejects proofs using non-SIGHASH_ALL flags in the puzzle signatures.

Attack: Sighash Byte Entropy

All 256 sighash flag bytes are consensus-valid, giving an attacker 16 extra bits of grinding freedom across 2 rounds. Impact: Only ~0.6 bits of security reduction because pinning work (4 × 242) dominates sample cost, making the puzzle work reduction negligible. BitVM enforcement of canonical SIGHASH_ALL further mitigates this.

8 Limitations

9 Current Status

Proof-of-Concept Deployed

Transactions demonstrating a 4-byte Binohash have been successfully executed on both Testnet4 and Bitcoin Mainnet, mined via Marathon's Slipstream service. The paper includes a Polyglot Digest optimization (Appendix D) that could reduce script size by ~3.7 KB by merging dummy signatures with HORS hash commitments.

Future Work

See Also: Background from Every Byte Tells a Story

Binohash composes several primitives in subtle ways. For the underlying mechanics: