RustCrypto / RustCrypto/elliptic-curves

primefield: canonical form field element types (for e.g. `Scalar` types)

Open
#1,192 1 comment 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.