Skip to content

feat(wnaf): add scalar_repr_to_le_bytes()#10

Closed
tob-scott-a wants to merge 1 commit intoRustCrypto:mainfrom
tob-scott-a:wnaf-little-endian
Closed

feat(wnaf): add scalar_repr_to_le_bytes()#10
tob-scott-a wants to merge 1 commit intoRustCrypto:mainfrom
tob-scott-a:wnaf-little-endian

Conversation

@tob-scott-a
Copy link
Copy Markdown

Needed for a clean fix to elliptic-curve.

@tarcieri
Copy link
Copy Markdown
Member

Hmm, I do think a fix to group is warranted, though we'd need to get it upstream to https://github.com/rustcrypto/group

Per @str4d it sounds like the wNAF implementation in group should be refactored to not make any assumptions about endianness

tarcieri added a commit to RustCrypto/ff that referenced this pull request Mar 31, 2026
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.
tarcieri added a commit to RustCrypto/ff that referenced this pull request Mar 31, 2026
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.
@tarcieri
Copy link
Copy Markdown
Member

FYI, I took a slightly different approach here, adding a method to PrimeField for obtaining an always-little-endian representation: RustCrypto/ff#10

That's probably not the ideal solution, but it should be enough to at least get things working initially.

@tarcieri
Copy link
Copy Markdown
Member

Closing in favor of #12, but thanks for finding the issue!

@tarcieri tarcieri closed this Mar 31, 2026
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.

2 participants