Skip to content

Commit

Permalink
plonk: removed check that we are on the BLS12-381 in view of the fact…
Browse files Browse the repository at this point in the history
… that all example test vectors are defined on this curve. the check is not necessary since there will be an error at the compiler level if there is an attempt to compile the unit tests for a curve other than BLS12-381.
  • Loading branch information
Vesselin Velichkov committed Jul 13, 2022
1 parent b1c76fc commit 3397c23
Showing 1 changed file with 17 additions and 71 deletions.
88 changes: 17 additions & 71 deletions libsnark/zk_proof_systems/plonk/tests/test_plonk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,12 @@ void test_verify_invalid_proof(
}

/// Compute or fill-in ciruit specific data from example.
/// \attention the example class is defined specifically for the BLS12-381
/// curve, so make sure we are using this curve
template<typename ppT>
circuit_t<ppT> plonk_circuit_description_from_example(
const plonk_example example)
{
// the example class is defined specifically for the BLS12-381
// curve, so make sure we are using this curve TODO: remove when
// the implementation is stable and tested
try {
plonk_exception_assert_curve_bls12_381<ppT>();
} catch (const std::domain_error &e) {
std::cout << "Error: " << e.what() << "\n";
exit(EXIT_FAILURE);
}

using Field = libff::Fr<ppT>;

// public input (PI)
Expand Down Expand Up @@ -458,19 +450,12 @@ void test_plonk_prover_round_five(
ASSERT_EQ(W_zeta_omega_at_secret_aff.Y, example.W_zeta_omega_at_secret[1]);
}

/// \attention the example class is defined specifically for the BLS12-381
/// curve, so make sure we are using this curve
template<typename ppT> void test_plonk_prover_rounds()
{
using Field = libff::Fr<ppT>;

// example test values are defined specifically for the BLS12-381
// curve, so make sure we are using this curve
try {
plonk_exception_assert_curve_bls12_381<ppT>();
} catch (const std::domain_error &e) {
std::cout << "Error: " << e.what() << "\n";
exit(EXIT_FAILURE);
}

ppT::init_public_params();

// load test vector values from example circuit
Expand Down Expand Up @@ -562,18 +547,12 @@ template<typename ppT> void test_plonk_prover_rounds()
srs);
}

/// \attention the example class is defined specifically for the BLS12-381
/// curve, so make sure we are using this curve
template<typename ppT> void test_plonk_srs()
{
using Field = libff::Fr<ppT>;

// example test values are defined specifically for the BLS12-381
// curve, so make sure we are using this curve
try {
plonk_exception_assert_curve_bls12_381<ppT>();
} catch (const std::domain_error &e) {
std::cout << "Error: " << e.what() << "\n";
exit(EXIT_FAILURE);
}
ppT::init_public_params();
// load test vector values from example circuit
plonk_example example;
Expand Down Expand Up @@ -609,18 +588,12 @@ template<typename ppT> void test_plonk_srs()
}
}

/// \attention the example class is defined specifically for the BLS12-381
/// curve, so make sure we are using this curve
template<typename ppT> void test_plonk_prover()
{
using Field = libff::Fr<ppT>;

// example test values are defined specifically for the BLS12-381
// curve, so make sure we are using this curve
try {
plonk_exception_assert_curve_bls12_381<ppT>();
} catch (const std::domain_error &e) {
std::cout << "Error: " << e.what() << "\n";
exit(EXIT_FAILURE);
}
ppT::init_public_params();
// load test vector values from example circuit
plonk_example example;
Expand Down Expand Up @@ -700,20 +673,12 @@ template<typename ppT> void test_plonk_prover()
ASSERT_EQ(W_zeta_omega_at_secret_aff.Y, example.W_zeta_omega_at_secret[1]);
}

/// \attention the example class is defined specifically for the BLS12-381
/// curve, so make sure we are using this curve
template<typename ppT>
void test_plonk_verifier_preprocessed_input(
const plonk_example &example, const srs<ppT> &srs)
{
// the example class is defined specifically for the BLS12-381
// curve, so make sure we are using this curve TODO: remove when
// the implementation is stable and tested
try {
plonk_exception_assert_curve_bls12_381<ppT>();
} catch (const std::domain_error &e) {
std::cout << "Error: " << e.what() << "\n";
exit(EXIT_FAILURE);
}

// compute verifier preprocessed input
const verifier_preprocessed_input_t<ppT> preprocessed_input =
plonk_verifier<ppT>::preprocessed_input(srs);
Expand Down Expand Up @@ -846,7 +811,9 @@ void test_plonk_verifier_step_eleven(
ASSERT_EQ(E1_aff.Y, example.E1[1]);
}

// step 12
/// test verifier step 12
/// \attention the example class is defined specifically for the BLS12-381
/// curve, so make sure we are using this curve
template<typename ppT>
void test_plonk_verifier_pairing(
const plonk_example &example,
Expand All @@ -857,15 +824,6 @@ void test_plonk_verifier_pairing(
const plonk_proof<ppT> &proof,
const srs<ppT> &srs)
{
// the example class is defined specifically for the BLS12-381
// curve, so make sure we are using this curve TODO: remove when
// the implementation is stable and tested
try {
plonk_exception_assert_curve_bls12_381<ppT>();
} catch (const std::domain_error &e) {
std::cout << "Error: " << e.what() << "\n";
exit(EXIT_FAILURE);
}
using Field = libff::Fr<ppT>;
std::vector<libff::G1<ppT>> curve_points_lhs{
proof.W_zeta_at_secret, proof.W_zeta_omega_at_secret};
Expand Down Expand Up @@ -912,18 +870,12 @@ void test_plonk_verifier_pairing(
ASSERT_TRUE(b_accept);
}

/// \attention the example class is defined specifically for the BLS12-381
/// curve, so make sure we are using this curve
template<typename ppT> void test_plonk_verifier_steps()
{
using Field = libff::Fr<ppT>;

// example test values are defined specifically for the BLS12-381
// curve, so make sure we are using this curve
try {
plonk_exception_assert_curve_bls12_381<ppT>();
} catch (const std::domain_error &e) {
std::cout << "Error: " << e.what() << "\n";
exit(EXIT_FAILURE);
}
ppT::init_public_params();
// load test vector values from example circuit
plonk_example example;
Expand Down Expand Up @@ -1021,18 +973,12 @@ template<typename ppT> void test_plonk_verifier_steps()
srs);
}

/// \attention the example class is defined specifically for the BLS12-381
/// curve, so make sure we are using this curve
template<typename ppT> void test_plonk_verifier()
{
using Field = libff::Fr<ppT>;

// example test values are defined specifically for the BLS12-381
// curve, so make sure we are using this curve
try {
plonk_exception_assert_curve_bls12_381<ppT>();
} catch (const std::domain_error &e) {
std::cout << "Error: " << e.what() << "\n";
exit(EXIT_FAILURE);
}
ppT::init_public_params();
// load test vector values from example circuit
plonk_example example;
Expand Down

0 comments on commit 3397c23

Please sign in to comment.