Hello Zcash Community!
For most of Zcash’s life, zcashd was the reference implementation, and most of this year’s consensus bugs in Zebra were found by disagreeing with it.
This year alone Zebra had seven Critical consensus splits in a handful of consensus libraries.
In April it was accepting signatures zcashd rejected, which could split the chain, and two weeks later the fix itself split the chain a different way. In May a different signature rule broke, and two days after its fix some cases were still getting through. By the end of May it was sigop counting, and three days later came an advisory titled “Not Correctly Fixed”.
The tests in the code didn’t catch any of them, because it’s very difficult to test transactions you never intended to build.
So let’s prove the code against the spec instead!
We’ll write the consensus rules these libraries implement in Lean 4, from the protocol spec and the ZIPs, and from zcashd where the spec says nothing, so the transparent script rules get written down for the first time.
Each function in Zebra’s and Zakura’s versions of these libraries is transcribed into Lean, checked against the official test vectors, and proven to follow those rules for every input, accepting only valid blocks and rejecting invalid ones.
That’s where the proofs earn their keep. If a fix only covers part of a rule, the proof fails and we know before it ships. If one library quietly relies on a check another library never makes, which is how most of this year’s signature bugs happened, it shows up as an assumption the proof can’t get rid of. If the code and the spec disagree, or the spec leaves a choice open, the maintainers or the ZIP editors decide which one is wrong.
As Zebra and Zakura are proven against the same spec, they agree wherever they run the proven code, and the next upgrade becomes one set of rules to change instead of two codebases to compare.
The core developers’ own verification work is focused elsewhere: Ironwood’s formal verification covers the cryptography, and ZFND’s zebrafm lists Equihash, the digests, the script interpreter and the trees under “Uncovered areas”.
The libraries
equihash0.3.0 andzakura-equihash5.3.0: proof of workzcash_primitives0.31.0 andzakura-primitives5.3.0: transactions, txid, auth digest and signature hashzcash_encoding0.5.0 andzakura-protocol5.3.0’s encoding: byte encodingszcash_protocol0.11.0 andzakura-protocol5.3.0: network upgrades, branch IDs and amountszcash_transparent0.11.0 andzakura-transparent5.3.0: transparent inputs and outputszcash_script0.6.0 andzakura-zcash-script0.0.1: the Rust script interpreter, which Zakura runs to check scripts and Zebra uses for parsing and sigop countszebra-script14.0.0 andzakura-script5.0.5: the digests handed to the interpreterzcash_history0.6.0 andzakura-mmr-tree0.1.0: the history tree (ZIP 221)zcash_note_encryption0.5.1 andzakura-note-encryption5.3.0: shielded coinbase decryptionincrementalmerkletree0.9.0: the note commitment trees
Milestones
- Milestone 1: transactions, the txid, auth digest and signature hash
- Milestone 2: transparent scripts and sigop counting
- Milestone 3: Equihash, the history tree, the note commitment trees and shielded coinbase
Supporting links
- Full application: #564
- Zebra’s security advisories: ZcashFoundation/zebra
- Equihash spec fixes in protocol spec 2026.8.0: zips#1444 (Forum Post)