Skip to content

Have wNAF use PrimeField::to_le_repr for scalars#12

Merged
tarcieri merged 1 commit intomainfrom
wnaf-fix
Mar 31, 2026
Merged

Have wNAF use PrimeField::to_le_repr for scalars#12
tarcieri merged 1 commit intomainfrom
wnaf-fix

Conversation

@tarcieri
Copy link
Copy Markdown
Member

@tarcieri tarcieri commented 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.

Thanks to @tob-scott-a for sleuthing this out in #10.

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 tarcieri changed the title [WIP] Have wNAF use PrimeField::to_le_repr for scalars Have wNAF use PrimeField::to_le_repr for scalars Mar 31, 2026
@tarcieri tarcieri marked this pull request as ready for review March 31, 2026 15:55
@tarcieri
Copy link
Copy Markdown
Member Author

tarcieri commented Mar 31, 2026

Confirmed this is working against p256 on the wnaf branch of https://github.com/RustCrypto/elliptic-curves, so I'm going to merge

cc @str4d

@tarcieri tarcieri merged commit 0d3091d into main Mar 31, 2026
8 checks passed
@tarcieri tarcieri deleted the wnaf-fix branch March 31, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant