Skip to content

Preliminary wNAF support#1714

Merged
tarcieri merged 1 commit intomasterfrom
wnaf
Apr 8, 2026
Merged

Preliminary wNAF support#1714
tarcieri merged 1 commit intomasterfrom
wnaf

Conversation

@tarcieri
Copy link
Copy Markdown
Member

@tarcieri tarcieri commented Apr 8, 2026

RustCrypto/group#12 included a workaround that allows curves with a big endian PrimeField::Repr to be used for wNAF, by defining a separate PrimeField::to_le_repr method which is always guaranteed to be little endian. This may not be the permanent solution to this problem which gets upstreamed, but it unblocks work for now.

This commit adds the relevant impls of to_le_repr, along with initial WnafGroup impls to ProjectivePoint in k256 and primeorder (currently hardcoded to a fixed constant of 4 for now to unblock additional work).

This also adds a ProjectivePoint::wnaf static method to obtain a wNAF context for that particular curve group, feature-gated on alloc.

Finally, it adds a smoke test to p256 which checks it against our scalar multiplication test vectors, however it does not check any other curves yet and probably should.

RustCrypto/group#12 included a workaround that allows curves with a big
endian `PrimeField::Repr` to be used for wNAF, by defining a separate
`PrimeField::to_le_repr` method which is always guaranteed to be little
endian. This may not be the permanent solution to this problem which
gets upstreamed, but it unblocks work for now.

This commit adds the relevant impls of `to_le_repr`, along with initial
`WnafGroup` impls to `ProjectivePoint` in `k256` and `primeorder`
(currently hardcoded to a fixed constant of `4` for now to unblock
additional work).

This also adds a `ProjectivePoint::wnaf` static method to obtain a
wNAF context for that particular curve group, feature-gated on `alloc`.

Finally, it adds a smoke test to `p256` which checks it against our
scalar multiplication test vectors, however it does not check any other
curves yet and probably should.
@tarcieri tarcieri merged commit c8fa260 into master Apr 8, 2026
159 checks passed
@tarcieri tarcieri deleted the wnaf branch April 8, 2026 23:06
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