RustCrypto / RustCrypto/elliptic-curves
primefield: canonical form field element types (for e.g. `Scalar` types)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 874
- Forks
- 299
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 12
Description
Currently we only support Montgomery form for field elements. #1191 would further solidify that.
p256 contains a handwritten Scalar implementation which uses canonical form w\ Barrett reduction as opposed to Montgomery form w\ Montgomery reduction. Using this form for scalars has potential performance benefits for common scalar usage patterns, where the overhead of converting into/out of Montgomery form outweighs the performance advantages the form provides.
It would be potentially useful to provide macros which can write field elements in canonical form, generating a Barrett reduction implementation. Anyone attempting to generalize the implementation in p256::Scalar should be aware of the performance optimization introduced in #1155, however, which relies on particular properties of the P-256 scalar modulus.
Some other important questions here: how do we share code between canonical and Montgomery field element types, and should macros be prefixed based on the internal representation?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the handwritten p256::Scalar implementation and read the context in issues #1191 and #1155. Compare its canonical-form and Barrett-reduction approach with the existing Montgomery field-element support. Done requires an agreed design for sharing code, naming macros, and generating canonical field-element types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cryptography
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100