diff --git a/src/kzg/setup.rs b/src/kzg/setup.rs index 22666f4d..4f3ceb24 100644 --- a/src/kzg/setup.rs +++ b/src/kzg/setup.rs @@ -100,14 +100,6 @@ pub fn check( lhs == rhs } -// for g1 last, g2 first -// lhs GaloisField { coeffs: [PrimeField { value: 2 }, PrimeField { value: 94 }] } -// rhs GaloisField { coeffs: [PrimeField { value: 26 }, PrimeField { value: 97 }] } - -// for g1 first, g2 first -// lhs GaloisField { coeffs: [PrimeField { value: 2 }, PrimeField { value: 94 }] } -// rhs GaloisField { coeffs: [PrimeField { value: 59 }, PrimeField { value: 49 }] } - // p = 101 // k = 2 (embedding degree, determines your extension field) // base field = GF_101 @@ -116,4 +108,5 @@ pub fn check( // (all petals are in this base extension field: has two cyclic groups of order 17) // Asymmetric means G1 and G2 are different subgroups +// This is a little confusing teminology because all pairing friendly subgroups are isomorphic // Symmetric means G1 and G2 are the same subgroup diff --git a/src/kzg/tests.rs b/src/kzg/tests.rs index 9b3a5880..2ba30fd0 100644 --- a/src/kzg/tests.rs +++ b/src/kzg/tests.rs @@ -251,7 +251,48 @@ fn e2e(#[case] poly: Polynomial, #[case] eval_point: paring_params.g1srs.clone(), paring_params.g2srs.clone(), ); + assert!(valid); +} +#[rstest] +#[case(poly_1(), PlutoScalarField::new(4))] +#[case(poly_2(), PlutoScalarField::new(3))] +#[case(poly_3(), PlutoScalarField::new(5))] +#[should_panic] +fn invalid_check( + #[case] poly: Polynomial, + #[case] eval_point: PlutoScalarField, +) { + let paring_params = commit_and_open(poly, eval_point); + let valid = check( + paring_params.p, + paring_params.q, + paring_params.point, + PlutoScalarField::new(10), // fake evaluation point + paring_params.g1srs.clone(), + paring_params.g2srs.clone(), + ); + assert!(valid); +} + +#[rstest] +#[case(poly_1(), PlutoScalarField::new(4))] +#[case(poly_2(), PlutoScalarField::new(3))] +#[case(poly_3(), PlutoScalarField::new(5))] +#[should_panic] +fn fake_proof( + #[case] poly: Polynomial, + #[case] eval_point: PlutoScalarField, +) { + let paring_params = commit_and_open(poly, eval_point); + let valid = check( + paring_params.p, + AffinePoint::::Infinity, // fake proof + paring_params.point, + paring_params.point, + paring_params.g1srs.clone(), + paring_params.g2srs.clone(), + ); assert!(valid); }