arkworks-rs / crypto-primitives

Interfaces and implementations of cryptographic primitives, along with R1CS constraints for them
https://www.arkworks.rs
Apache License 2.0
165 stars 79 forks source link

Added size check to Bowe-Hopwood gadget `evaluate` method #120

Closed rozbb closed 8 months ago

rozbb commented 11 months ago

Description

Previously, the Bowe-Hopwood CRH gadget would silently fail to hash inputs whose bitlength exceeded NUM_WINDOWS * WINDOW_SIZE * 3. This makes it easy to miss simple things in development, but it's probably not a security issue, since any gadget eval is almost certainly accompanied by a native eval, which does have the size check. Instead, it should say that the input is too large, as the Pedersen CRH gadget does.

This PR adds the check, and also a regression test.


Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why.