Support montgomery form directly in non-native field operations

Open
#21 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
cryptography

Research direction

Start by reading the existing non-native field operations under core/src/operations/field and compare how multiplication and division/inversion handle regular field representations. The issue describes Montgomery-form support as the goal; done should provide operations that handle the R factor directly and avoid the described conversion roundtrips.

Written by the indexing model from the issue text.

Description

Many implementations of elliptic curves in libraries (e.g. bls12_381) internally make use of the montgomery form to represent field elements, where a number a mod P is stored as aR mod P for some factor R (for bls12_381, this is 2^384 mod P).

Currently, the existing non-native field operations supported all simply deal with regular a mod P representations of these numbers. In the case of addition and subtraction nothing changes, but when multiplication and division are involved, the R factor needs to be dealt with separately. This incurs overhead by requiring multiple additional operations. It would be desirable to have non-native field operations that natively directly support the montgomery form when performing multiplication and division/inversion.

This is not a high-priority blocking issue since we can work around this issue by using a field multiplication precompile to perform the reduction, i.e. multiplying by R^(-1) to remove the R factor, perform the usual operation, then multiply back by R to return it to its montgomery representation. There is still overhead in doing this though, specially in long-running computations that perform many of these roundtrips.

Dominant language
Rust
Stars
80
Forks
8
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

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.

More from argumentcomputer/sphinx

All issues in argumentcomputer/sphinx

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.