-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ecc): Add Grumpkin curve + refactor fuzzer (#811)
* add grumpkin + add fuzzer + refactor fuzzer module * fmt * comment for tests to add * add additional tests * rm extraneous comment * add point operate_with test * fmt
- Loading branch information
Showing
13 changed files
with
413 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#![no_main] | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
use lambdaworks_math::{ | ||
cyclic_group::IsGroup, | ||
elliptic_curve::{ | ||
traits::{IsEllipticCurve, IsPairing}, | ||
short_weierstrass::{ | ||
curves::grumpkin::curve::GrumpkinCurve, | ||
point::ShortWeierstrassProjectivePoint, | ||
} | ||
}, | ||
field::element::FieldElement, | ||
}; | ||
|
||
type LambdaG1 = ShortWeierstrassProjectivePoint<GrumpkinCurve>; | ||
|
||
//TODO: derive arbitrary for Affine and Projective or change this to use &[u8] as input to cover more cases | ||
fuzz_target!(|values: (u64, u64)| { | ||
let (a_val, b_val) = values; | ||
|
||
let a_g1 = GrumpkinCurve::generator().operate_with_self(a_val); | ||
let b_g1 = GrumpkinCurve::generator().operate_with_self(b_val); | ||
|
||
// ***AXIOM SOUNDNESS*** | ||
let g1_zero = LambdaG1::neutral_element(); | ||
|
||
// -O = O | ||
assert_eq!(g1_zero.neg(), g1_zero, "Neutral mul element a failed"); | ||
|
||
// P * O = O | ||
assert_eq!(a_g1.operate_with(&g1_zero), a_g1, "Neutral operate_with element a failed"); | ||
assert_eq!(b_g1.operate_with(&g1_zero), b_g1, "Neutral operate_with element b failed"); | ||
|
||
// P * Q = Q * P | ||
assert_eq!(a_g1.operate_with(&b_g1), b_g1.operate_with(&a_g1), "Commutative add property failed"); | ||
|
||
// (P * Q) * R = Q * (P * R) | ||
let c_g1 = a_g1.operate_with(&b_g1); | ||
assert_eq!((a_g1.operate_with(&b_g1)).operate_with(&c_g1), a_g1.operate_with(&b_g1.operate_with(&c_g1)), "Associative operate_with property failed"); | ||
|
||
// P * -P = O | ||
assert_eq!(a_g1.operate_with(&a_g1.neg()), g1_zero, "Inverse add a failed"); | ||
assert_eq!(b_g1.operate_with(&b_g1.neg()), g1_zero, "Inverse add b failed"); | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.