mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-23 12:13:48 +01:00
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:
@@ -235,6 +235,16 @@ impl PartialEq for AllocatedBit {
|
||||
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 From<AllocatedBit> for Boolean {
|
||||
}
|
||||
|
||||
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 UInt64 {
|
||||
}
|
||||
|
||||
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> ConditionalEqGadget<ConstraintF> for UInt8 {
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user