Skip to content

Commit

Permalink
fix cmts
Browse files Browse the repository at this point in the history
  • Loading branch information
PatStiles committed Nov 22, 2023
1 parent 2f237b4 commit 7fac432
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions fuzz/no_gpu_fuzz/fuzz_targets/curve_bls12_381.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use lambdaworks_math::{
type LambdaG1 = ShortWeierstrassProjectivePoint<BLS12381Curve>;
type LambdaG2 = ShortWeierstrassProjectivePoint<BLS12381TwistCurve>;

//TODO: derive arbitrary for Affine and Projective or change this to use &[u8] as input to cover more cases.
//TODO: use more advanced options to generate values over curve specifically given most inputs will fail curve check.
//TODO: Derive arbitrary for Affine and Projective or change this to use &[u8] as input to cover more cases.
//TODO: Use more advanced options to generate values over curve specifically given most inputs will fail curve check.
//TODO: Investigate normalization of projective coordinates in arkworks to allow for differential fuzzing.
fuzz_target!(|values: (u64, u64)| {
let (a_val, b_val) = values;
Expand All @@ -43,37 +43,37 @@ fuzz_target!(|values: (u64, u64)| {
// -O = O
assert_eq!(g1_zero.neg(), g1_zero, "Neutral mul element a failed");

// P * O = O
// 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
// 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)
// (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
// 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");

// G2
// -O = O
assert_eq!(g2_zero.neg(), g2_zero, "Neutral mul element a failed");

// P * O = O
// P + O = O
assert_eq!(a_g2.operate_with(&g2_zero), a_g2, "Neutral operate_with element a failed");
assert_eq!(b_g2.operate_with(&g2_zero), b_g2, "Neutral operate_with element b failed");

// P * Q = Q * P
// P + Q = Q + P
assert_eq!(a_g2.operate_with(&b_g2), b_g2.operate_with(&a_g2), "Commutative add property failed");

// (P * Q) * R = Q * (P * R)
// (P + Q) + R = Q + (P + R)
let c_g2 = a_g2.operate_with(&b_g2);
assert_eq!((a_g2.operate_with(&b_g2)).operate_with(&c_g2), a_g2.operate_with(&b_g2.operate_with(&c_g2)), "Associative operate_with property failed");

// P * -P = O
// P + -P = O
assert_eq!(a_g2.operate_with(&a_g2.neg()), g2_zero, "Inverse add a failed");
assert_eq!(b_g2.operate_with(&b_g2.neg()), g2_zero, "Inverse add b failed");

Expand Down

0 comments on commit 7fac432

Please sign in to comment.