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

Fix pairing tests for null accumulated values #579

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading