mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-09-11 05:45:30 +03:00
add ToBytesGadget to GroupType
This commit is contained in:
parent
e5ee1cfe4d
commit
8ab5108558
@ -12,10 +12,11 @@ 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 snarkos_models::gadgets::utilities::{ToBitsGadget, ToBytesGadget};
|
||||
use std::borrow::Borrow;
|
||||
use std::ops::Sub;
|
||||
use std::str::FromStr;
|
||||
use snarkos_models::gadgets::utilities::uint8::UInt8;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum EdwardsGroupType {
|
||||
@ -276,4 +277,16 @@ impl ToBitsGadget<Fq> for EdwardsGroupType {
|
||||
let self_gadget = self.allocated(&mut cs)?;
|
||||
self_gadget.to_bits_strict(cs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToBytesGadget<Fq> for EdwardsGroupType {
|
||||
fn to_bytes<CS: ConstraintSystem<Fq>>(&self, mut cs: CS) -> Result<Vec<UInt8>, SynthesisError> {
|
||||
let self_gadget = self.allocated(&mut cs)?;
|
||||
self_gadget.to_bytes(cs)
|
||||
}
|
||||
|
||||
fn to_bytes_strict<CS: ConstraintSystem<Fq>>(&self, mut cs: CS) -> Result<Vec<UInt8>, SynthesisError> {
|
||||
let self_gadget = self.allocated(&mut cs)?;
|
||||
self_gadget.to_bytes_strict(cs)
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ use snarkos_models::gadgets::r1cs::ConstraintSystem;
|
||||
use snarkos_models::gadgets::utilities::alloc::AllocGadget;
|
||||
use snarkos_models::gadgets::utilities::eq::{ConditionalEqGadget, EqGadget};
|
||||
use snarkos_models::gadgets::utilities::select::CondSelectGadget;
|
||||
use snarkos_models::gadgets::utilities::{ToBitsGadget, ToBytesGadget};
|
||||
use std::fmt::Debug;
|
||||
use snarkos_models::gadgets::utilities::ToBitsGadget;
|
||||
|
||||
pub mod edwards_bls12;
|
||||
|
||||
@ -18,6 +18,7 @@ pub trait GroupType<F: Field>:
|
||||
+ AllocGadget<String, F>
|
||||
+ CondSelectGadget<F>
|
||||
+ ToBitsGadget<F>
|
||||
+ ToBytesGadget<F>
|
||||
{
|
||||
fn constant(string: String) -> Result<Self, GroupError>;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user