Add FromUniformBytes<64> to {k,p}256::Scalar#1379
Merged
tarcieri merged 1 commit intoRustCrypto:masterfrom Sep 3, 2025
Merged
Conversation
tarcieri
approved these changes
Sep 3, 2025
Member
tarcieri
left a comment
There was a problem hiding this comment.
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
Member
|
See also: #1341 |
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`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.