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.
This PR introduces a concept of malleable field elements - i.e., elements which might have redundant internal representation for the same canonical representation. For example, this is the case for field elements where internally elements are stored in the range
[0, 2M)
(rather than[0, M)
) which we use for ourf62
field (thef128
field does not have this issue because we don't use Montgomery arithmetic for it).This also allows us to hash elements consistently by first normalizing their internal representation, and only then hashing them. We do this for malleable elements only, since non-malleable elements don't need to be normalized, and thus, we can hash them directly.
We also make sure that we always write elements into the proof in canonical representation. This avoids issues when trying to deserialize elements where canonical and internal representations differ.
The above fixes should resolve the problems mentioned in #13 (comment).