Skip to content

primefield: remove shr support#1320

Merged
tarcieri merged 1 commit intomasterfrom
primefield/remove-shr-support
Jul 21, 2025
Merged

primefield: remove shr support#1320
tarcieri merged 1 commit intomasterfrom
primefield/remove-shr-support

Conversation

@tarcieri
Copy link
Member

@tarcieri tarcieri commented Jul 21, 2025

It was noted as buggy in #1319 because shr was being computed on values within the Montgomery domain directly. They either need to be converted to canonical form first, or a Montgomery multiplication needs to be used in place of a bit shift.

Turns out it was completely unused, aside from fulfilling a bound in the elliptic-curve crate, which has since been removed.

This removes shr support from all curves whose Scalar uses an internal Montgomery representation. It has been retained on k256 and p256 which use canonical form Scalar types.

Closes #1319

It was noted as buggy in #1319 because `shr` was being computed on
values within the Montgomery domain directly. They either need to be
converted to canonical form first, or a multiplication needs to be used
in place of a bit shift.

Turns out it was completely unused, aside from fulfilling a bound in the
`elliptic-curve` crate, which has since been removed.

This removes `shr` support from all curves whose `Scalar` used an
internal Montgomery representation. It has been retained on `k256` and
`p256` which use canonical form `Scalar` types.

Closes #1319
@tarcieri tarcieri force-pushed the primefield/remove-shr-support branch from c4cebd1 to e780294 Compare July 21, 2025 14:42
@tarcieri tarcieri merged commit d0f55ba into master Jul 21, 2025
159 checks passed
@tarcieri tarcieri deleted the primefield/remove-shr-support branch July 21, 2025 15: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.

primefield: shr appears to be miscomputed in Montgomery form

1 participant