Skip to content

Commit

Permalink
Add multi-pairing test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-lj committed Apr 16, 2024
1 parent 00127dc commit bc2a0a7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fastcrypto/src/tests/bls12381_group_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,21 @@ fn test_pairing_and_hash_to_curve() {
let sig2 = e2 * sk2;
assert_eq!(pk2.pairing(&e2), G1Element::generator().pairing(&sig2));

// Test multi-pairing
assert!(G1Element::multi_pairing(&[], &[pk1]).is_err());
assert_eq!(
G1Element::multi_pairing(&[], &[]).unwrap(),
GTElement::zero()
);
assert_eq!(
G1Element::multi_pairing(&[e1], &[pk1]).unwrap(),
e1.pairing(&pk1)
);
assert_eq!(
G1Element::multi_pairing(&[e1, pk2], &[pk1, e2]).unwrap(),
e1.pairing(&pk1) + pk2.pairing(&e2)
);

assert_eq!(
G1Element::zero().pairing(&G2Element::zero()),
GTElement::zero()
Expand Down

0 comments on commit bc2a0a7

Please sign in to comment.