mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-09-11 05:45:30 +03:00
add ToBitsGadget to GroupType
This commit is contained in:
parent
887e374e28
commit
e5ee1cfe4d
@ -12,6 +12,7 @@ use snarkos_models::gadgets::utilities::alloc::AllocGadget;
|
||||
use snarkos_models::gadgets::utilities::boolean::Boolean;
|
||||
use snarkos_models::gadgets::utilities::eq::{ConditionalEqGadget, EqGadget};
|
||||
use snarkos_models::gadgets::utilities::select::CondSelectGadget;
|
||||
use snarkos_models::gadgets::utilities::ToBitsGadget;
|
||||
use std::borrow::Borrow;
|
||||
use std::ops::Sub;
|
||||
use std::str::FromStr;
|
||||
@ -264,3 +265,15 @@ impl CondSelectGadget<Fq> for EdwardsGroupType {
|
||||
2 * <EdwardsBlsGadget as CondSelectGadget<Fq>>::cost()
|
||||
}
|
||||
}
|
||||
|
||||
impl ToBitsGadget<Fq> for EdwardsGroupType {
|
||||
fn to_bits<CS: ConstraintSystem<Fq>>(&self, mut cs: CS) -> Result<Vec<Boolean>, SynthesisError> {
|
||||
let self_gadget = self.allocated(&mut cs)?;
|
||||
self_gadget.to_bits(cs)
|
||||
}
|
||||
|
||||
fn to_bits_strict<CS: ConstraintSystem<Fq>>(&self, mut cs: CS) -> Result<Vec<Boolean>, SynthesisError> {
|
||||
let self_gadget = self.allocated(&mut cs)?;
|
||||
self_gadget.to_bits_strict(cs)
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ use snarkos_models::gadgets::utilities::alloc::AllocGadget;
|
||||
use snarkos_models::gadgets::utilities::eq::{ConditionalEqGadget, EqGadget};
|
||||
use snarkos_models::gadgets::utilities::select::CondSelectGadget;
|
||||
use std::fmt::Debug;
|
||||
use snarkos_models::gadgets::utilities::ToBitsGadget;
|
||||
|
||||
pub mod edwards_bls12;
|
||||
|
||||
@ -16,6 +17,7 @@ pub trait GroupType<F: Field>:
|
||||
+ ConditionalEqGadget<F>
|
||||
+ AllocGadget<String, F>
|
||||
+ CondSelectGadget<F>
|
||||
+ ToBitsGadget<F>
|
||||
{
|
||||
fn constant(string: String) -> Result<Self, GroupError>;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user