Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better const field and group initialization #437

Merged
merged 17 commits into from
Jul 13, 2022

Conversation

Pratyush
Copy link
Member

@Pratyush Pratyush commented Jul 7, 2022

Description

Leverages improved Rust support for const fn to enable better initialization of field and group elements in the const contexts.

Examples include:

// old
const f: Fp = MontFp!(Fp, "123");
// new
const F: Fp = MontFp!("123");

// old
const F2: Fp2 = QuadExt!(F, F);
//new
const F2: Fp2 = Fp2::new(F, F);

// old, impossible:
const GENERATOR: G1Affine = ???;
// new
const GENERATOR: G1Affine = G1Affine::new_unchecked(X, Y);
// ^ we use unchecked here to avoid on-curve and subgroup-membership tests

Closes #296


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (master)
  • Linked to GitHub issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Wrote unit tests
  • Updated relevant documentation in the code
  • Added a relevant changelog entry to the Pending section in CHANGELOG.md
  • Re-reviewed Files changed in the GitHub PR explorer

@Pratyush Pratyush requested a review from mmagician July 7, 2022 17:36
Copy link
Member

@mmagician mmagician left a comment

Choose a reason for hiding this comment

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

Looks good to me now!

@Pratyush Pratyush changed the title Leverage new Rust feature for better const field and group initialization Better const field and group initialization Jul 13, 2022
@Pratyush Pratyush merged commit b32685e into master Jul 13, 2022
@Pratyush Pratyush deleted the better-const-field-element-support branch July 13, 2022 14:44
@swasilyev
Copy link
Contributor

It seems CHANGELOG hasn't been updated

@Pratyush Pratyush linked an issue Sep 2, 2022 that may be closed by this pull request
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.

Make constructors const constant group element API over curve
3 participants