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

Feat/bn 254 #646

Merged
merged 43 commits into from
Jan 30, 2024
Merged

Feat/bn 254 #646

merged 43 commits into from
Jan 30, 2024

Conversation

PatStiles
Copy link
Contributor

Add BN254

Description

Implementation of BN254 #548 to be finished with @protocolwhisper

Implements:

  • BN254 curve
  • Towered Extension Field
  • Twist
  • Unit tests
  • Differential Fuzzer against ark_bn254
  • Pairing
  • Optimized Pairing Final Exponentiation as described in https://eprint.iacr.org/2015/192.pdf

Type of change

Please delete options that are not relevant.

  • New feature

Checklist

  • Linked to Github Issue
  • Unit tests added
  • This change requires new documentation.
    • Documentation has been added/updated.
  • This change is an Optimization
    • Benchmarks added/run

@PatStiles PatStiles requested review from schouhy, ajgara and a team as code owners October 31, 2023 06:15
@codecov-commenter
Copy link

codecov-commenter commented Oct 31, 2023

Codecov Report

Attention: 100 lines in your changes are missing coverage. Please review.

Comparison is base (51affa8) 94.59% compared to head (e5b80bf) 94.34%.

Files Patch % Lines
...short_weierstrass/curves/bn_254/field_extension.rs 16.37% 97 Missing ⚠️
...tic_curve/short_weierstrass/curves/bn_254/curve.rs 98.78% 1 Missing ⚠️
...e/short_weierstrass/curves/bn_254/default_types.rs 0.00% 1 Missing ⚠️
...tic_curve/short_weierstrass/curves/bn_254/twist.rs 99.03% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #646      +/-   ##
==========================================
- Coverage   94.59%   94.34%   -0.25%     
==========================================
  Files         144      148       +4     
  Lines       33838    34141     +303     
==========================================
+ Hits        32008    32211     +203     
- Misses       1830     1930     +100     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

PatStiles and others added 25 commits January 25, 2024 13:00
* initial commit

* change serde_cbor for serde_bare

* bincode de/ser

* remove comparison

* fmt

* restore flag

* fix failing test

* add std feature flag

* conditional  use

* rmv conditional use

* replace std for core

* add cond import

* rmv unused import

* rplc todo w unimplemented

* Update provers/cairo/src/main.rs

---------

Co-authored-by: Mauro Toscano <12560266+MauroToscano@users.noreply.github.com>
* initial commit

* change serde_cbor for serde_bare

* bincode de/ser

* remove comparison

* fmt

* restore flag

* fix failing test

* add std feature flag

* conditional  use

* rmv conditional use

* replace std for core

* add cond import

* rmv unused import

* rplc todo w unimplemented

* Update provers/cairo/src/main.rs

---------

Co-authored-by: Mauro Toscano <12560266+MauroToscano@users.noreply.github.com>
* update wasm with new verifier api

* fmt

* Re add wasm compile and test

* Add wasm commands to makefile

* Add wasm commands to makefile

* Fix wasm commands

* Fix wasm

* Fix wasm CI

* Fmt

* Fmt + fmt ci wasm

* Compatibility with main

* Fix

* Fmt

* Remove unnecesary clone

* Fix linters

* Raise security

* Re add dep

* Wasm

---------

Co-authored-by: Mauro Toscano <12560266+MauroToscano@users.noreply.github.com>
Co-authored-by: MauroFab <maurotoscano2@gmail.com>
@PatStiles PatStiles changed the title Feat/bn 256 Feat/bn 254 Jan 26, 2024
Comment on lines 63 to 77
impl ShortWeierstrassProjectivePoint<BN254TwistCurve> {
/// This function is related to the map ψ: E_twist(𝔽p²) -> E(𝔽p¹²).
/// Given an affine point G in E_twist(𝔽p²) returns x, y such that
/// ψ(G) = (x', y', 1) with x' = x * x'' and y' = y * y''
/// for some x'', y'' in 𝔽p².
/// This is meant only to be used in the miller loop of the
/// ate pairing before the final exponentiation.
/// This is because elements in 𝔽p² raised to that
/// power are 1 and so the final result of the ate pairing
/// doens't depend on having this function output the exact
/// values of x' and y'. And it is enough to work with x and y.
pub fn to_fp12_unnormalized(&self) -> [FieldElement<Degree12ExtensionField>; 2] {
todo!()
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
impl ShortWeierstrassProjectivePoint<BN254TwistCurve> {
/// This function is related to the map ψ: E_twist(𝔽p²) -> E(𝔽p¹²).
/// Given an affine point G in E_twist(𝔽p²) returns x, y such that
/// ψ(G) = (x', y', 1) with x' = x * x'' and y' = y * y''
/// for some x'', y'' in 𝔽p².
/// This is meant only to be used in the miller loop of the
/// ate pairing before the final exponentiation.
/// This is because elements in 𝔽p² raised to that
/// power are 1 and so the final result of the ate pairing
/// doens't depend on having this function output the exact
/// values of x' and y'. And it is enough to work with x and y.
pub fn to_fp12_unnormalized(&self) -> [FieldElement<Degree12ExtensionField>; 2] {
todo!()
}
}

README.md Outdated
Comment on lines 239 to 240

testing
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
testing

diegokingston
diegokingston previously approved these changes Jan 30, 2024
@MauroToscano MauroToscano added this pull request to the merge queue Jan 30, 2024
Merged via the queue into lambdaclass:main with commit e1a4aaf Jan 30, 2024
7 checks passed
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.

None yet

7 participants