Skip to content

Add ReprEndianness enum and PrimeField::REPR_ENDIANNESS#158

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

Add ReprEndianness enum and PrimeField::REPR_ENDIANNESS#158
tarcieri wants to merge 1 commit into
zkcrypto:mainfrom
tarcieri:repr-endianness

Conversation

@tarcieri

@tarcieri tarcieri commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Adds an enum and associated constant with default ReprEndianness::Little for describing the endianness of the binary representation of field elements, as proposed in zkcrypto/rfcs#4.

Because the constant has a default, this is a non-breaking change.

Adds an enum and associated constant with default
`ReprEndianness::Little` for describing the endianness of the binary
representation of field elements, as proposed in
zkcrypto/rfcs#4
tarcieri added a commit to RustCrypto/traits that referenced this pull request Jun 21, 2026
Removes the `FieldBytesEncoding` trait and replaces it with:
- `Curve::FIELD_ENDIANNESS` which defaults to `ByteOrder::BigEndian`
- `field::{bytes_to_uint, uint_to_bytes}` generic free functions

This constant annoyingly duplicates the ones we have elsewhere, but
without getting it upstream into `ff` (zkcrypto/ff#158) there is no
single other convenient place to hang it but here.

Ideally this functionality could be phased out completely, but there are
still places that need it for now (e.g. legacy `rfc6979`, ECDSA
recovery).

In a future breaking release after the imminent one, we need to refactor
everything so the base and scalar fields are treated completely
separately. At that point, hopefully this all can and will need to go
away, and we will be able to leverage an upstream endianness constant
instead of having to stick (another) one in `elliptic-curve`.
tarcieri added a commit to RustCrypto/traits that referenced this pull request Jun 21, 2026
…2457)

Removes the `FieldBytesEncoding` trait and replaces it with:
- `Curve::FIELD_ENDIANNESS` which defaults to `ByteOrder::BigEndian`
- `field::{bytes_to_uint, uint_to_bytes}` generic free functions

This constant annoyingly duplicates the ones we have elsewhere, but
without getting it upstream into `ff` (zkcrypto/ff#158) there is no
single other convenient place to hang it but here.

Ideally this functionality could be phased out completely, but there are
still places that need it for now (e.g. legacy `rfc6979`, ECDSA
recovery).

In a future breaking release after the imminent one, we need to refactor
everything so the base and scalar fields are treated completely
separately. At that point, hopefully this all can and will need to go
away, and we will be able to leverage an upstream endianness constant
instead of having to stick (another) one in `elliptic-curve`.
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