Skip to content

Add FromUniformBytes<64> to {k,p}256::Scalar#1379

Merged
tarcieri merged 1 commit intoRustCrypto:masterfrom
kayabaNerve:kp256-scalar-from-uniform-bytes
Sep 3, 2025
Merged

Add FromUniformBytes<64> to {k,p}256::Scalar#1379
tarcieri merged 1 commit intoRustCrypto:masterfrom
kayabaNerve:kp256-scalar-from-uniform-bytes

Conversation

@kayabaNerve
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Member

@tarcieri tarcieri left a comment

Choose a reason for hiding this comment

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

It would be nice to compose either the FromUniformBytes impl in terms of the Reduce<WideBytes> impl or vice versa, so we don't duplicate the implementation, but this is fine for now

@tarcieri tarcieri merged commit b595134 into RustCrypto:master Sep 3, 2025
37 checks passed
@tarcieri
Copy link
Copy Markdown
Member

tarcieri commented Sep 3, 2025

See also: #1341

@kayabaNerve kayabaNerve deleted the kp256-scalar-from-uniform-bytes branch September 3, 2025 16:58
kayabaNerve added a commit to kayabaNerve/elliptic-curves that referenced this pull request Mar 30, 2026
I don't _love_ this implementation. `crypto_bigint` could generate a faster
modular reduction, and I'm sure the tailored arithmetic would also be faster if
this was expressed as a linear combination of `hi * 2**256 + lo`. This is just
the most direct possible way to implement this.

As for why perform a hit and run for this specific function, I maintain an
implementation of secq256k1 where the `Scalar`, `FieldElement` types are
secp256k1's `FieldElement`, `Scalar` types (respectively). This means I need
all functions for `FieldElement` as one would want (or as I would want) from
`Scalar`. I wanted to make this PR now as obviously, many RustCrypto crates
have recently moved out of `rc`, so I'm double checking if anything slipped
through the cracks on my end for features I want to ensure are included.
Historically, I implemented this trait for the `Scalar` types with
RustCrypto#1379. While that included
feedback on deferring to `Reduce`, this type does not have any outstanding
implementations of `Reduce`.
kayabaNerve added a commit to kayabaNerve/elliptic-curves that referenced this pull request Mar 30, 2026
I don't _love_ this implementation. `crypto_bigint` could generate a faster
modular reduction, and I'm sure the tailored arithmetic would also be faster if
this was expressed as a linear combination of `hi * 2**256 + lo`. This is just
the most direct possible way to implement this.

As for why perform a hit and run for this specific function, I maintain an
implementation of secq256k1 where the `Scalar`, `FieldElement` types are
secp256k1's `FieldElement`, `Scalar` types (respectively). This means I need
all functions for `FieldElement` as one would want (or as I would want) from
`Scalar`. I wanted to make this PR now as obviously, many RustCrypto crates
have recently moved out of `rc`, so I'm double checking if anything slipped
through the cracks on my end for features I want to ensure are included.
Historically, I implemented this trait for the `Scalar` types with
RustCrypto#1379. While that included
feedback on deferring to `Reduce`, this type does not have any outstanding
implementations of `Reduce`.
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.

2 participants