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.
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.
| Legacy | inputs and outputs, first and unchanged |
| PQ input | previous output, 36 bytes · sequence number, 4 bytes |
| PQ output | amount, 8 bytes · format, 1 byte · scheme, 1 byte · script hash, 32 bytes |
| Signing mode | sighashInfo, 2 bytes |
| Input script | the signatures, then the spending script they satisfy |
- 1The same asset. PQ coins are transparent ZEC. The transparent bundle declares one value delta covering both kinds of coin, and there is no new chain value pool.
- 2v7 only. The PQ lists exist only in the v7 transparent bundle, so they activate at or after the network upgrade that introduces v7.
- 3Backward-compatible and opt-in. Existing transparent outputs stay valid and are spent as they are today.
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:
| Node | A transaction with a PQ input or output | Outcome |
|---|---|---|
| Without the PQ rules | It cannot read the PQ lists in the transparent bundle, so the transaction does not parse. | Rejected |
| With the PQ rules, before activation | Refused before any coin is looked up. | Rejected |
| With the PQ rules, from activation | Every 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.
| Format | Scheme | Signatures | Script hash |
|---|---|---|---|
| 0 | 1 | Bonsai (ZPQ-SHA2-160), 7,812 bytes | SHA-256, 32 bytes |
| 0 | any other | undefined | rejected |
| 1 to 255 | any | undefined | rejected |
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.
(txid, 0)transparent(txid, 1)transparent(txid, 2)PQ- 1One coin database. Wallets, explorers and nodes see one kind of outpoint and look both kinds of coin up in the same set.
- 2The node records each coin's kind. A legacy input may spend only a legacy coin and a PQ input only a PQ coin, so a PQ coin is never checked under the legacy script rules.
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
| Opcode | Byte | What it does |
|---|---|---|
OP_CHECKPQSIG | 0xba | Takes a key and a signature, and leaves whether the signature is valid. |
OP_CHECKPQSIGVERIFY | 0xbb | The same, but the spend fails at once if the check fails. |
OP_CHECKPQSIGADD | 0xbc | Takes 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:
- 1Legacy scripts are unchanged. They read
0xbato0xbcas unknown opcodes, which fail when executed, and the legacy interpreter is not touched. - 2Legacy checks are refused in a PQ script.
OP_CHECKSIG,OP_CHECKSIGVERIFY,OP_CHECKMULTISIGandOP_CHECKMULTISIGVERIFYare invalid wherever they appear, executed or not, including inside an unusedIFbranch. - 3One algorithm per output. A script cannot mix ECDSA and PQ checks, so a recovery path is built from several PQ keys.
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:
- 1A failed signature ends the spend. Only an empty signature evaluates to false, and it does so without any cryptography.
- 2A byte budget. Each check with a non-empty signature costs 7,812 bytes, charged before it runs. A spend whose checks cost more than its input script is invalid, so a copied signature buys no second check.
- 3Whole-transaction signing only. Every signature covers the whole transaction (
SIGHASH_ALL). - 4One spelling. Pushes and numbers use their shortest encoding and execution ends with exactly one item, so nobody relaying a spend can edit it and keep it valid.
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.
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.
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
| Spend | Input size | Actions | Minimum fee | Standard fee |
|---|---|---|---|---|
| Legacy single-key payment | 150 B | 2 | 0.000008 ZEC | 0.00002 ZEC |
| One single-key PQ input | 7,904 B | 53 | 0.000212 ZEC | 0.00053 ZEC |
| Ten single-key PQ inputs | 79,040 B | 527 | 0.002108 ZEC | 0.00527 ZEC |
| One 2-of-3 PQ input | 15,808 B | 106 | 0.000424 ZEC | 0.00106 ZEC |
- 1About 26 times a legacy payment. At either rate, against a minimum-size ECDSA payment.
- 2The spender pays. Paying a PQ address costs the sender a 42-byte output against 34 for today's pay-to-key, at most one more action.
- 3Combining saves nothing. Every input carries its own signature, so the fee follows the total input size.
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
- 1Addresses are generated ahead of need. With no extended public key, only the holder of the secret can compute the next address. The wallet keeps a small pool and refills it while signing.
- 2Everything still recovers from the mnemonic. A hardware wallet has to be connected to regenerate its addresses, at 20.3 s each on a Ledger Nano S Plus.
- 3Change goes to the shielded pool. A spend never leaves a new PQ output that would cost another signature to move.
- 4One signature per payment received. A wallet shows a new address once the current one is paid, so each payment sits at its own key and costs one signature to move.
Next steps
- Formal specification (ZIP).
Open items
- One signature per key per transaction. Inputs at the same address share one signature: ten of them take about 8.6 KB instead of 79 KB.
- Requiring signatures from more than one scheme (AND). A coin stays safe while either scheme holds. "Either may sign" stays impossible.