Adds alloc_constant to AllocGadget (#189) * adds alloc constant to AllocGadget * fmt * fmt * more alloc constant impls * fmt * even more impls * fixes type * fixes alloc_constant in gm17 * uses alloc_constant from field gadget in group gadgets * fmt * handle most comments
jump to
@@ -48,6 +48,16 @@ }
} impl<ConstraintF: Field> AllocGadget<(), ConstraintF> for Blake2sParametersGadget { + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + cs: CS, + val: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<()>, + { + Self::alloc(cs, || Ok(val)) + } + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>(_: CS, _: F) -> Result<Self, SynthesisError> where F: FnOnce() -> Result<T, SynthesisError>,@@ -69,6 +79,22 @@ }
} impl<ConstraintF: PrimeField> AllocGadget<[u8; 32], ConstraintF> for Blake2sRandomnessGadget { + #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + val: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<[u8; 32]>, + { + let mut bytes = vec![]; + for (i, b) in val.borrow().iter().enumerate() { + bytes.push(UInt8::alloc_constant(cs.ns(|| format!("value {}", i)), b)?) + } + + Ok(Blake2sRandomnessGadget(bytes)) + } + #[inline] fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( cs: CS,
@@ -98,16 +98,14 @@ G: Group,
W: PedersenWindow, ConstraintF: PrimeField, { - fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( _cs: CS, - value_gen: F, + val: T, ) -> Result<Self, SynthesisError> where - F: FnOnce() -> Result<T, SynthesisError>, T: Borrow<PedersenParameters<G>>, { - let temp = value_gen()?; - let parameters = temp.borrow().clone(); + let parameters = val.borrow().clone(); Ok(PedersenCommitmentGadgetParameters { params: parameters,@@ -117,6 +115,18 @@ _window: PhantomData,
}) } + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( + cs: CS, + value_gen: F, + ) -> Result<Self, SynthesisError> + where + F: FnOnce() -> Result<T, SynthesisError>, + T: Borrow<PedersenParameters<G>>, + { + let temp = value_gen()?; + Self::alloc_constant(cs, temp) + } + fn alloc_input<F, T, CS: ConstraintSystem<ConstraintF>>( _cs: CS, value_gen: F,@@ -142,6 +152,21 @@ where
G: Group, ConstraintF: PrimeField, { + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + val: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<PedersenRandomness<G>>, + { + let mut result_bytes = vec![]; + for (i, byte) in to_bytes![val.borrow().0].unwrap().into_iter().enumerate() { + let cur = UInt8::alloc_constant(cs.ns(|| format!("byte {}", i)), byte)?; + result_bytes.push(cur); + } + Ok(PedersenRandomnessGadget(result_bytes)) + } + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( cs: CS, value_gen: F,
@@ -89,21 +89,32 @@ impl<G: Group, W: PedersenWindow, ConstraintF: Field, GG: GroupGadget<G, ConstraintF>>
AllocGadget<BoweHopwoodPedersenParameters<G>, ConstraintF> for BoweHopwoodPedersenCRHGadgetParameters<G, W, ConstraintF, GG> { - fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( _cs: CS, - value_gen: F, + val: T, ) -> Result<Self, SynthesisError> where - F: FnOnce() -> Result<T, SynthesisError>, T: Borrow<BoweHopwoodPedersenParameters<G>>, { - let params = value_gen()?.borrow().clone(); + let params = val.borrow().clone(); Ok(BoweHopwoodPedersenCRHGadgetParameters { params, _group_g: PhantomData, _engine: PhantomData, _window: PhantomData, }) + } + + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( + cs: CS, + value_gen: F, + ) -> Result<Self, SynthesisError> + where + F: FnOnce() -> Result<T, SynthesisError>, + T: Borrow<BoweHopwoodPedersenParameters<G>>, + { + let params = value_gen()?.borrow().clone(); + Self::alloc_constant(cs, params) } fn alloc_input<F, T, CS: ConstraintSystem<ConstraintF>>(
@@ -80,21 +80,32 @@ impl<G: Group, W: PedersenWindow, ConstraintF: Field, GG: GroupGadget<G, ConstraintF>>
AllocGadget<PedersenParameters<G>, ConstraintF> for PedersenCRHGadgetParameters<G, W, ConstraintF, GG> { - fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( _cs: CS, - value_gen: F, + val: T, ) -> Result<Self, SynthesisError> where - F: FnOnce() -> Result<T, SynthesisError>, T: Borrow<PedersenParameters<G>>, { - let params = value_gen()?.borrow().clone(); + let params = val.borrow().clone(); Ok(PedersenCRHGadgetParameters { params, _group_g: PhantomData, _engine: PhantomData, _window: PhantomData, }) + } + + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( + cs: CS, + value_gen: F, + ) -> Result<Self, SynthesisError> + where + F: FnOnce() -> Result<T, SynthesisError>, + T: Borrow<PedersenParameters<G>>, + { + let params = value_gen()?.borrow().clone(); + Self::alloc_constant(cs, params) } fn alloc_input<F, T, CS: ConstraintSystem<ConstraintF>>(
@@ -128,6 +128,28 @@ P: MerkleTreeConfig,
HGadget: FixedLengthCRHGadget<P::H, ConstraintF>, ConstraintF: Field, { + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + val: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<MerkleTreePath<P>>, + { + let mut path = Vec::new(); + for (i, &(ref l, ref r)) in val.borrow().path.iter().enumerate() { + let l_hash = HGadget::OutputGadget::alloc_constant( + &mut cs.ns(|| format!("l_child_{}", i)), + l.clone(), + )?; + let r_hash = HGadget::OutputGadget::alloc_constant( + &mut cs.ns(|| format!("r_child_{}", i)), + r.clone(), + )?; + path.push((l_hash, r_hash)); + } + Ok(MerkleTreePathGadget { path }) + } + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: F,
@@ -203,6 +203,54 @@ ConstraintF: Field,
P: PairingGadget<PairingE, ConstraintF>, { #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + val: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<VerifyingKey<PairingE>>, + { + let VerifyingKey { + h_g2, + g_alpha_g1, + h_beta_g2, + g_gamma_g1, + h_gamma_g2, + query, + } = val.borrow().clone(); + let h_g2 = P::G2Gadget::alloc_constant(cs.ns(|| "h_g2"), h_g2.into_projective())?; + let g_alpha_g1 = + P::G1Gadget::alloc_constant(cs.ns(|| "g_alpha"), g_alpha_g1.into_projective())?; + let h_beta_g2 = + P::G2Gadget::alloc_constant(cs.ns(|| "h_beta"), h_beta_g2.into_projective())?; + let g_gamma_g1 = + P::G1Gadget::alloc_constant(cs.ns(|| "g_gamma_g1"), g_gamma_g1.into_projective())?; + let h_gamma_g2 = + P::G2Gadget::alloc_constant(cs.ns(|| "h_gamma_g2"), h_gamma_g2.into_projective())?; + + let query = query + .into_iter() + .enumerate() + .map(|(i, query_i)| { + P::G1Gadget::alloc_constant( + cs.ns(|| format!("query_{}", i)), + query_i.into_projective(), + ) + }) + .collect::<Vec<_>>() + .into_iter() + .collect::<Result<_, _>>()?; + Ok(Self { + h_g2, + g_alpha_g1, + h_beta_g2, + g_gamma_g1, + h_gamma_g2, + query, + }) + } + + #[inline] fn alloc<FN, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: FN,@@ -312,6 +360,21 @@ PairingE: PairingEngine,
ConstraintF: Field, P: PairingGadget<PairingE, ConstraintF>, { + #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + val: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<Proof<PairingE>>, + { + let Proof { a, b, c } = val.borrow().clone(); + let a = P::G1Gadget::alloc_constant(cs.ns(|| "a"), a.into_projective())?; + let b = P::G2Gadget::alloc_constant(cs.ns(|| "b"), b.into_projective())?; + let c = P::G1Gadget::alloc_constant(cs.ns(|| "c"), c.into_projective())?; + Ok(Self { a, b, c }) + } + #[inline] fn alloc<FN, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS,
@@ -174,6 +174,50 @@ ConstraintF: Field,
P: PairingGadget<PairingE, ConstraintF>, { #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + val: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<VerifyingKey<PairingE>>, + { + let VerifyingKey { + alpha_g1, + beta_g2, + gamma_g2, + delta_g2, + gamma_abc_g1, + } = val.borrow().clone(); + let alpha_g1 = + P::G1Gadget::alloc_constant(cs.ns(|| "alpha_g1"), alpha_g1.into_projective())?; + let beta_g2 = P::G2Gadget::alloc_constant(cs.ns(|| "beta_g2"), beta_g2.into_projective())?; + let gamma_g2 = + P::G2Gadget::alloc_constant(cs.ns(|| "gamma_g2"), gamma_g2.into_projective())?; + let delta_g2 = + P::G2Gadget::alloc_constant(cs.ns(|| "delta_g2"), delta_g2.into_projective())?; + + let gamma_abc_g1 = gamma_abc_g1 + .into_iter() + .enumerate() + .map(|(i, gamma_abc_i)| { + P::G1Gadget::alloc_constant( + cs.ns(|| format!("gamma_abc_{}", i)), + gamma_abc_i.into_projective(), + ) + }) + .collect::<Vec<_>>() + .into_iter() + .collect::<Result<_, _>>()?; + Ok(Self { + alpha_g1, + beta_g2, + gamma_g2, + delta_g2, + gamma_abc_g1, + }) + } + + #[inline] fn alloc<FN, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: FN,@@ -276,6 +320,21 @@ PairingE: PairingEngine,
ConstraintF: Field, P: PairingGadget<PairingE, ConstraintF>, { + #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + val: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<Proof<PairingE>>, + { + let Proof { a, b, c } = val.borrow().clone(); + let a = P::G1Gadget::alloc_constant(cs.ns(|| "a"), a.into_projective())?; + let b = P::G2Gadget::alloc_constant(cs.ns(|| "b"), b.into_projective())?; + let c = P::G1Gadget::alloc_constant(cs.ns(|| "c"), c.into_projective())?; + Ok(Self { a, b, c }) + } + #[inline] fn alloc<FN, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS,
@@ -451,6 +451,22 @@ }
impl<ConstraintF: PrimeField> AllocGadget<[u8; 32], ConstraintF> for Blake2sOutputGadget { #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + val: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<[u8; 32]>, + { + let mut bytes = vec![]; + for (i, b) in val.borrow().iter().enumerate() { + bytes.push(UInt8::alloc_constant(cs.ns(|| format!("value {}", i)), b)?) + } + + Ok(Blake2sOutputGadget(bytes)) + } + + #[inline] fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( cs: CS, value_gen: F,
@@ -96,6 +96,21 @@ ConstraintF: Field,
GG: GroupGadget<G, ConstraintF>, D: Digest, { + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + cs: CS, + val: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<SchnorrSigParameters<G, D>>, + { + let generator = GG::alloc_constant(cs, val.borrow().generator)?; + Ok(Self { + generator, + _engine: PhantomData, + _group: PhantomData, + }) + } + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>(cs: CS, f: F) -> Result<Self, SynthesisError> where F: FnOnce() -> Result<T, SynthesisError>,@@ -133,6 +148,21 @@ G: Group,
ConstraintF: Field, GG: GroupGadget<G, ConstraintF>, { + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + cs: CS, + val: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<SchnorrPublicKey<G>>, + { + let pub_key = GG::alloc_constant(cs, val.borrow())?; + Ok(Self { + pub_key, + _engine: PhantomData, + _group: PhantomData, + }) + } + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>(cs: CS, f: F) -> Result<Self, SynthesisError> where F: FnOnce() -> Result<T, SynthesisError>,
@@ -8,6 +8,13 @@ where
Self: Sized, V: ?Sized, { + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<V>; + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>(cs: CS, f: F) -> Result<Self, SynthesisError> where F: FnOnce() -> Result<T, SynthesisError>,@@ -47,6 +54,21 @@
impl<I, ConstraintF: Field, A: AllocGadget<I, ConstraintF>> AllocGadget<[I], ConstraintF> for Vec<A> { + #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<[I]>, + { + let mut vec = Vec::new(); + for (i, value) in t.borrow().iter().enumerate() { + vec.push(A::alloc_constant(cs.ns(|| format!("value_{}", i)), value)?); + } + Ok(vec) + } + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, f: F,
@@ -235,6 +235,16 @@
impl Eq for AllocatedBit {} impl<ConstraintF: Field> AllocGadget<bool, ConstraintF> for AllocatedBit { + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + _cs: CS, + _t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<bool>, + { + unimplemented!(); + } + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: F,@@ -715,6 +725,16 @@ }
} impl<ConstraintF: Field> AllocGadget<bool, ConstraintF> for Boolean { + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + _cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<bool>, + { + Ok(Boolean::constant(*t.borrow())) + } + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( cs: CS, value_gen: F,
@@ -277,6 +277,16 @@ }
} impl<ConstraintF: Field> AllocGadget<u64, ConstraintF> for UInt64 { + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + _cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<u64>, + { + Ok(UInt64::constant(*t.borrow())) + } + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: F,
@@ -214,6 +214,16 @@
impl<ConstraintF: Field> EqGadget<ConstraintF> for UInt8 {} impl<ConstraintF: Field> AllocGadget<u8, ConstraintF> for UInt8 { + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + _cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<u8>, + { + Ok(UInt8::constant(*t.borrow())) + } + fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: F,
@@ -585,6 +585,18 @@ }
impl<F: PrimeField> AllocGadget<F, F> for FpGadget<F> { #[inline] + fn alloc_constant<T, CS: ConstraintSystem<F>>(_cs: CS, t: T) -> Result<Self, SynthesisError> + where + T: Borrow<F>, + { + let value = t.borrow().clone(); + Ok(Self { + value: Some(value), + variable: LinearCombination::from((value, CS::one())).into(), + }) + } + + #[inline] fn alloc<FN, T, CS: ConstraintSystem<F>>( mut cs: CS, value_gen: FN,
@@ -835,6 +835,17 @@ P: Fp12Parameters,
<P::Fp6Params as Fp6Parameters>::Fp2Params: Fp2Parameters<Fp = ConstraintF>, { #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<Fp12<P>>, + { + Self::zero(cs.ns(|| "zero"))?.add_constant(cs.ns(|| "add constant"), t.borrow()) + } + + #[inline] fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: F,
@@ -612,6 +612,17 @@ impl<P: Fp2Parameters<Fp = ConstraintF>, ConstraintF: PrimeField> AllocGadget<Fp2<P>, ConstraintF>
for Fp2Gadget<P, ConstraintF> { #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<Fp2<P>>, + { + Self::zero(cs.ns(|| "zero"))?.add_constant(cs.ns(|| "add constant"), t.borrow()) + } + + #[inline] fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: F,
@@ -868,6 +868,17 @@ impl<P: Fp3Parameters<Fp = ConstraintF>, ConstraintF: PrimeField + SquareRootField>
AllocGadget<Fp3<P>, ConstraintF> for Fp3Gadget<P, ConstraintF> { #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<Fp3<P>>, + { + Self::zero(cs.ns(|| "zero"))?.add_constant(cs.ns(|| "add constant"), t.borrow()) + } + + #[inline] fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: F,
@@ -674,6 +674,17 @@ P: Fp4Parameters,
P::Fp2Params: Fp2Parameters<Fp = ConstraintF>, { #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<Fp4<P>>, + { + Self::zero(cs.ns(|| "zero"))?.add_constant(cs.ns(|| "add constant"), t.borrow()) + } + + #[inline] fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: F,
@@ -665,6 +665,17 @@ P: Fp6Parameters,
P::Fp3Params: Fp3Parameters<Fp = ConstraintF>, { #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<Fp6<P>>, + { + Self::zero(cs.ns(|| "zero"))?.add_constant(cs.ns(|| "add constant"), t.borrow()) + } + + #[inline] fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: F,
@@ -965,6 +965,17 @@ P: Fp6Parameters,
P::Fp2Params: Fp2Parameters<Fp = ConstraintF>, { #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<Fp6<P>>, + { + Self::zero(cs.ns(|| "zero"))?.add_constant(cs.ns(|| "add constant"), t.borrow()) + } + + #[inline] fn alloc<F, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: F,
@@ -438,6 +438,24 @@ ConstraintF: PrimeField,
F: FieldGadget<P::BaseField, ConstraintF>, { #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<SWProjective<P>>, + { + let p = t.borrow().into_affine(); + Ok(Self { + x: F::alloc_constant(cs.ns(|| "x"), &p.x)?, + y: F::alloc_constant(cs.ns(|| "y"), &p.y)?, + infinity: Boolean::constant(p.infinity), + _params: PhantomData, + _engine: PhantomData, + }) + } + + #[inline] fn alloc<FN, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: FN,
@@ -492,6 +492,23 @@ ConstraintF: Field,
F: FieldGadget<P::BaseField, ConstraintF>, Self: GroupGadget<TEAffine<P>, ConstraintF>, { + #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<TEAffine<P>>, + { + let p = t.borrow(); + Ok(Self { + x: F::alloc_constant(cs.ns(|| "x"), &p.x)?, + y: F::alloc_constant(cs.ns(|| "y"), &p.y)?, + _params: PhantomData, + _engine: PhantomData, + }) + } + fn alloc<FN, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: FN,@@ -1089,6 +1106,23 @@ ConstraintF: Field,
F: FieldGadget<P::BaseField, ConstraintF>, Self: GroupGadget<TEProjective<P>, ConstraintF>, { + #[inline] + fn alloc_constant<T, CS: ConstraintSystem<ConstraintF>>( + mut cs: CS, + t: T, + ) -> Result<Self, SynthesisError> + where + T: Borrow<TEProjective<P>>, + { + let p = t.borrow().into_affine(); + Ok(Self { + x: F::alloc_constant(cs.ns(|| "x"), &p.x)?, + y: F::alloc_constant(cs.ns(|| "y"), &p.y)?, + _params: PhantomData, + _engine: PhantomData, + }) + } + fn alloc<FN, T, CS: ConstraintSystem<ConstraintF>>( mut cs: CS, value_gen: FN,