INNER CODE UNIT · Rust
new_variable
arkworks-rs/groth16 · src/constraints.rs:414
fn new_variable<T: Borrow<Proof<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(|proof| {
let Proof { a, b, c } = proof.borrow().clone();
let a = P::G1Var::new_variable(ark_relations::ns!(cs, "a"), || Ok(a), mode)?;
let b = P::G2Var::new_variable(ark_relations::ns!(cs, "b"), || Ok(b), mode)?;
let c = P::G1Var::new_variable(ark_relations::ns!(cs, "c"), || Ok(c), mode)?;
Ok(Self { a, b, c })
})
}
}