# Bonsai Bonsai tree Bonsai is an experimental post-quantum signature scheme for Zcash transparent outputs. Its technical identifier is `ZPQ-SHA2-160`. [Explore the construction and parameter choices](https://bonsai.valargroup.dev/#why). A public key is **40 bytes** and a signature is **7,812 bytes**. A hardware wallet prepares 512 one-time keys. A custody signer prepares 65,536 to support a longer signing lifetime. Both produce signatures for the same verifier. **Status: research.** There is no security proof for this parameter set and no outside review. The only keys in this repository are public test keys. Do not protect anything of value with it. ## Use Verify a signature from the repository root with Rust 1.87 or later: ```sh cargo run --quiet --locked --bin verify -- vectors/pk.bin vectors/130.msg vectors/130.sig ``` Expected output: `Signature verified.` As a library, `zpq_sha2_160::verify(public_key, message, signature) -> bool` takes byte slices and needs no allocator or standard library. `zpq_sha2_160::SigningKey` is the reference signer: ```rust use zpq_sha2_160::{KeyMode, SigningKey}; let (sk_seed, sk_prf, pk_seed) = ([1; 20], [2; 20], [3; 20]); // Public example only. let key = SigningKey::from_seeds(KeyMode::Regular, sk_seed, sk_prf, pk_seed); let signature = key.sign(b"message"); assert!(zpq_sha2_160::verify(&key.public_key(), b"message", &signature)); ``` ## Parameters | | | | --- | --- | | Hash width | 160 bits, SHA-256 and SHA-512 truncated | | FORS | 18 trees of height 10, zero grinding bits | | Hypertree | 3 layers of heights 16, 8, 8 from the top | | One-time signatures | 53 chains of 7 steps, leading digest bit zero, digit sum 232, no checksum chains | | Message hash | Two-stage SHA-512 over a keyed randomizer, the public key and the message itself | | Modeled FORS lifetime at 160 classical bits | About 2^21.48 signatures for a regular key and 2^28.78 for a custody key | On a physical Nano S Plus, regular setup took 20.33 s and signing took 23.96 s at p90 (30 signatures). On four x86-64 vCPUs without SHA-NI, custody setup took 3.13 s at the median and signing took 142.66 ms at p90 (90 signatures). Both runs used commit 9458f21, before the current key derivation and message hash, and have not been repeated since. The message hash now costs slightly more per randomizer candidate, and signatures are 48 bytes shorter. [Measurements and raw samples](docs/measurements.md) ## Tests ```sh cargo test --locked (cd host && python3 -m unittest test_vectors test_transport test_fors_keys) ``` The Rust tests check that the files under `vectors/` are exactly what the reference signer produces, that a second verifier written in Python agrees on every labelled case, and that changing any single byte of a signature, key or message is rejected. ## Documents - [Specification](docs/spec.md): parameters, key generation, signing, verification, signature layout, and every difference from FIPS 205. - [Security notes](docs/security.md): what is claimed, the signature budget, what is not proven, and what a signing device must still defend against. - [Ledger research signer](docs/ledger.md): build the firmware and reproduce a vector in the emulator. - [Measurements](docs/measurements.md): what was timed on a device, and on which version of the scheme. - [Sources and licences](docs/credits.md). - [Parameter study](https://bonsai.valargroup.dev/): why these parameters.