Bonsai Measurements ↗ Code ↗

Integration Status: Draft

How post-quantum transparent payments enter Zcash

This is a draft proposal, implementing transparent post-quantum spending with a Bonsai signature to supersede ECDSA. It adds two lists, PQ inputs and PQ outputs, to the transparent bundle of the ZIP 248 v7 transaction format, after the legacy inputs and outputs, so existing transparent outputs and their rules stay exactly as they are.

Carried in
Type 0
Two lists in the ZIP 248 transparent bundle, v7 transactions only
Output
42bytes
Amount, format, scheme, script hash
Single-key input
7,904bytes
7,812 of them are the signature
Fee to spend one
0.00053ZEC
7,904 B ÷ 150 B per action = 53 actions, rounded up, × 1,000 zatoshis

Two lists in the transparent bundle

The v7 transaction format (ZIP 248) is a list of typed bundles. Each keeps its effects, what it spends and creates, apart from its authorization, the scripts and signatures. Post-quantum (PQ) payments go in the transparent bundle, type 0, variant 0, as two lists after its legacy inputs and outputs.

The legacy inputs and outputs are unchanged byte for byte. A count and list of PQ inputs follows them, then a count and list of PQ outputs, so a transaction with no PQ parts grows by two zero bytes. A PQ output is an entry in its own list. It is never a script among the legacy outputs.

This layout is proposed and awaits the ZIP 248 authors. It replaces an earlier draft that gave PQ payments a bundle of their own, type 7. That type is not registered, so a transaction carrying it does not parse.

EffectsCommitted to by the transaction identifier, through one sub-digest inside the transparent bundle's digest.

Legacyinputs and outputs, first and unchanged
PQ inputprevious output, 36 bytes · sequence number, 4 bytes
PQ outputamount, 8 bytes · format, 1 byte · scheme, 1 byte · script hash, 32 bytes

AuthorizationOne record per PQ input.

Signing modesighashInfo, 2 bytes
Input scriptthe signatures, then the spending script they satisfy

Fails closed

Because a PQ output is not a script, there is nothing for the legacy rules to run and nothing an empty input script can satisfy. What a node does with a PQ payment depends only on whether it knows the PQ lists:

NodeA transaction with a PQ input or outputOutcome
Without the PQ rulesIt cannot read the PQ lists in the transparent bundle, so the transaction does not parse.Rejected
With the PQ rules, before activationRefused before any coin is looked up.Rejected
With the PQ rules, from activationEvery PQ input is verified in full.Verified

No node can read a PQ output as spendable by anyone. A wallet that builds one too early has made a transaction no node accepts, and the coins never move.

A bad output is refused when it is created

The format and scheme sit in the output, so a pair that no rules define does not decode. The transaction that would create it is invalid while the sender still holds the coins, instead of the receiver finding out when they try to spend.

A wallet that does not check PQ spends

A scanner cannot skip PQ data as a separate bundle: every reader of the v7 transparent bundle reads the two PQ lists. Their entries have fixed sizes, so this takes no PQ rules, and the scanner still finds an ordinary transparent payment in the same transaction. Checking the PQ spend itself needs the PQ rules.

The output

Forty-two bytes: an amount, two bytes that name how the output is read and which signatures it accepts, and the hash of the script that may spend it.

A PQ output paying 100 ZECAs serialized in the transparent bundle's list of PQ outputs.
Amount800 e4 0b 54 02 00 00 00
Format100
Scheme101
Script hash32SHA-256 of the spending script
FormatSchemeSignaturesScript hash
01Bonsai (ZPQ-SHA2-160), 7,812 bytesSHA-256, 32 bytes
0any otherundefinedrejected
1 to 255anyundefinedrejected

The format says how to read and check the output: the hash, its length and the spend rules. The scheme says which signatures are valid under it. A later change, such as a 48-byte hash, is one new format in which the signature scheme keeps its number, with no change to the transaction layout.

One set of unspent outputs

PQ outputs share the transparent outpoint space. A transaction's transparent outputs are numbered first and its PQ outputs follow: PQ output j is the outpoint (txid, n + j), where n is the number of transparent outputs.

Two transparent outputs and one PQ outputAdding PQ outputs changes no transparent output's index.
(txid, 0)transparent
(txid, 1)transparent
(txid, 2)PQ

A 32-byte script hash

The hash is SHA-256 over the exact script bytes. Today's pay-to-script hash is 20 bytes; at 32, the generic classical collision bound rises from 280 to 2128.

Collisions matter where someone else can influence the script before the address is agreed, as in a multisig setup. For an address a wallet generates alone, an attacker needs a second preimage of that one hash.

The spending script

The output commits to a script rather than a key, so several signers, timelocks and recovery branches stay expressible. The spender reveals the script, the node checks its hash against the output, and the PQ evaluator runs it.

An address issued from a derived key always commits to one fixed script, so a wallet restored from its seed can recompute every address it gave out:

PUSH40 <public key> OP_CHECKPQSIG        42 bytes: 28 <40 bytes> ba

seed → key → script → script hash → address

Signature opcodes of its own

OpcodeByteWhat it does
OP_CHECKPQSIG0xbaTakes a key and a signature, and leaves whether the signature is valid.
OP_CHECKPQSIGVERIFY0xbbThe same, but the spend fails at once if the check fails.
OP_CHECKPQSIGADD0xbcTakes a key, a counter and a signature, and adds one to the counter when the signature is valid. This is how a threshold is written.

The opcodes name no scheme. OP_CHECKPQSIG verifies under whatever scheme the output names: Bonsai today, and a later scheme without a new opcode.

No opcode means one thing in a legacy script and another in a PQ one:

One signature, one check

Block size limits how many signatures fit in a block. That bounds verification work only if one signature can cause only one check, so a PQ script follows four more rules:

Most checks a 2 MB block can demand
256
Its size divided by the signature size, however its scripts are written
Checks in an honest full 2 MB block
253
One per single-key input

The worst block costs about what an honest full one does, so no separate verification budget or multisig cap is needed. Hashing is not covered by the budget, and the time one check takes on a node is still to be measured.

What a signature covers

Each PQ input signs the transaction identifier, the legacy coins the transaction spends, a tag that marks the signature as a PQ one, a hash of every PQ coin it spends, and the input's own outpoint, coin, sequence number and position. The signing context also binds the network, the format and the scheme, so a signature made for one pair cannot authorize another.

Multisig

A threshold is written with OP_CHECKPQSIGADD, which works like Bitcoin's OP_CHECKSIGADD (BIP 342). Each key has its own slot, and a key that does not sign supplies an empty item.

Two of three, signed by A and CThe input lists its signatures in reverse key order, then the script.
Script  <A> OP_CHECKPQSIG <B> OP_CHECKPQSIGADD <C> OP_CHECKPQSIGADD OP_2 OP_NUMEQUAL
Input   <signature C> <empty> <signature A> <script>
Checks
Exactly k for a k-of-n. Nothing is tried against a key it does not belong to.
Size
No twenty-key limit. A key that does not sign costs one byte.
Setup
Hash-based keys have no extended public key, so cosigners exchange public keys generated in advance instead of xpubs. The rest of the ZIP 48 multisig model carries over.
Conditions
Timelocks and recovery branches remain ordinary script.
Backup
A hash says nothing about the script behind it, so a wallet that commits to its own script keeps the script's template with its recovery material.
Cost
A two-of-three input is 15,808 bytes: 106 actions, 0.00106 ZEC.

Threshold signature schemes such as FROST rest on elliptic curves, so a PQ threshold lives in the script.

Fees

PQ spends use the existing fee rule with no discount. Transparent data is counted in logical actions (ZIP 317): one per 150 input bytes or per 34 output bytes, whichever count is larger, each rounded up. A PQ input is almost all signature, so the size rule already charges for it.

From bytes to a feeSpending one single-key PQ output.
Input size7,904bytes
÷ 150
Logical actions53rounded up
× 1,000 zatoshis
Fee0.00053ZEC

Counts the PQ inputs only: outputs and shielded actions are added on top, and the smallest charge is two actions. At the minimum rate of 400 zatoshis per action the same spend is 0.000212 ZEC. The 3-of-5 figure is arithmetic from the same sizes.

Where the bytes go

One single-key input, 7,904 bytesThe signature is pushed with its one-byte signing mode.
Coin, sequence, mode42
Length3
Signature7,816
Script43
SpendInput sizeActionsMinimum feeStandard fee
Legacy single-key payment150 B20.000008 ZEC0.00002 ZEC
One single-key PQ input7,904 B530.000212 ZEC0.00053 ZEC
Ten single-key PQ inputs79,040 B5270.002108 ZEC0.00527 ZEC
One 2-of-3 PQ input15,808 B1060.000424 ZEC0.00106 ZEC

Addresses and wallets

A PQ destination is the 32-byte script hash, published in one of two forms. Both produce the same output on chain.

Unified Address
A new receiver beside the ones a recipient already publishes (ZIP 316; typecode 0x04, provisional). Senders that know it pay PQ, and every other sender keeps paying the shielded or legacy receiver in the same address. No address is reissued.
Preference
Orchard, Sapling, PQ, P2SH, P2PKH. PQ ranks above legacy transparent because its authorization is stronger, and below shielded because a transparent payment is public for good.
Standalone
tpq1qp…, about 64 characters of Bech32m, for a destination with no shielded receiver. Specified now and built after the Unified Address receiver.

What changes for a wallet

Next steps

Open items