zebra_consensus/primitives/groth16/params.rs
1//! Loading and checking correctness of Groth16 Sapling and Sprout parameters.
2
3use bellman::groth16::{prepare_verifying_key, PreparedVerifyingKey, VerifyingKey};
4use bls12_381::Bls12;
5use derive_getters::Getters;
6use zcash_proofs::prover::LocalTxProver;
7
8lazy_static::lazy_static! {
9 /// Sapling prover containing spend and output params for the Sapling circuit.
10 ///
11 /// Used to:
12 ///
13 /// - construct Sapling outputs in coinbase txs, and
14 /// - verify Sapling shielded data in the tx verifier.
15 pub static ref SAPLING: LocalTxProver = LocalTxProver::bundled();
16
17 /// Spend parameters for the Sprout circuit.
18 ///
19 /// Used to verify Sprout shielded data in transactions.
20 ///
21 /// Note that adding value to the Sprout pool was disabled by the Canopy network upgrade.
22 pub static ref SPROUT: SproutParams = Default::default();
23}
24
25/// Spend parameters for the Sprout circuit.
26///
27/// Used to verify Sprout shielded data in transactions.
28///
29/// Note that adding value to the Sprout pool was disabled by the Canopy network upgrade.
30#[derive(Getters)]
31pub struct SproutParams {
32 prepared_verifying_key: PreparedVerifyingKey<Bls12>,
33}
34
35impl Default for SproutParams {
36 fn default() -> Self {
37 let sprout_vk = VerifyingKey::<Bls12>::read(&include_bytes!("sprout-groth16.vk")[..])
38 .expect("should be able to read and parse Sprout verification key");
39
40 Self {
41 prepared_verifying_key: prepare_verifying_key(&sprout_vk),
42 }
43 }
44}