zebra_consensus/primitives/groth16/
params.rsuse bellman::groth16;
use bls12_381::Bls12;
mod parse_parameters;
use parse_parameters::parse_sapling_parameters;
lazy_static::lazy_static! {
pub static ref GROTH16_PARAMETERS: Groth16Parameters = Groth16Parameters::new();
}
pub struct Groth16Parameters {
pub sapling: SaplingParameters,
pub sprout: SproutParameters,
}
pub struct SaplingParameters {
pub spend: groth16::Parameters<Bls12>,
pub spend_prepared_verifying_key: groth16::PreparedVerifyingKey<Bls12>,
pub output: groth16::Parameters<Bls12>,
pub output_prepared_verifying_key: groth16::PreparedVerifyingKey<Bls12>,
}
pub struct SproutParameters {
pub joinsplit_prepared_verifying_key: groth16::PreparedVerifyingKey<Bls12>,
}
impl Groth16Parameters {
fn new() -> Groth16Parameters {
tracing::info!("checking and loading Zcash Sapling and Sprout parameters");
let (sapling_spend_bytes, sapling_output_bytes) =
wagyu_zcash_parameters::load_sapling_parameters();
let sprout_vk_bytes = include_bytes!("sprout-groth16.vk");
let sapling = parse_sapling_parameters(
sapling_spend_bytes.as_slice(),
sapling_output_bytes.as_slice(),
);
let sprout_vk = groth16::VerifyingKey::<Bls12>::read(&sprout_vk_bytes[..])
.expect("should be able to parse Sprout verification key");
let sprout_vk = groth16::prepare_verifying_key(&sprout_vk);
let sprout = SproutParameters {
joinsplit_prepared_verifying_key: sprout_vk,
};
tracing::info!("Zcash Sapling and Sprout parameters loaded and verified");
Groth16Parameters { sapling, sprout }
}
pub fn failure_hint() -> String {
"Hint: re-run `zebrad` or re-install it from a trusted source".to_string()
}
}