veridise audit fix: redc field is manipulable #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses Veredise Audit Issue: redc field is manipulable
The recommendation was to constrain that
redc = floor((1 << (2 * Params::modulus_bits())) / modulus)
. However, this would greatly negatively impact the efficiency of the circuit so we want to avoid this measure. Since the ultimate goal is to constrain the outputteddkim_key_hash
, we bind the redc to the modulus by hashing the two together. The verifier will still need to do this work themselves (only once) to get the expecteddkim_key_hash
, but it is far more efficient this way and ultimately addresses the core vulnerability.Since this adds a couple thousand constraints of work we also compose the limbs of the modulus and redcs from two 120 bit numbers into one 240 bit number to negate this increase. In order to do this we had to move pubkey hashing into the pubkey struct since there are different impls for even and odd (1024/2048 bit) limb lengths
Stack order: 2