INNER CODE UNIT · Rust
new_variable
arkworks-rs/groth16 · src/constraints.rs:321
fn new_variable<T: Borrow<PreparedVerifyingKey<E>>>(
cs: impl Into<Namespace<BasePrimeField<E>>>,
f: impl FnOnce() -> Result<T, SynthesisError>,
mode: AllocationMode,
) -> Result<Self, SynthesisError> {
let ns = cs.into();
let cs = ns.cs();
f().and_then(|pvk| {
let pvk = pvk.borrow();
let alpha_g1_beta_g2 = P::GTVar::new_variable(
ark_relations::ns!(cs, "alpha_g1_beta_g2"),
|| Ok(pvk.alpha_g1_beta_g2.clone()),
mode,
)?;
let gamma_g2_neg_pc = P::G2PreparedVar::new_variable(
ark_relations::ns!(cs, "gamma_g2_neg_pc"),