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
This commit is contained in:
Kobi Gurkan
2020-04-19 02:03:33 +03:00
committed by GitHub
parent c486e15f0e
commit 5cc094be6b
22 changed files with 474 additions and 19 deletions

View File

@@ -96,6 +96,21 @@ where
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 @@ where
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>,