Conversation
The current `group::Wnaf` implementation assumes `PrimeField::to_repr` returns a little endian encoding, so it doesn't work with our implementations of the NIST P-curves, which return a big endian SEC1 encoding. Following the general idea from RustCrypto/group#10, this adds an API which is guaranteed to return a little endian encoding which will always work with the current implementation of `group::Wnaf`. This is largely a stopgap solution which allows us to begin using `group::Wnaf` at all, though ideally we can find a more elegant upstream solution.
Member
Author
|
@str4d curious what you had in mind here. I was wondering if |
tarcieri
added a commit
to RustCrypto/group
that referenced
this pull request
Mar 31, 2026
The wNAF implementation assumes a little endian representation for scalars, but `PrimeField::to_repr` returns an opaque representation which may be big endian and is in the case of our implementations of the NIST P-curves. RustCrypto/ff#10 added a stopgap API: `PrimeField::to_le_repr`, which is guaranteed to return a little endian representation. This commit switches `(rustcrypto-)group` to use it, which should make it compatible with our curves which otherwise use a big endian SEC1 representation.
tarcieri
added a commit
to RustCrypto/group
that referenced
this pull request
Mar 31, 2026
The wNAF implementation assumes a little endian representation for scalars, but `PrimeField::to_repr` returns an opaque representation which may be big endian and is in the case of our implementations of the NIST P-curves. RustCrypto/ff#10 added a stopgap API: `PrimeField::to_le_repr`, which is guaranteed to return a little endian representation. This commit switches `(rustcrypto-)group` to use it, which should make it compatible with our curves which otherwise use a big endian SEC1 representation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The current
group::Wnafimplementation assumesPrimeField::to_reprreturns a little endian encoding, so it doesn't work with our implementations of the NIST P-curves, which return a big endian SEC1 encoding.Following the general idea from RustCrypto/group#10, this adds an API which is guaranteed to return a little endian encoding which will always work with the current implementation of
group::Wnaf.This is largely a stopgap solution which allows us to begin using
group::Wnafat all, though ideally we can find a more elegant upstream solution.cc @str4d @tob-scott-a