Skip to content

Commit

Permalink
tests: fake + fake proof
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJepsen committed May 20, 2024
1 parent 3e81559 commit 99c28cd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/kzg/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
41 changes: 41 additions & 0 deletions src/kzg/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,48 @@ fn e2e(#[case] poly: Polynomial<Monomial, PlutoScalarField>, #[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<Monomial, PlutoScalarField>,
#[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<Monomial, PlutoScalarField>,
#[case] eval_point: PlutoScalarField,
) {
let paring_params = commit_and_open(poly, eval_point);
let valid = check(
paring_params.p,
AffinePoint::<PlutoExtendedCurve>::Infinity, // fake proof
paring_params.point,
paring_params.point,
paring_params.g1srs.clone(),
paring_params.g2srs.clone(),
);
assert!(valid);
}

Expand Down

0 comments on commit 99c28cd

Please sign in to comment.