05 · the curve we shipped on
BN254
The 254-bit pairing-friendly curve the shielded pool was built on — Ethereum's alt_bn128, circom's default, and the curve with the cheapest on-chain verifier anyone has measured on Bitcoin Cash. This page records what it costs, what it gives up, the one verifier generation we had to retract, and the reviewed generation that replaced it — now deployed on chipnet.
[measured] = first-party measurement with a recorded source · [cited] = third-party bench number · [derived] = arithmetic from the curve parameters · nothing here is estimated
01 · the object
What BN254
Actually Is
A Barreto–Naehrig curve over a 254-bit prime with embedding degree 12. Every arithmetic operation inside the circuit happens in a 254-bit field, so a single field element is one 32-byte word — no limb splitting, no carry games. That is why the constraint counts are what they are.
parameters, as we build against them
verified- family
- BN (Barreto–Naehrig) · pairing-friendly · embedding degree 12
- base prime
- 254-bit · 32 B serialized field element
- G1 b
- 3
- G2 twist
- D-twist
- ξ (sextic)
- 9 + u
- ate loop
- NAF of 6x+2, plus Q1/Q2 ψ post-step · x positive
- line mul
- mul034 (divisive)
- final exp
- BN scheme
- compiler
- circom 2.2.3, --prime bn128 (the default) — verified via circom --help
- toolchain
- snarkjs groth16 · r1cs reports curve bn-128
curve comparison table: groth16_cashscript/bls12-381 ↗ · compiler: circom 2.2.3 on the apecsdev VM
02 · the choice
Why This Curve, and Not Another
Four reasons, in the order they actually mattered. Only one of them is about the curve itself.
The toolchain default
circom compiles to BN254 unless you pass --prime. snarkjs generates and verifies BN254 Groth16 proofs by default. Choosing anything else means opting out of the default path of both tools — a real cost when the goal was to prove the pool could exist at all.
The cheapest verifier measured
On the BCH VM the verifier is the expensive part, not the prover. Across every construction the public bench has graded, the smallest deployable sound verifier is BN254 at 27,624 B in 3 inputs. The smallest sound BLS12-381 verifier is 34,229 B in 4. On a chain where bytes are fees, that gap is the argument.
A ceremony transcript already exists
The Perpetual Powers of Tau transcript is BN254. Ours is ppot_0080_18.ptau — 302,083,218 B, sha256 9693220206afab749e3d88d4ab5fdf5d36120ea102e7e587ccea0e7a5208e711. A different curve means a different transcript means a different ceremony. That is the single most expensive consequence of a curve change, and it is why the curve decision and the ceremony decision should be made together.
The verifier engineering existed
A full Groth16 pairing check does not fit in one BCH input. Someone had to work out how to split the Miller loop and the final exponentiation across inputs, hand state over byte-exactly, and stay inside a per-input op budget. That work existed for BN254 first. Building it for another curve would have been a research project of its own — which is exactly what the BLS12-381 pages now document.
03 · the numbers
What It Measured
first-party measurements on chipnet, 2026-10/11 · hardware spec for proving times UNMEASURED
| quantity | value | tag |
|---|---|---|
| single-asset circuit | 183,472 constraints · 107 private inputs · 181,959 wires | measured |
| multi-asset circuit | 186,007 constraints (+1.38%) · variant b, Poseidon(6) note | measured |
| 3-out circuit (v3 demo) | 184,528 constraints (+1,056, +0.58%) · 112 private inputs · 183,017 wires · 20.2 s compile | measured |
| 3-out carrier + actionHash | 201 B · 9 fields (cm2) · action +32 B · 2 public inputs unchanged | measured |
| 3-out setup | 1-of-1 demo VK/zkey/wasm built 2026-11-26; 3-out verifier 7,310 B plain / 7,848 B hooked, hook 39,082/37,930 op; acceptance 21/21; red team 146/0; demo pool deployed; new MPC (Gate 7) pending | measured + deployed demo |
| public inputs | 2 — [merkleRoot, actionHash] · vk IC length 3 | measured |
| Groth16 proof | 128 B — 2 × G1 (32 B) + 1 × G2 (64 B) | derived |
| proving time | 16.967 s (183,472) · 17.6 s (186,007) · snarkjs fullProve | measured |
| covenant redeem | 347 B — identical for every asset (category is a constructor arg) | measured |
| verifier, generation 1 | 35,626 B · 5 inputs · 24.3M op · withdrawn | measured + cited |
| verifier, generation 2 | 27,624 B · 3 inputs · 20.72M op · deployed (role-2 pool, 2026-11-24) | cited |
| pool-op tx size | ~36.8 – 37.8 KB per shielded operation | measured |
build records: APECSdev/pusd-shielded-pool ↗ · deployment: /research/shielded-pool →
04 · the record
Verifier Generations
We have deployed one, reviewed the other, and built the 3-out VK — the 3-out verifier program and a chipnet demo pool are live. The difference between the verifier generations is not performance — it is whether the argument that a forged proof cannot pass still holds. The 3-out is a circuit generation, not a verifier rewrite: the same reviewed verifier, a new VK and a new setup.
densless-msm
withdrawn- size
- 35,626 B
- shape
- 5 inputs
- op-cost
- 24.3M op
- redeems
- 347 B covenant / 574 B exec / 6044 B genesis / 4415 B terminal
The build every pool deployed before 2026-11-24 (gate3, gate6, gate6b, mainnet, nito v2/v4). Withdrawn by its author on 2026-10-26 under finding F6: the shared Miller event consumes slopes without the tangent/chord equations, and the terminal compares a value with itself instead of checking the B endpoint. Its vk_x MSM does repair the public-input binding — which is what our red-team numbers actually measured.
bch-groth16-bn254-sound-native · 3-out VK
deployed demo- size
- 7,310 B plain / 7,848 B hooked
- shape
- 3 inputs
- op-cost
- 39,082 std / 37,930 cons hook
- redeems
- new VK → new program P2SH32; fixture-category locking aa200240…; demo pool locking aa204a6c…
The 3-out circuit (184,528 constraints, +1,056, +0.58%) uses the same reviewed sound verifier with a NEW verifying key. The 1-of-1 demo setup (new VK d4ed12ee…, zkey b0177dbe…, wasm c806e561…), the 3-out verifier program (7,310 B plain sha256 6ec7ca8e…; 7,848 B hooked sha256 628207b1…), the 201-B role-2 hook, the 9-field actionHash and the 3-out witness are BUILT; acceptance 21/21, red team 146/0, sweep 69/69. A 3-out demo pool is deployed on chipnet (SHIELD e847ef56… → TRANSFER ef64f3dd… → UNSHIELD ec31a41c…). The new MPC (Gate 7) and the Nito client UI remain, while the 3-out blank path IS live (vending machine aa2020bd…, price 1,000 sats, first stranger buy 569a6e6d… at block 348,775); the 3-out witness path is built and byte-exact, and the proving assets are live on prover.nito.cash. The 3-out is the note-management layer of v3; the deposit path, the nullifier set and encrypted note delivery are the other v3 pieces.
bch-groth16-bn254-sound-native
reviewed- size
- 27,624 B
- shape
- 3 inputs
- op-cost
- 20.72M op
- redeems
- 65 B, identical in all three inputs (locking aa20 d9ba…a11a 87)
Independently reviewed 2026-10-26. Sound by construction: every accept-relevant value is computed on-chain, a baked VK constant, hash-committed before any challenge it meets, or fixed by an exact field or integer equation. Smaller, cheaper and two inputs fewer than the withdrawn build. Verifies the same relation under the same verifying key — so it needed NO new trusted setup. It is NOT a drop-in beside a covenant, though: its graph pins exactly 3 inputs, every one of them spending the same P2SH32, and forbids any funding or fee input with another locking. So the route was to extend its third role with the pool rules (the README's supported integration point: "applications that release funds add output rules in role 2") — and that route is now SHIPPED: the chipnet role-2 pool (deployed 2026-11-24, block 345,467) runs this verifier with the pool rules as a role-2 hook — acceptance 20/20, red team 146/0, liveness sweep 69/0.
05 · the constraint
Why a Pairing
Check Has to Be Split
This is the whole engineering problem, and it is a BCH problem, not a BN254 problem. The same constraint applies to every curve: the verifier is bigger than one input allows, so it must become several inputs that hand state to each other.
the two hard limits
- script cap
- 10,000 B per input — a full pairing check does not fit
- op budget
- (41 + unlockingLength) × 800 per input — ≈ 8.03M for a max-size input
- consequence
- the verifier MUST be split across inputs and/or transactions
- generation 1
- verifier as sibling inputs in the SAME transaction, beside the covenant
- generation 2 · deployed
- pool rules INSIDE the verifier (role 2) — one program, no siblings
- generation 3 · 3-out (chipnet demo)
- same reviewed verifier, NEW VK — 184,528-constraint 3-out circuit; verifier/hook/witness built; demo pool deployed; Gate 7 pending
how the sound build solves it
Three roles, one per input, each covering a range of the 65 Miller events — cut at [0,24), [24,48), [48,65). Each role ends by handing over a byte-exact canonical state that the next role pins. The B walk is affine: every doubling and addition reads one 32-byte inverse-norm witness fixed by the exact equation t·N(den) ≡ 1, so no prover-supplied evaluation is trusted anywhere.
Measured margins per input: 5.81% / 5.81% / 5.80% of the standard-mode budget, 6.26% / 6.27% / 6.26% of consensus. Worst case (every nibble 15) is 11.95% below the 10,000-byte cap budget of 8,032,800.
06 · the trade
What BN254 Gives Up
security margin
BN254's base field is 254 bits, which after the tower and the embedding degree yields a security level materially below the 128-bit target that BLS12-381 was designed for.
[ UNVERIFIED ] — the specific bit figures are commonly cited but we have not obtained a primary citation. We will not publish a number until we can.
the ceremony is curve-bound
Powers-of-Tau transcripts are curve-specific. Ours is BN254-only — the PSE repository ships phase2-bn254 and every instruction targets it. A BLS12-381 pool therefore needs its own multi-party ceremony; the work cannot be reused.
not post-quantum
Groth16 is pairing-based. Every construction on this page — on either curve — falls to a sufficiently large quantum computer. The pool's privacy is a present-tense property, not a longevity claim, and we say so on the pool page.
07 · open
Open Questions
Does the sound verifier change the circuit or the setup?
No. bch-groth16-bn254-sound-native verifies the same Groth16 relation under the same verifying key — it is a different implementation of the same check. The 183,472-constraint R1CS, the proving key and the ceremony output are all unchanged. What changes is the pool's composition: the sound build pins exactly three inputs, all spending the same P2SH32, and permits no funding input with another locking — so a covenant cannot sit beside it. The pool rules therefore move INTO the verifier's third role, which is the integration the artifact documents ("applications that release funds add output rules in role 2"). That code is now written, gated and deployed on chipnet (2026-11-24): the role-2 hook passes acceptance 20/20, red team 146/0 and a 69-scenario liveness sweep — and it remains our own code; Nito Cash's own client is the final approval before it carries real value.
Could a forged proof have drained a pool?
Unknown, and we will not pretend otherwise. The withdrawal says no end-to-end false acceptance is claimed — nobody has demonstrated one. What is established is that the on-chain check does not enforce the tangent/chord equations and does not test the B endpoint, so the usual argument is unavailable. Because the pool covenant credits value from the proof's public inputs, an actor able to craft a witness is the threat model. This is why the replacement is the next deployment and not a roadmap item.
Is BN254 still the right choice after all this?
It is the deployed choice — the chipnet role-2 pool runs the reviewed sound BN254 verifier — and for a reason that is not about the curve: it is the smallest sound verifier that exists, it is reviewed, and it needed no new ceremony. The curve decision that actually matters is the one made alongside Gate 7, because that is the step which forces a new transcript either way. See /research/bls12-381 for the comparison.
What would we need to measure to publish a security comparison?
Three things: a primary citation for the security level of each curve; a circom --prime bls12381 compile of pool.circom to get a real constraint count (we have not run it — UNMEASURED); and a verifier regeneration under the same VK to confirm the on-chain size delta on our own artifacts rather than the bench's fixtures.
08 · sources
Sources
groth16_cashscript — verifiers.md (the map, incl. F6)
https://github.com/mr-zwets/groth16_cashscript/blob/main/verifiers.md
densless-msm — the withdrawal record
https://github.com/mr-zwets/groth16_cashscript/blob/main/chunked/bn254/densless-msm/README.md
bn-native-sound — the reviewed replacement
https://github.com/mr-zwets/groth16_cashscript/blob/main/chunked/bn254/bn-native-sound/README.md
zk-verifier-bench — the grading harness
https://github.com/mr-zwets/zk-verifier-bench
perpetualpowersoftau — the BN254 ceremony transcript
https://github.com/privacy-scaling-explorations/perpetualpowersoftau
our circuit + design records
https://github.com/APECSdev/pusd-shielded-pool
3-out v3 design
https://github.com/APECSdev/hushyourmoney/blob/master/docs/ROLE2-3OUT-V3-DESIGN.md
3-out circuit (pool3.circom)
https://github.com/APECSdev/pusd-shielded-pool/blob/master/circuits/pool3.circom