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