Skip to content

Commit

Permalink
Fix pairing tests for null accumulated values (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare authored Sep 2, 2024
1 parent b938b63 commit e1f03df
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions evm_arithmetization/src/curve_pairings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,18 +1007,15 @@ mod tests {
}

// Finally, multiply by the accumulated inverse and check this matches the
// expected value.
let p = CurveAff::<BLS381>::int(acc);
let q = CurveAff::<Fp2<BLS381>>::GENERATOR;
running_product = running_product * bls381::ate_optim(p, q);

let expected = if acc == 0 {
Fp12::<BLS381>::ZERO
} else {
Fp12::<BLS381>::UNIT
};
// expected value. Only do this when acc is nonzero, as the pairing is only
// defined over valid curve points.
if acc != 0 {
let p = CurveAff::<BLS381>::int(acc);
let q = CurveAff::<Fp2<BLS381>>::GENERATOR;
running_product = running_product * bls381::ate_optim(p, q);
}

assert_eq!(running_product, expected);
assert_eq!(running_product, Fp12::<BLS381>::UNIT);
}

#[test]
Expand All @@ -1040,17 +1037,14 @@ mod tests {
}

// Finally, multiply by the accumulated inverse and check this matches the
// expected value.
let p = CurveAff::<BN254>::int(acc);
let q = CurveAff::<Fp2<BN254>>::GENERATOR;
running_product = running_product * bn254::tate(p, q);

let expected = if acc == 0 {
Fp12::<BN254>::ZERO
} else {
Fp12::<BN254>::UNIT
};
// expected value. Only do this when acc is nonzero, as the pairing is only
// defined over valid curve points.
if acc != 0 {
let p = CurveAff::<BN254>::int(acc);
let q = CurveAff::<Fp2<BN254>>::GENERATOR;
running_product = running_product * bn254::tate(p, q);
}

assert_eq!(running_product, expected);
assert_eq!(running_product, Fp12::<BN254>::UNIT);
}
}

0 comments on commit e1f03df

Please sign in to comment.