mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-12 00:41:32 +01:00
Add ToConstraintField impls for some primitives
This commit is contained in:
@@ -24,8 +24,7 @@ use r1cs_std::{
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
pub trait InjectiveMapGadget<G: Group, I: InjectiveMap<G>, ConstraintF: Field, GG: GroupGadget<G, ConstraintF>>
|
||||
{
|
||||
pub trait InjectiveMapGadget<G: Group, I: InjectiveMap<G>, ConstraintF: Field, GG: GroupGadget<G, ConstraintF>> {
|
||||
type OutputGadget: EqGadget<ConstraintF>
|
||||
+ ToBytesGadget<ConstraintF>
|
||||
+ CondSelectGadget<ConstraintF>
|
||||
@@ -75,13 +74,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PedersenCRHCompressorGadget<
|
||||
pub struct PedersenCRHCompressorGadget<G, I, ConstraintF, GG, IG>
|
||||
where
|
||||
G: Group,
|
||||
I: InjectiveMap<G>,
|
||||
ConstraintF: Field,
|
||||
GG: GroupGadget<G, ConstraintF>,
|
||||
IG: InjectiveMapGadget<G, I, ConstraintF, GG>,
|
||||
> {
|
||||
{
|
||||
_compressor: PhantomData<I>,
|
||||
_compressor_gadget: PhantomData<IG>,
|
||||
_crh: PedersenCRHGadget<G, ConstraintF, GG>,
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use algebra::Field;
|
||||
|
||||
use crate::crh::{
|
||||
FixedLengthCRHGadget,
|
||||
pedersen::{PedersenCRH, PedersenParameters, PedersenWindow},
|
||||
};
|
||||
use algebra::groups::Group;
|
||||
use algebra::{Field, Group};
|
||||
use r1cs_core::{ConstraintSystem, SynthesisError};
|
||||
use r1cs_std::prelude::*;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use std::{
|
||||
};
|
||||
|
||||
use crate::crh::FixedLengthCRH;
|
||||
use algebra::{Field, ToConstraintField};
|
||||
use algebra::groups::Group;
|
||||
|
||||
|
||||
@@ -139,3 +140,11 @@ impl<G: Group> Debug for PedersenParameters<G> {
|
||||
write!(f, "}}\n")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<ConstraintF: Field, G: Group + ToConstraintField<ConstraintF>> ToConstraintField<ConstraintF> for PedersenParameters<G> {
|
||||
#[inline]
|
||||
fn to_field_elements(&self) -> Result<Vec<ConstraintF>, Error> {
|
||||
Ok(Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user