You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using many gadgets requires repeating type parameters: once for the native version, and once for the constraint version. However, this seems redundant as usually there's only a single gadget for a particular primitive. So, it makes sense to tie the gadget to the native impl. We can do this via an extension trait, as follows:
pubtraitCRHGadget<ConstraintF:Field>:CRH{typeParametersVar:AllocGadget<Self::Parameters>;typeInputVar:AllocGadget<Self::Input>;typeOutputVar:AllocGadget<Self::Output>;fnevaluate(params:&Self::ParametersVar,input:&[UInt8]) -> R1CSResult<Self::OutputVar>;}implCRHGadgetforPedersenCRH{ ... }// Note: this is implemented for *PedersenCRH*, not PedersenCRHGadget.
We've reduced the number of type parameters greatly. This works for Gadget traits which don't contain variables themselves. What about Var traits, which contain variables? We can still use them, as follows:
traitFieldExt{typeVar:FieldVar<...>;//figure out what to put in the type parameters.}implFieldExtforFpN{
...
}
This would allow us to access the "unique" variable type for a given field element, without introducing multiple type parameters.
Feedback on this idea is very welcome!
The text was updated successfully, but these errors were encountered:
should input be &Self::InputVar instead of &[UInt8]? (or rather, Borrow<Self::InputVar>)
Yeah this API looks good (if possible). One minor issue is that we have to bound input var is an AllocVar of Self::Input, which might not always be the case (in fact, InputVar do not even need to be Sized right?). It makes sense to bound OutputVar, but do we really need to bound InputVar?
Using many gadgets requires repeating type parameters: once for the native version, and once for the constraint version. However, this seems redundant as usually there's only a single gadget for a particular primitive. So, it makes sense to tie the gadget to the native impl. We can do this via an extension trait, as follows:
We can invoke this as
We've reduced the number of type parameters greatly. This works for
Gadget
traits which don't contain variables themselves. What aboutVar
traits, which contain variables? We can still use them, as follows:This would allow us to access the "unique" variable type for a given field element, without introducing multiple type parameters.
Feedback on this idea is very welcome!
The text was updated successfully, but these errors were encountered: