Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,15 @@ pub trait PrimeField: Field + From<u64> {
/// encodings of field elements should be treated as opaque.
fn to_repr(&self) -> Self::Repr;

/// Converts an element of the prime field into a little-endian byte representation.
///
/// The default implementation assumes [`Self::to_repr`] already returns a little-endian
/// encoding. Implementors whose [`Self::to_repr`] uses big-endian encoding must override
/// this method (e.g. by reversing the bytes).
Comment on lines +296 to +298

@str4d str4d May 28, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bad assumption to include in a root trait's default method, because downstream trait implementers will not be aware that they need to override it.

fn to_le_repr(&self) -> Self::Repr {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot return Self::Repr, because this is not guaranteed to be round-trip compatible with Self::from_repr.

self.to_repr()
}

/// Returns true iff this element is odd.
fn is_odd(&self) -> Choice;

Expand Down