Closed weikengchen closed 3 years ago
This can also make the HashChain/Sponge easier to program since they can accept any types with a trait ToConstraintFieldGadget
, rather than requiring the developers to write additional lines of code to convert it first to constraint field gadgets.
We should have a new trait
ToConstraintFieldGadget
, which is the r1cs counterpart ofToConstraintField
. Both are shown below.Reason: for algebraic hash functions.
Currently, many gadgets implement
ToBytesGadget
, so that they could later be used for Pedersen hash functions (or even classical SHA-256).This is not suitable for algebraic hash functions like Poseidon, whose natural input is exactly of the field elements.
Thus, it would be great if we have a
ToConstraintFieldGadget
that is implemented in many applicable gadgets. I have had some local implementations. And I am wondering whether we should do so. If so, I can submit a PR after the Great Refactoring.