|
1 | 1 | use core::{fmt::Debug, marker::PhantomData}; |
2 | 2 |
|
3 | 3 | use crate::crh::{ |
| 4 | + constraints, |
4 | 5 | injective_map::{InjectiveMap, PedersenCRHCompressor, TECompressor}, |
5 | 6 | pedersen::{constraints as ped_constraints, Window}, |
6 | | - CRHGadget, |
7 | 7 | }; |
8 | 8 |
|
9 | 9 | use ark_ec::{ |
|
72 | 72 | _crh: ped_constraints::CRHGadget<C, GG, W>, |
73 | 73 | } |
74 | 74 |
|
75 | | -impl<C, I, GG, IG, W> CRHGadget<PedersenCRHCompressor<C, I, W>, ConstraintF<C>> |
| 75 | +impl<C, I, GG, IG, W> constraints::CRHGadget<PedersenCRHCompressor<C, I, W>, ConstraintF<C>> |
76 | 76 | for PedersenCRHCompressorGadget<C, I, W, GG, IG> |
77 | 77 | where |
78 | 78 | C: ProjectiveCurve, |
|
94 | 94 | IG::evaluate(&result) |
95 | 95 | } |
96 | 96 | } |
| 97 | + |
| 98 | +impl<C, I, GG, IG, W> constraints::TwoToOneCRHGadget<PedersenCRHCompressor<C, I, W>, ConstraintF<C>> |
| 99 | + for PedersenCRHCompressorGadget<C, I, W, GG, IG> |
| 100 | +where |
| 101 | + C: ProjectiveCurve, |
| 102 | + I: InjectiveMap<C>, |
| 103 | + GG: CurveVar<C, ConstraintF<C>>, |
| 104 | + for<'a> &'a GG: GroupOpsBounds<'a, C, GG>, |
| 105 | + IG: InjectiveMapGadget<C, I, GG>, |
| 106 | + W: Window, |
| 107 | +{ |
| 108 | + type OutputVar = IG::OutputVar; |
| 109 | + type ParametersVar = ped_constraints::CRHParametersVar<C, GG>; |
| 110 | + |
| 111 | + #[tracing::instrument(target = "r1cs", skip(parameters))] |
| 112 | + fn evaluate( |
| 113 | + parameters: &Self::ParametersVar, |
| 114 | + left_input: &[UInt8<ConstraintF<C>>], |
| 115 | + right_input: &[UInt8<ConstraintF<C>>], |
| 116 | + ) -> Result<Self::OutputVar, SynthesisError> { |
| 117 | + // assume equality of left and right length |
| 118 | + assert_eq!(left_input.len(), right_input.len()); |
| 119 | + let result = |
| 120 | + ped_constraints::CRHGadget::<C, GG, W>::evaluate(parameters, left_input, right_input)?; |
| 121 | + IG::evaluate(&result) |
| 122 | + } |
| 123 | +} |
0 commit comments