Skip to content

RFC: Add enum ReprEndianness constant to PrimeField trait#4

Open
tarcieri wants to merge 1 commit into
zkcrypto:mainfrom
tarcieri:ff-prime-field-repr-endianness
Open

RFC: Add enum ReprEndianness constant to PrimeField trait#4
tarcieri wants to merge 1 commit into
zkcrypto:mainfrom
tarcieri:ff-prime-field-repr-endianness

Conversation

@tarcieri

@tarcieri tarcieri commented Jun 4, 2026

Copy link
Copy Markdown

This aims to provide a solution to zkcrypto/group#78.

Rendered

@tarcieri tarcieri force-pushed the ff-prime-field-repr-endianness branch from 48fb332 to 8f44c47 Compare June 4, 2026 22:07
Downstream consumers of `PrimeField::Repr`, including the `group` crate, need to instead handle it
in an endian-aware manner.

# Guide-level explanation

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I may have misunderstood the purpose of this section versus "Reference-level explanation" and could potentially swap them?

Comment on lines +36 to +40
pub enum ReprEndianness {
Big,
#[default]
Little,
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I chose this name based on ff_derive, but I think a pub enum ByteOrder ala the primefield crate might be a little more reusable

tarcieri added a commit to RustCrypto/elliptic-curves that referenced this pull request Jun 16, 2026
Adds a trait for specifying the endianness of the serialized
representation of a field element as a stopgap until zkcrypto/rfcs#4 is
accepted.

This uses the `ByteOrder` enum and replaces the previous
`FIELD_REPR_IS_BE` flag on `PrimeCurveParams`. It also means
`Radix16Decomposition` now "Just Works" and doesn't need an endianness
parameter passed to `new`.

The `primefield::monty_field_element!` macro now writes impls for this
trait, sourcing the endianness information from the `MontyFieldParams`.
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