    ZIP: Unassigned (proposed as text for the reserved ZIP 2007)
    Title: Quantum Recoverability for Transparent Funds
    Owners: igor <saplingzcash@gmail.com>
    Credits: Sapling Technologies LLC (the companion design, lab and test vectors)
             Daira-Emma Hopwood (scoping in zips#1302 and the ZIP 2005 design this builds on)
             Jack Grigg (ZIP 2005)
    Status: Draft
    Category: Consensus
    Created: 2026-10-24
    License: MIT
    Discussions-To: <https://github.com/zcash/zips/issues/1302>


# Terminology

The key words "MUST", "MUST NOT", "SHOULD", "SHOULD NOT", and "MAY" in this
document are to be interpreted as described in BCP 14 [^BCP14] when, and only
when, they appear in all capitals.

The character § is used when referring to sections of the Zcash Protocol
Specification. [^protocol]

The terms "Mainnet" and "Testnet" are to be interpreted as described in
§ 3.12 ‘Mainnet and Testnet’. [^protocol-networks]

The term "network upgrade" is to be interpreted as described in ZIP 200.
[^zip-0200]

The terms below are to be interpreted as follows:

Discrete-logarithm-breaking adversary

: An adversary able to compute discrete logarithms on every elliptic curve
  used by Zcash, by quantum computation or otherwise, as in ZIP 2005.
  [^zip-2005] It may also run Grover's algorithm against hash functions.

Recovery switch

: The block height $\mathsf{RecoverySwitchHeight}$ from which transparent
  inputs authorized by ECDSA signatures are no longer valid and claims under
  this ZIP become valid. See [Activation of the recovery switch](#activation-of-the-recovery-switch).

Revealed script

: A byte string $\mathsf{s}$ is revealed if, in some block at a height below
  $\mathsf{RecoverySwitchHeight}$, $\mathsf{s}$ appears as a data push in a
  transparent input's scriptSig (including as a redeem script or as a public
  key), or as a public key push in a transparent output script. A public key
  is revealed in both of its SEC1 encodings (compressed and uncompressed) when
  either one is, since each gives the other.

Post-quantum destination

: A 32-byte value $\mathsf{dest}$ identifying the output a claim lands on: a
  Bonsai public key whenever a Bonsai output type is enabled, else a pay to
  post-quantum key hash (P2PQ) output, as defined in
  [Post-quantum landing outputs](#post-quantum-landing-outputs).

Recovery commitment

: A 32-byte hiding and binding commitment to an anchor, a post-quantum
  destination and payment terms, as defined in
  [Recovery commitments](#recovery-commitments).

Anchor

: The data a claim uses to show ownership of transparent outputs: an HD node,
  a preimage, or a registration.

Claim

: A transaction component that reclaims transparent outputs after the
  recovery switch, as defined in [Claims](#claims).


# Abstract

This proposal makes transparent ZEC recoverable after the elliptic curve
protocols are switched off in response to a discrete-logarithm-breaking
attack. It defines a recovery switch that disables ECDSA-authorized
transparent spends, three ways to show ownership of a transparent output
afterwards, and a minimal post-quantum output type for the recovered value.

The three ways are: revealing the hardened BIP 44 node m/44'/133' of an HD
wallet; revealing a public key or redeem script that was never revealed on
chain; and a registration made before the switch, authenticated by an
ordinary transparent spend. Each reveal is protected against front running by
a commit, delay, reveal protocol. Every check uses only hash functions and
deterministic computation, so this proposal does not depend on the choice of
a post-quantum proof system. A private form using a post-quantum
zero-knowledge proof of knowledge, as scoped in zips#1302, is outlined for a
later deployment.


# Motivation

On 2026-10-23 the transparent chain value pool held 11,968,063 ZEC, 70.4% of
the supply. ZIP 2005 makes *Ironwood-pool* notes recoverable, but does not
address transparent funds. [^zip-2005]

A discrete-logarithm-breaking adversary can forge ECDSA signatures for every
transparent address whose public key is known to it. A survey of the 500
largest transparent addresses on 2026-10-24, which together hold 84.6% of the
transparent pool, found 5.70M ZEC (56%) at addresses that had already spent
and so had revealed their public key or redeem script. For the 10 largest
addresses the share was 77%.

ZIP 2005 explains why the elliptic curve protocols must be switched off before
such an adversary appears. Once they are, every transparent output becomes
unspendable unless a recovery path exists. This ZIP provides that path for
every output that can be recovered safely, and makes the remaining gap
explicit so holders can close it themselves before the switch.


# Privacy Implications

1. Recovery commitments are hiding. They reveal neither the anchor, the
   destination nor which outputs they cover until a claim opens them.
2. An HD claim reveals the node m/44'/133', and so the link between every
   transparent address the wallet derived under it. That link was previously
   known only to the wallet. Claims are made only after the switch, when
   ECDSA keys no longer authorize anything, so this costs privacy and not
   funds.
3. A preimage claim reveals a public key or redeem script.
4. A type T registration is an ordinary transparent spend with an OP_RETURN
   output. It reveals that the spending addresses registered, but not the
   destination.
5. The private form outlined under [Rationale](#the-private-form) reveals only
   the claimed outputs, the destination, and a key tag.


# Requirements

1. After the recovery switch, a discrete-logarithm-breaking adversary MUST NOT
   be able to obtain the value of an output whose holder has an HD anchor, a
   type T registration earlier than any made by the adversary, or a preimage
   that never leaked.
2. Claims MUST NOT create value. Each output pays out at most once, and the
   total paid out MUST NOT exceed the transparent chain value pool balance at
   the switch.
3. No party other than the holder MUST be able to change how much of a claimed
   output goes to the holder's destination.
4. Every check MUST rely only on hash functions and deterministic computation.
5. Holders of HD wallets, and holders of addresses that have never spent,
   MUST NOT need to act before the switch.
6. Registrations MUST be possible before this ZIP activates, using only
   transactions that are valid and standard today.
7. Validation cost per block MUST be bounded.


# Non-requirements

1. Recovery of outputs already spent before the switch, including by an
   adversary.
2. Recovery of non-HD outputs whose public key or script was revealed on chain
   and that were never registered. For those, a discrete-logarithm-breaking
   adversary cannot be told apart from the holder.
3. Recovery of top-level P2PK, bare multisig and nonstandard outputs. On
   2026-10-24 unspent top-level P2PK outputs held about 789 ZEC.
4. Normal payments after the switch beyond the landing outputs.
5. Privacy against a discrete-logarithm-breaking adversary for past
   transactions.


# Specification

## Constants

| Constant | Value | Meaning |
|---|---|---|
| $\mathsf{RecoveryCommitDepth}$ | 1440 | blocks a commitment must be buried before it can be opened; also the maturity of HD claims |
| $\mathsf{RecoveryDisputeWindow}$ | 103680 | maturity of PREIMAGE and REGISTERED claims |
| $\mathsf{MaxClaimedOutputsPerBlock}$ | 2000 | transparent outputs claimed per block |
| $\mathsf{MaxClaimBytesPerBlock}$ | 500000 | bytes of claim bundles per block |
| $\mathsf{MaxStampedCommitmentsPerBlock}$ | 2000 | commitments in fee-free bundles per block |
| $\mathsf{ClaimFeePerOutput}$ | 5000 zatoshis | consensus claim fee per claimed output |
| $\mathsf{ClaimFeePerByte}$ | 1 zatoshi | consensus claim fee per byte of claim bundle |
| $\mathsf{StampTarget}$ | $2^{232}$ | proof of work target for fee-free commitment bundles |

The values assume the 25-second block target spacing of ZIP 218.
[^zip-0218] $\mathsf{RecoveryCommitDepth}$ exceeds the 600-block rollback
depth that ZIP 218 asks nodes to support. The per block limits are set so that
claim validation stays well below ZIP 218's worst case block verification
time. A reference implementation checks an HD claim in about 0.11 ms per
output on a current laptop core. The same core computes 2.2 to 3.2 million
stamp hashes per second, so a stamp at $\mathsf{StampTarget} = 2^{232}$ takes
$2^{24}$ hashes, or 5 to 7.5 seconds, on average.

## Notation

1. $\mathsf{H}_{p}(x)$ is $\mathsf{BLAKE2b\text{-}256}$ with the 16-byte
   personalization $p$, applied to $x$.
2. $\mathsf{Hash160}(x) = \mathsf{RIPEMD\text{-}160}(\mathsf{SHA\text{-}256}(x))$.
3. $\mathsf{I2LEOSP}_\ell(n)$ is the $\ell$-bit little-endian encoding of $n$.
4. $\mathsf{CompactSize}$ is the variable length integer encoding of § 7.1.
5. $||$ is concatenation.

Personalizations used in this ZIP:

| Name | Personalization |
|---|---|
| commitment | `ZcashRecov_Commt` |
| key tag | `ZcashRecov_KeyTg` |
| type T registration | `ZcashRecov_RegTr` |
| P2PQ destination | `ZcashRecov_P2PQ_` |
| landing descriptor | `ZcashRecov_PQLnd` |
| Merkle node | `ZcashRecov_Merkl` |
| stamp | `ZcashRecov_Stamp` |

## Post-quantum landing outputs

### Bonsai landing

When the consensus rules enable a Bonsai (ZPQ-SHA2-160) output type,
[^bonsai] a claim lands on a 40-byte Bonsai public key
$\mathsf{S} \,||\, \mathsf{PK.root}$ as Bonsai's specification defines it,
and

$$\mathsf{dest} = \mathsf{H}_{\texttt{"ZcashRecov\_PQLnd"}}(\mathsf{descriptor})$$

where $\mathsf{descriptor}$, version 1, is:

| Bytes | Field | Value |
|---|---|---|
| 1 | $\mathsf{kind}$ | 0x02 (Bonsai); other values are reserved |
| 1 | $\mathsf{labelLen}$ | length of $\mathsf{keyLabel}$ |
| $\mathsf{labelLen}$ | $\mathsf{keyLabel}$ | Bonsai's ASCII key label, `ZPQ-SHA2-160/key/v4` (19 bytes) for the current profile |
| 64 | $\mathsf{paramHash}$ | SHA-512 of Bonsai's 167-byte parameter block P, `3051b200db3eff5d1829d183a981b7f6508f8c86959d553b00624b337f8f4498e7b4dcb187101ad3ee00c6288f80a52738420a54fb1181a4acf76a9cedaf1f10` for the current profile |
| 40 | $\mathsf{pk}$ | $\mathsf{S} \,||\, \mathsf{PK.root}$ |

A claim that lands on a Bonsai key carries its $\mathsf{descriptor}$. It is
valid only if the descriptor hashes to $\mathsf{dest}$, its kind is 0x02, and
its $\mathsf{keyLabel}$ and $\mathsf{paramHash}$ are those of a Bonsai profile
the consensus rules enable at that height. The landing output is a Bonsai
output paying $\mathsf{pk}$.

Bonsai changes $\mathsf{paramHash}$ with any parameter or label in P, and its
key label with any other change to the construction. Either gives a different
descriptor and a different $\mathsf{dest}$, so a destination made under one
profile is never accepted under another.

The landing key MUST be a fresh Bonsai key whose public seed $\mathsf{S}$ is
chosen as Bonsai's specification requires, used for no other key.

### P2PQ landing (fallback)

A P2PQ output is a pair $(\mathsf{value}, \mathsf{dest})$ with
$\mathsf{dest} = \mathsf{H}_{\texttt{"ZcashRecov\_P2PQ\_"}}(\mathsf{pk})$, where
$\mathsf{pk}$ is a 32-byte SLH-DSA-SHA2-128s public key. [^FIPS205]

A P2PQ output is spent by revealing $\mathsf{pk}$ and a 7,856-byte
SLH-DSA-SHA2-128s signature over the transaction's signature digest, with the
context string `Zcash P2PQ v1`. The validator checks that $\mathsf{pk}$ hashes
to $\mathsf{dest}$ and that the signature verifies.

P2PQ outputs MUST NOT be created before $\mathsf{RecoverySwitchHeight}$. From
$\mathsf{RecoverySwitchHeight}$ they MAY be created by claims, by coinbase
transactions, by canaries, and by transactions spending P2PQ outputs, only if
no Bonsai output type is enabled at $\mathsf{RecoverySwitchHeight}$, or, for
a claim, if its destination was fixed by a registration mined before a Bonsai
output type was enabled.

P2PQ outputs are carried in a dedicated bundle of the extensible transaction
format. [^zip-0248] Its value balance entry and its contribution to the
signature digest are to be specified with the other ZIP 248 bundle
registrations.

## Anchors and key tags

| anchorType | Name | anchorMaterial | Length |
|---|---|---|---|
| 0x02 | HD | $\mathsf{k} \,||\, \mathsf{c}$: private key and chain code of the node m/44'/133' | 64 |
| 0x03 | PREIMAGE | a public key encoding or redeem script $\mathsf{s}$ | 33, 35, 65 or 25 |

(Type 0x01 is reserved for *Ironwood-pool* spending keys, specified separately.)

The key tag of an anchor is

$$\mathsf{keyTag} = \mathsf{H}_{\texttt{"ZcashRecov\_KeyTg"}}(\mathsf{anchorType} \,||\, \mathsf{anchorMaterial}).$$

## Recovery commitments

A recovery commitment is

$$\mathsf{C} = \mathsf{H}_{\texttt{"ZcashRecov\_Commt"}}(\mathsf{anchorType} \,||\, \mathsf{I2LEOSP}_{32}(\mathsf{len}(\mathsf{anchorMaterial})) \,||\, \mathsf{anchorMaterial} \,||\, \mathsf{dest} \,||\, \mathsf{salt} \,||\, \mathsf{terms})$$

where $\mathsf{salt}$ is 32 random bytes and
$\mathsf{terms} = \mathsf{payDest} \,||\, \mathsf{I2LEOSP}_{64}(\mathsf{payAmount})$
is 40 bytes naming an optional payment, out of the claimed value, to the
landing destination $\mathsf{payDest}$, for example to an aggregator that posted the
commitment. $\mathsf{terms}$ is all zero bytes when there is no payment.

### Commitment bundle

| Field | Size | Description |
|---|---|---|
| flags | 1 | bit 0: rooted; bit 1: stamped; other bits MUST be 0 |
| nItems | 1 | 1 to 8 |
| items | 32 × nItems | commitments, or, if rooted, Merkle roots |
| stamp | 32 if stamped | proof of work stamp |

A Merkle root is computed over up to $2^{16}$ commitments as a binary tree of
$\mathsf{H}_{\texttt{"ZcashRecov\_Merkl"}}(\mathsf{left} \,||\, \mathsf{right})$
nodes, where an odd node at any level is paired with itself.

The position of a commitment is
$(\mathsf{height}, \mathsf{txIndex}, \mathsf{itemIndex}, \mathsf{leafIndex})$,
with $\mathsf{leafIndex} = 0$ for an unrooted item. Positions are ordered
lexicographically.

Commitment bundles are valid from the activation of this ZIP, before and after
the switch. A bundle MAY pay a fee in the usual way. From
$\mathsf{RecoverySwitchHeight}$, a bundle that pays no fee MUST be stamped:
$\mathsf{H}_{\texttt{"ZcashRecov\_Stamp"}}(\mathsf{flags} \,||\, \mathsf{nItems} \,||\, \mathsf{items} \,||\, \mathsf{stamp})$,
read as a little-endian integer, MUST be below $\mathsf{StampTarget}$. A block
MUST NOT contain more than $\mathsf{MaxStampedCommitmentsPerBlock}$ items in
stamped bundles.

## Registrations

A type T registration is a transaction mined at a height below
$\mathsf{RecoverySwitchHeight}$ that spends at least one transparent input and
has exactly one OP_RETURN output whose script is

    0x6a 0x25 "ZQR1" 0x54 R

that is, OP_RETURN followed by a 37-byte push of the ASCII bytes `ZQR1`, the
type byte 0x54, and
$\mathsf{R} = \mathsf{H}_{\texttt{"ZcashRecov\_RegTr"}}(\mathsf{dest} \,||\, \mathsf{salt})$.

The registration covers every transparent address (P2PKH public key hash or
P2SH script hash) of the outputs that the transaction's transparent inputs
spend. Its position is $(\mathsf{height}, \mathsf{txIndex})$.

For each address, the earliest registration covering it (by position) is the
address's registration. Later registrations covering the same address have no
effect for it.

Registrations need no consensus change before this ZIP activates. The 39-byte
script is within the 83-byte OP_RETURN relay limit of zcashd and Zebra. A
registration is authenticated by the ordinary script validation of its
inputs, so a P2SH multisig address registers with the signatures its script
requires. Wallets SHOULD create registrations as transactions that send the
registering addresses' funds back to the same addresses or to an
*Ironwood-pool* address.

## Claims

### Claim bundle

| Field | Size | Description |
|---|---|---|
| anchorType | 1 | 0x02 HD, 0x03 PREIMAGE, 0x52 REGISTERED |
| anchorMaterial | CompactSize length, then bytes | absent for REGISTERED |
| dest | 32 | |
| salt | 32 | |
| terms | 40 | absent for REGISTERED |
| reference | see below | |
| nOutputs | CompactSize | 1 or more |
| outputs | see below | |

For HD and PREIMAGE the reference is the commitment's position (height 4
bytes, txIndex 4 bytes, itemIndex 1 byte, leafIndex 2 bytes), followed, for a
rooted item, by its Merkle path (depth 1 byte, at most 16, then depth × 32
bytes of siblings from the leaf upward). The path's direction at each level is
the corresponding bit of leafIndex, and leafIndex MUST be below
$2^{\mathsf{depth}}$. For REGISTERED it is the 32-byte txid of the
registration.

Each output entry is an outpoint (32-byte txid, 4-byte index), followed for HD
by the path suffix (account 4 bytes, change 4 bytes, index 4 bytes, each below
$2^{31}$).

Claims MUST NOT be included in blocks below $\mathsf{RecoverySwitchHeight}$.

### Checks common to all claims

For a claim in a block at height $h$:

1. Every claimed outpoint MUST refer to a transparent P2PKH or P2SH output
   that was unspent at $\mathsf{RecoverySwitchHeight}$.
2. The claim's fee is
   $\mathsf{fee} = \mathsf{ClaimFeePerOutput} \cdot \mathsf{nOutputs} + \mathsf{ClaimFeePerByte} \cdot \mathsf{claimBundleSize}$.
   It is fixed by consensus and is not a field of the claim. Let $V$ be the
   sum of the claimed outputs' values. $V$ MUST be at least
   $\mathsf{fee} + \mathsf{payAmount}$.
3. The claim creates a landing output to $\mathsf{dest}$ of value
   $V - \mathsf{fee} - \mathsf{payAmount}$ and, if $\mathsf{payAmount} > 0$,
   a landing output of value $\mathsf{payAmount}$ to $\mathsf{payDest}$. Both
   are landing outputs of the claim, each a Bonsai or a P2PQ output as
   [Post-quantum landing outputs](#post-quantum-landing-outputs) requires.

### HD anchors (anchorType = 0x02)

$\mathsf{anchorMaterial} = \mathsf{k} \,||\, \mathsf{c}$ is the BIP 32
extended private key at the hardened path m/44'/133'. [^BIP32] [^BIP44]

For each output entry with path suffix
$(\mathsf{account}, \mathsf{change}, \mathsf{index})$, the validator MUST:

1. derive, by BIP 32 private derivation (CKDpriv) from
   $(\mathsf{k}, \mathsf{c})$, the key at child indices
   $\mathsf{account} + 2^{31}$, then $\mathsf{change}$, then $\mathsf{index}$,
   rejecting the claim if any step yields an invalid key;
2. compute the 33-byte compressed SEC1 encoding $\mathsf{P}$ of that key's
   public key;
3. check that the outpoint is a P2PKH output with public key hash
   $\mathsf{Hash160}(\mathsf{P})$.

### Preimage anchors (anchorType = 0x03)

$\mathsf{anchorMaterial} = \mathsf{s}$ is one of:

1. a 33-byte compressed or 65-byte uncompressed SEC1 public key encoding, for
   P2PKH outputs;
2. a 35-byte redeem script `<33-byte push> OP_CHECKSIG` (P2SH-wrapped P2PK).

The validator MUST check that:

1. every claimed outpoint is a P2PKH output with public key hash
   $\mathsf{Hash160}(\mathsf{s})$ when $\mathsf{s}$ is a public key, or a
   P2SH output with script hash $\mathsf{Hash160}(\mathsf{s})$ when
   $\mathsf{s}$ is a redeem script;
2. $\mathsf{s}$ is not a revealed script;
3. for a P2SH-wrapped P2PK script, the public key it contains is not a revealed
   script.

A P2SH-wrapped P2PKH redeem script is not a preimage anchor. It is byte for
byte the output script of a P2PKH address, so anyone who has seen that key
hash on chain could rebuild it. Holders of such outputs register, or use an
HD anchor.

Redeem scripts of any other form, including multisig, MUST NOT be used as
preimage anchors.

### Registered anchors (anchorType = 0x52)

The validator MUST check that:

1. the referenced transaction is a type T registration mined below
   $\mathsf{RecoverySwitchHeight}$;
2. its payload equals $\mathsf{H}_{\texttt{"ZcashRecov\_RegTr"}}(\mathsf{dest} \,||\, \mathsf{salt})$;
3. for each claimed outpoint, the referenced registration is the registration
   of that outpoint's address.

### Opening a commitment

For HD and PREIMAGE claims, the validator MUST check that:

1. the referenced position holds a commitment item (or, for a rooted item, a
   root that the given Merkle path connects to the leaf), whose value equals
   $\mathsf{C}$ recomputed from $\mathsf{anchorType}$,
   $\mathsf{anchorMaterial}$, $\mathsf{dest}$, $\mathsf{salt}$ and
   $\mathsf{terms}$;
2. the commitment's height is at most $h - \mathsf{RecoveryCommitDepth}$.

### One anchor, one destination

Validators keep a map $\mathsf{AnchorDestination}$ from key tags to
$(\mathsf{position}, \mathsf{dest}, \mathsf{terms})$. For an HD or PREIMAGE
claim with key tag $t$ and commitment position $p$:

1. If $\mathsf{AnchorDestination}[t] = (p', d', \tau')$ with $p' < p$, the
   claim MUST use $\mathsf{dest} = d'$ and $\mathsf{terms} = \tau'$.
2. Otherwise, after the claim is applied,
   $\mathsf{AnchorDestination}[t] = (p, \mathsf{dest}, \mathsf{terms})$.

### Resolution between claims on the same output

Anchor strength is ordered HD > REGISTERED > PREIMAGE. The position of a claim
is the position of its commitment, or of its registration.

Validators keep, for each claimed outpoint, its current claim: the anchor
strength, the position, and the claim's landing outputs.

1. If an outpoint has no current claim, the claim becomes its current claim.
2. If an outpoint's current claim has matured (see below), the new claim MUST
   be rejected.
3. Otherwise the new claim MUST be rejected unless its anchor is stronger, or
   of equal strength with a lower position. If it is accepted, the current
   claim's landing outputs for that outpoint are voided and can never be
   spent, and the new claim becomes the current claim.

A claim's landing outputs mature, and can be spent, from height
$h + \mathsf{RecoveryCommitDepth}$ for an HD claim, and from height
$h + \mathsf{RecoveryDisputeWindow}$ for a PREIMAGE or REGISTERED claim, where
$h$ is the claim's height.

Landing outputs are created per claimed outpoint, so that voiding one
outpoint's claim does not affect the others. The fee and payment are taken
from the first outpoint's landing.

### Turnstile

The sum of the values of all current claims MUST NOT exceed the transparent
chain value pool balance at $\mathsf{RecoverySwitchHeight}$. Claimed value that
lands on a P2PQ output leaves the transparent chain value pool and enters the
P2PQ value pool; claimed value that lands on a Bonsai output stays in the
transparent chain value pool. A
voided landing returns its value to the claimable total.

### Limits

A block MUST NOT contain claims for more than
$\mathsf{MaxClaimedOutputsPerBlock}$ outpoints, or more than
$\mathsf{MaxClaimBytesPerBlock}$ bytes of claim bundles.

## Changes at the recovery switch

From $\mathsf{RecoverySwitchHeight}$:

1. A transparent input MUST NOT be spent by a script whose evaluation executes
   OP_CHECKSIG, OP_CHECKSIGVERIFY, OP_CHECKMULTISIG or OP_CHECKMULTISIGVERIFY,
   including inside a P2SH redeem script. Inputs authorized only by a
   post-quantum signature check that the consensus rules define at that
   height remain valid.
2. Transparent outputs with nonzero value MUST NOT be created, other than
   P2PQ outputs and outputs of a post-quantum transparent output type that
   the consensus rules define at that height.
3. Coinbase outputs MUST be P2PQ outputs or outputs of such a post-quantum
   type.

The disabling of the Sapling, Orchard and *Ironwood* protocols at the same
height, and recovery of shielded notes, are specified separately.

## Activation of the recovery switch

This ZIP is deployed with $\mathsf{RecoverySwitchHeight}$ unset. It is set by:

1. a later network upgrade that assigns it; or
2. a canary.

A canary bundle contains a curve identifier (1 byte), a 32-byte scalar $x$ and
a 32-byte landing destination. It is valid if $[x]\,\mathsf{G} = \mathsf{P_{canary}}$,
where $\mathsf{G}$ is the curve's standard generator and
$\mathsf{P_{canary}}$ is obtained by hashing the ASCII string
`Zcash quantum canary v1` to the curve. When a block contains a valid canary
and $\mathsf{RecoverySwitchHeight}$ is unset,
$\mathsf{RecoverySwitchHeight}$ becomes that block's height plus one.

The curve identifiers, the hash to curve suites, and an optional canary bounty
pool paid to the canary's destination are specified in a companion ZIP.


# Security analysis

This section states what each rule protects and under which assumption. The
hash functions are modelled as random oracles that a quantum adversary may
query in superposition. Every bound below is a generic search bound.

## Assumptions

1. A1. BLAKE2b-256, SHA-256, RIPEMD-160 and HMAC-SHA512 behave as random
   oracles. Grover search for a preimage of an $n$-bit output costs about
   $2^{n/2}$ quantum queries.
2. A2. SLH-DSA-SHA2-128s, and ZPQ-SHA2-160 where claims land on it, are
   existentially unforgeable against quantum adversaries.
3. A3. Proof of work consensus holds: an adversary cannot rewrite more than
   600 blocks.
4. A4. The switch is set before the adversary has spent the outputs it wants.

## Security claims

1. **HD theft.** Under A1 and A3, an adversary that does not know the node
   m/44'/133' of a wallet cannot make an HD claim for that wallet's outputs,
   except with negligible probability. The adversary may know every public
   key, every extended public key at or below account level, and every
   discrete logarithm. To succeed it must produce a node
   $(\mathsf{k}', \mathsf{c}')$ and a path whose CKDpriv chain ends at a key
   whose Hash160 matches. Each hardened step computes
   $\mathsf{k}_{child} = \mathsf{k} + I_L(\mathsf{c}, 0 \,||\, \mathsf{k} \,||\, i)$,
   so the input feeds the oracle that masks it, and each non-hardened step
   does the same with $[\mathsf{k}]\mathsf{G}$ in place of $\mathsf{k}$.
   Neither step can be inverted, and solving for a fixed point costs a
   generic search over 256 bits. Matching an account node learnt from a leaked
   extended public key needs a 512-bit HMAC-SHA512 output to hit both the key
   and the chain code. The remaining route is a Hash160 second preimage, at
   about $2^{80}$ quantum queries per target, which transparent addresses
   already rely on.
2. **Preimage theft.** Under A1, a PREIMAGE claim for an output succeeds for
   an adversary only if it knows $\mathsf{s}$ or finds a Hash160 preimage. The
   rule excluding revealed scripts removes every $\mathsf{s}$ visible on
   chain. Knowledge of $\mathsf{s}$ from outside the chain (watch-only
   exports, signed messages, extended public keys) is not prevented; the
   dispute window lets an HD or REGISTERED anchor for the same output
   supersede such a claim.
3. **Registration theft.** A registration is accepted only if its inputs pass
   script validation when mined. So before the adversary can compute discrete
   logarithms, only the holder can register an address. The earliest
   registration wins, so a holder who registered before the adversary existed
   cannot be displaced. HD anchors supersede registrations, because a
   discrete-logarithm-breaking adversary can forge registrations for revealed
   addresses that were never registered, but cannot forge HD anchors.
4. **Front running.** Under A1 and A3, an adversary that learns an anchor from
   a claim in the mempool cannot redirect the funds. Any commitment it makes
   is at least $\mathsf{RecoveryCommitDepth}$ blocks younger than the claim's
   commitment, which is already buried below the rollback limit. One anchor,
   one destination binds every later claim under the anchor, including for
   outputs the first claim did not list, to the first claim's destination and
   terms. Binding rests on the collision resistance of BLAKE2b-256 (about
   $2^{85}$ quantum queries with BHT); hiding rests on the 256-bit salt.
5. **Malleation.** A claim carries no signature. Every field that decides
   where value goes ($\mathsf{dest}$, $\mathsf{payDest}$, $\mathsf{payAmount}$)
   is fixed by the commitment, or by the registration. The fee is fixed by
   consensus. A relayer can drop outpoints from a claim, which only delays
   them: they remain claimable to the same destination. It can add outpoints
   under the same anchor, which pays them to the same destination.
6. **Inflation and double recovery.** Each outpoint has at most one current
   claim. Voided landings can never be spent. The turnstile bounds the total.
   Transparent outputs carry public values, so no claim can open an output to
   a larger value.
7. **Grinding commitments.** A commitment that no one can open costs its
   poster a fee or a stamp and has no effect.

## What remains open

1. Outputs of non-HD wallets whose keys are revealed, if never registered.
2. PREIMAGE claims for keys that leaked off chain, against holders who have
   neither an HD anchor nor a registration. The holder and the adversary race,
   and the earlier commitment wins.
3. Everything the adversary did before the switch.


# Rationale

## Why commit, delay, reveal

Commit, delay, reveal is an established way to authorize with hash functions
alone (Bonneau and Miller, Fawkescoin, 2014). [^Fawkescoin] It lets these rules
be written, implemented and deployed without waiting for a post-quantum proof
system. The delay is a global constant: a delay chosen per claim would let an
adversary that can briefly reorganize the chain choose a short one.

## Why the fee is fixed by consensus

An open claim reveals its anchor, so anyone can rebuild a valid claim from it.
If the fee were a field of the claim, a miner could raise it and keep most of
the value. A fee fixed by consensus, together with payment terms fixed in the
commitment, leaves nothing for a relayer or miner to change. Aggregators who
post commitments for holders without post-quantum funds are paid through
$\mathsf{terms}$.

## Why m/44'/133'

Account-level extended public keys are commonly exported for watch-only use,
and every unified full viewing key with a transparent P2PKH component contains
one. [^zip-0316] With discrete logarithms, an adversary holding one can derive
the account's private keys. The coin type node is one hardened step above
every account, so no public data derived below it reveals it. It is specific
to Zcash, so revealing it exposes no keys for other coin types derived from the
same seed. The seed is never revealed: it would expose shielded keys and keys
for other chains. Every HD scheme in current Zcash wallets derives transparent
keys under m/44'/133', including zcashd from 4.7.0 at
m/44'/133'/0x7FFFFFFF'/{0,1}/index for its legacy account, and the ZIP 320
ephemeral scope 2 used by librustzcash.

## Why preimage anchors exclude revealed scripts and multisig

A key or script that is already public gives no evidence of ownership. The
same holds for anything computable from public data: the other encoding of a
revealed key, and a wrapped P2PKH script, which equals a P2PKH output script. Every
cosigner of a multisig knows the full redeem script, so revealing it would let
one cosigner take the funds. Multisig holders register instead, authenticated
by the multisig itself while that was still secure.

## Why HD outranks registration

See item 3 of [Security claims](#security-claims).

## The revealed script set

Only outputs unspent at the switch can be claimed, so validators need to know
"revealed or not" only for the addresses that hold such outputs. On
2026-10-24 that was about 856,000 transparent addresses, against about 164
million transparent outputs ever spent. Validators MAY compute the set once,
at $\mathsf{RecoverySwitchHeight}$, by one pass over the chain: for each
address with an unspent output, whether its public key or redeem script ever
appeared in an input or output script. Stored as 20-byte hashes, the set is
about 17 MB.

## Why transparent claims need no settlement

A transparent output's value is public and was real when it was created, so
transparent claims can never add up to more than the transparent chain value
pool. Shielded pools can hold counterfeit value made before the switch, and
claims on them settle under a separate rule (a first claim window, then
senior and junior tiers by note age, pro rata within each).

## Why Bonsai first, and P2PQ as the fallback

Recovered value should land where the network's other post-quantum value
lives, so a claim lands on Bonsai whenever a Bonsai output type is enabled.
[^bonsai] P2PQ is the smallest landing that lets this ZIP stand alone if
Bonsai does not ship; FIPS 205 is a fixed standard, which also suits
registrations that fix a destination years ahead.

The descriptor names Bonsai's profile by its key label and parameter hash, the
two values Bonsai itself changes when its construction or parameters change,
so a destination can never be read under a profile it was not made for.

The changes at the recovery switch leave Bonsai outputs and their spends valid.
A script that requires both an ECDSA and a post-quantum signature cannot be
spent after the switch; one that accepts either is spent through its
post-quantum branch.

## Per outpoint landings

A competing claim may supersede one outpoint of a claim and not another.
Separate landings per outpoint let validators void exactly what was
superseded.

## The private form

zips#1302 scopes a zero-knowledge proof of knowledge of the ECDSA private key
behind a P2PKH or P2SH-wrapped key. The same proof can replace a PREIMAGE
reveal. An analogous proof of knowledge of a seed and BIP 32 path can replace
an HD reveal, and it hides the seed and the coin type node. Either needs no
commitment or delay, because nothing is revealed that could be front run. To
keep one anchor, one destination working across both forms, the proof's public
output includes the anchor's key tag. Once an anchor has been revealed in the
open, anyone can prove knowledge of it, so a private claim under a revealed
anchor must use that anchor's destination. The private form needs a
post-quantum knowledge-sound proof system and is left to a later ZIP. The
`recovery-private` crate in this repository prototypes both statements as
hash based succinct STARK receipts, with the destination and key tag in the
public output; its measurements are in `docs/RESULTS.md`. A hash based
receipt is about 224 KB, so private claims would be aggregated many to a
receipt by recursion. The private form MUST NOT rely on a pairing based or
other discrete logarithm based proof, including for aggregation or
compression: an adversary that can compute discrete logarithms could forge
it.

## Grover

Preimages of Hash160 cost about $2^{80}$ quantum queries per target address.
Transparent addresses already rely on that, and this ZIP does not lower it.


# Deployment

1. The registration format can be used from the publication of this ZIP.
   Wallets and custodians SHOULD register addresses whose keys have been
   revealed, or move their funds to the *Ironwood pool*.
2. The rest of this ZIP is proposed for deployment, dormant, in a network
   upgrade that adopts the extensible transaction format. [^zip-0248]
   Commitments and canaries are active from that upgrade. Claims and the
   changes at the switch apply from $\mathsf{RecoverySwitchHeight}$.
3. Nodes SHOULD run a regtest drill of the switch in their test suites, so
   that rules which are dormant on Mainnet are exercised continuously.


# Reference implementation

The `zcash-recovery` and `recovery-lab` crates in this repository implement
these rules on a local test chain, with an adversary that is given every
discrete logarithm, and publish test vectors in `vectors/recovery-vectors.json`.
The `recovery-private` crate prototypes the private form.


# Open issues

1. Final values of the constants. $\mathsf{StampTarget}$ and the claim fee
   are proposed from reference measurements on one laptop core and should be
   set against the slowest hardware wallets are expected to support.
2. Whether PREIMAGE anchors should be enabled, given the risk of public keys
   leaking off chain.
3. The ZIP 248 bundle registrations, value balance entries and signature
   digest contributions for the P2PQ, commitment, claim and canary bundles.
4. Lockbox and funding stream recipients.
5. Whether a finite claim period should end recovery, with unclaimed value
   sent to the Network Sustainability Mechanism.
6. Stamps can be computed in advance, so one fast machine could fill the
   stamped commitment cap of every block for a while. Binding the stamp to a
   recent block hash would stop stockpiling; the cap still bounds the damage,
   and aggregators (who pay fees) remain the main path for holders without
   funds.
7. The companion ZIPs this one relies on: canary curve identifiers, suites and
   the bounty pool; the Ironwood anchor (type 0x01); and recovery of shielded
   notes, including settlement against counterfeit value.


# References

[^BCP14]: [Information on BCP 14 — "RFC 2119: Key words for use in RFCs to Indicate Requirement Levels" and "RFC 8174: Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words"](https://www.rfc-editor.org/info/bcp14)

[^protocol]: [Zcash Protocol Specification, Version 2026.8.0 [NU6.3] or later](https://zips.z.cash/protocol/protocol.pdf)

[^protocol-networks]: [Zcash Protocol Specification, Version 2026.8.0 [NU6.3]. Section 3.12: Mainnet and Testnet](https://zips.z.cash/protocol/protocol.pdf#networks)

[^zip-0200]: [ZIP 200: Network Upgrade Mechanism](https://zips.z.cash/zip-0200)

[^zip-0218]: [ZIP 218: 25-second Block Target Spacing](https://zips.z.cash/zip-0218)

[^zip-0248]: [ZIP 248: Extensible Transaction Format](https://zips.z.cash/zip-0248)

[^zip-2005]: [ZIP 2005: Ironwood Quantum Recoverability](https://zips.z.cash/zip-2005)

[^zip-0316]: [ZIP 316: Unified Addresses and Unified Viewing Keys](https://zips.z.cash/zip-0316)

[^Fawkescoin]: [J. Bonneau and A. Miller, Fawkescoin: a cryptocurrency without public-key cryptography, Security Protocols Workshop 2014](https://jbonneau.com/doc/BM14-SPW-fawkescoin.pdf)

[^bonsai]: [Bonsai (ZPQ-SHA2-160), an experimental post-quantum signature scheme for Zcash transparent outputs](https://github.com/valargroup/bonsai)

[^FIPS205]: [FIPS 205: Stateless Hash-Based Digital Signature Standard](https://csrc.nist.gov/pubs/fips/205/final)

[^BIP32]: [BIP 32: Hierarchical Deterministic Wallets](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)

[^BIP44]: [BIP 44: Multi-Account Hierarchy for Deterministic Wallets](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)
