Skip to content

primeorder: use FieldArithmetic trait#1833

Merged
tarcieri merged 1 commit into
masterfrom
primeorder/use-field-arithmetic-trait
Jun 21, 2026
Merged

primeorder: use FieldArithmetic trait#1833
tarcieri merged 1 commit into
masterfrom
primeorder/use-field-arithmetic-trait

Conversation

@tarcieri

Copy link
Copy Markdown
Member

Uses the new hazmat trait added to elliptic-curve in RustCrypto/traits#2458 to define the associated FieldElement type for a given curve.

Uses the new `hazmat` trait added to `elliptic-curve` in
RustCrypto/traits#2458 to define the associated `FieldElement` type for
a given curve.
@tarcieri tarcieri force-pushed the primeorder/use-field-arithmetic-trait branch from 935a4a4 to 9c9b728 Compare June 21, 2026 23:19
@tarcieri tarcieri merged commit 7c112cb into master Jun 21, 2026
165 checks passed
@tarcieri tarcieri deleted the primeorder/use-field-arithmetic-trait branch June 21, 2026 23:35
tarcieri added a commit that referenced this pull request Jun 21, 2026
This removes the `expose-field` feature from `k256`, `p256`, `p384`, and
`p521`, which previously re-exported the `FieldElement` types for these
curves from the toplevel of these crates.

That's the wrong level of abstraction and mixes something which is easy
to misuse with the other safe abstractions provided at the crate's
toplevel.

Instead, the `FieldElement` types can always be accessed using the new
`hazmat` trait: `FieldArithmetic` (see #1833)

    use elliptic_curve::hazmat::FieldArithmetic;
    type FieldElement = <MyCurve as FieldArithmetic>::FieldElement;

There's no longer any crate features to enable and it's always
accessible, but must be accessed through the `hazmat` trait, which we
recommend you *do not* re-export (nor should you re-export a type alias)
so the "hazmat" string is always easy to search for.
tarcieri added a commit that referenced this pull request Jun 22, 2026
This removes the `expose-field` feature from `k256`, `p256`, `p384`, and
`p521`, which previously re-exported the `FieldElement` types for these
curves from the toplevel of these crates.

That's the wrong level of abstraction and mixes something which is easy
to misuse with the other safe abstractions provided at the crate's
toplevel.

Instead, the `FieldElement` types can always be accessed using the new
`hazmat` trait: `FieldArithmetic` (see #1833)

    use elliptic_curve::hazmat::FieldArithmetic;
    type FieldElement = <MyCurve as FieldArithmetic>::FieldElement;

There's no longer any crate features to enable and it's always
accessible, but must be accessed through the `hazmat` trait, which we
recommend you *do not* re-export (nor should you re-export a type alias)
so the "hazmat" string is always easy to search for.
@tarcieri tarcieri mentioned this pull request Jul 2, 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.

1 participant