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

proof-producer: introduce command chain #258

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion crypto3/libs/blueprint/test/bbf/test_circuit_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ bool check_proof(

std::cout << "Verifier" << std::endl;
bool verifier_res = nil::crypto3::zk::snark::placeholder_verifier<FieldType, lpc_placeholder_params_type>::process(
lpc_preprocessed_public_data.common_data, lpc_proof, desc, bp, verifier_lpc_scheme);
*lpc_preprocessed_public_data.common_data, lpc_proof, desc, bp, verifier_lpc_scheme);
return verifier_res;
}

Expand Down
2 changes: 1 addition & 1 deletion crypto3/libs/blueprint/test/test_plonk_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ namespace nil {
);

bool verifier_res = nil::crypto3::zk::snark::placeholder_verifier<BlueprintFieldType, placeholder_params_type>::process(
preprocessed_public_data.common_data, proof, desc, bp, lpc_scheme
*preprocessed_public_data.common_data, proof, desc, bp, lpc_scheme
);

return verifier_res;
Expand Down
14 changes: 7 additions & 7 deletions crypto3/libs/blueprint/test/verifiers/placeholder/verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ template<typename SrcParams>
}

template<typename PlaceholderParams>
static typename nil::crypto3::zk::snark::placeholder_public_preprocessor<typename PlaceholderParams::field_type, PlaceholderParams>::preprocessed_data_type::common_data_type load_common_data(std::string filename){
static std::shared_ptr<typename nil::crypto3::zk::snark::placeholder_public_preprocessor<typename PlaceholderParams::field_type, PlaceholderParams>::preprocessed_data_type::common_data_type> load_common_data(std::string filename){
std::ifstream ifile;
ifile.open(filename, std::ios_base::binary | std::ios_base::in);
BOOST_ASSERT(ifile.is_open());
Expand Down Expand Up @@ -394,8 +394,8 @@ void test_multiple_arithmetizations(std::string folder_name){

auto proof = load_proof<SrcParams>(folder_name + "/proof.bin");
std::cout << "Loaded the proof" << std::endl;
auto table_description = common_data.desc;
auto fri_params = common_data.commitment_params;
auto table_description = common_data->desc;
auto fri_params = common_data->commitment_params;

std::cout << "Usable rows = " << table_description.usable_rows_amount << std::endl;
std::cout << "Rows amount = " << table_description.rows_amount << std::endl;
Expand All @@ -407,10 +407,10 @@ void test_multiple_arithmetizations(std::string folder_name){

// auto [common_data, fri_params, proof] = gen_test_proof<SrcParams>(constraint_system, table_description, assignment_table);

test_flexible_verifier<SrcParams, dst_params<15>>(constraint_system, common_data, proof, fri_params);
test_flexible_verifier<SrcParams, dst_params<42>>(constraint_system, common_data, proof, fri_params);
test_flexible_verifier<SrcParams, dst_params<84>>(constraint_system, common_data, proof, fri_params);
test_flexible_verifier<SrcParams, dst_params<168>>(constraint_system, common_data, proof, fri_params);
test_flexible_verifier<SrcParams, dst_params<15>>(constraint_system, *common_data, proof, fri_params);
test_flexible_verifier<SrcParams, dst_params<42>>(constraint_system, *common_data, proof, fri_params);
test_flexible_verifier<SrcParams, dst_params<84>>(constraint_system, *common_data, proof, fri_params);
test_flexible_verifier<SrcParams, dst_params<168>>(constraint_system, *common_data, proof, fri_params);
}

BOOST_AUTO_TEST_SUITE(blueprint_pallas_test_suite)
Expand Down
2 changes: 1 addition & 1 deletion crypto3/libs/blueprint/test/zkevm_bbf/test_l1_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ bool check_proof(

std::cout << "Verifier" << std::endl;
bool verifier_res = nil::crypto3::zk::snark::placeholder_verifier<BlueprintFieldType, lpc_placeholder_params_type>::process(
lpc_preprocessed_public_data.common_data, lpc_proof, desc, bp, verifier_lpc_scheme);
*lpc_preprocessed_public_data.common_data, lpc_proof, desc, bp, verifier_lpc_scheme);
return verifier_res;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,7 @@ namespace nil {
template<typename Endianness, typename LPCScheme>
aggregated_proof<nil::crypto3::marshalling::field_type<Endianness>, LPCScheme>
fill_aggregated_proof(
const typename LPCScheme::aggregated_proof_type &proof,
const typename LPCScheme::fri_type::params_type &fri_params
const typename LPCScheme::aggregated_proof_type &proof
){
using TTypeBase = nil::crypto3::marshalling::field_type<Endianness>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ namespace nil {
}

template<typename Endianness, typename CommonDataType>
CommonDataType make_placeholder_common_data(const
std::shared_ptr<CommonDataType> make_placeholder_common_data(const
placeholder_common_data<nil::crypto3::marshalling::field_type<Endianness>, CommonDataType> &filled_common_data
){
auto fixed_values = make_commitment<Endianness, typename CommonDataType::commitment_scheme_type>(std::get<0>(filled_common_data.value()));
Expand Down Expand Up @@ -263,7 +263,7 @@ namespace nil {
Endianness, typename CommonDataType::commitment_scheme_type
>(std::get<15>(filled_common_data.value()));

return CommonDataType(
return std::make_shared<CommonDataType>(
commitments,
columns_rotations,
desc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace nil {
fill_polynomial<Endianness, PolynomialDFSType>(preprocessed_public_data.q_last),
fill_polynomial<Endianness, PolynomialDFSType>(preprocessed_public_data.q_blind),
fill_placeholder_common_data<Endianness, typename PreprocessedPublicDataType::common_data_type>(
preprocessed_public_data.common_data)
*preprocessed_public_data.common_data)
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ namespace nil {
template<typename Endianness, typename AggregatedProof, typename Proof>
placeholder_aggregated_proof_type<nil::crypto3::marshalling::field_type<Endianness>, Proof>
fill_placeholder_aggregated_proof(
const AggregatedProof &proof,
const typename Proof::commitment_scheme_type::fri_type::params_type &fri_params
const AggregatedProof &proof
) {

using TTypeBase = nil::crypto3::marshalling::field_type<Endianness>;
Expand All @@ -268,7 +267,7 @@ namespace nil {
return placeholder_aggregated_proof_type<TTypeBase, Proof>(std::make_tuple(
filled_partial_proofs,
fill_aggregated_proof<Endianness, typename Proof::commitment_scheme_type>(
proof.aggregated_proof, fri_params)
proof.aggregated_proof)
));
}

Expand Down
9 changes: 3 additions & 6 deletions crypto3/libs/marshalling/zk/test/lpc_commitment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,11 @@ void test_lpc_proof(typename LPC::proof_type &proof, typename LPC::fri_type::par
}

template<typename Endianness, typename LPC>
void test_lpc_aggregated_proof(
typename LPC::aggregated_proof_type &proof,
typename LPC::fri_type::params_type fri_params
) {
void test_lpc_aggregated_proof(typename LPC::aggregated_proof_type &proof) {
using TTypeBase = nil::crypto3::marshalling::field_type<Endianness>;

auto filled_proof =
nil::crypto3::marshalling::types::fill_aggregated_proof<Endianness, LPC>(proof, fri_params);
nil::crypto3::marshalling::types::fill_aggregated_proof<Endianness, LPC>(proof);
auto _proof = nil::crypto3::marshalling::types::make_aggregated_proof<Endianness, LPC>(filled_proof);
BOOST_CHECK(proof == _proof);

Expand Down Expand Up @@ -200,7 +197,7 @@ BOOST_FIXTURE_TEST_CASE(lpc_aggregated_proof_test, test_tools::random_test_initi
alg_random_engines.template get_alg_engine<field_type>(),
generic_random_engine
);
test_lpc_aggregated_proof<Endianness, lpc_scheme_type>(proof, fri_params);
test_lpc_aggregated_proof<Endianness, lpc_scheme_type>(proof);
}

BOOST_AUTO_TEST_SUITE_END()
Expand Down
6 changes: 3 additions & 3 deletions crypto3/libs/marshalling/zk/test/placeholder_common_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct placeholder_common_data_test_runner {

auto filled_common_data = nil::crypto3::marshalling::types::fill_placeholder_common_data<Endianness, common_data_type>(common_data);
auto _common_data = nil::crypto3::marshalling::types::make_placeholder_common_data<Endianness, common_data_type>(filled_common_data);
BOOST_CHECK(common_data == _common_data);
BOOST_CHECK(common_data == *_common_data);

std::vector<std::uint8_t> cv;
cv.resize(filled_common_data.length(), 0x00);
Expand All @@ -120,7 +120,7 @@ struct placeholder_common_data_test_runner {
auto constructed_val_read = nil::crypto3::marshalling::types::make_placeholder_common_data<Endianness, common_data_type>(
test_val_read
);
BOOST_CHECK(common_data == constructed_val_read);
BOOST_CHECK(common_data == *constructed_val_read);
}

bool run_test()
Expand Down Expand Up @@ -151,7 +151,7 @@ struct placeholder_common_data_test_runner {
lpc_scheme,
max_quotient_chunks);

test_placeholder_common_data(preprocessed_public_data.common_data);
test_placeholder_common_data(*preprocessed_public_data.common_data);

return true;
}
Expand Down
10 changes: 6 additions & 4 deletions crypto3/libs/marshalling/zk/test/placeholder_proof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ struct placeholder_lpc_proof_test_runner {
test_placeholder_partial_proof(lpc_proof, fri_params);

auto verifier_res = placeholder_verifier<field_type, lpc_placeholder_params_type>::process(
lpc_preprocessed_public_data.common_data, lpc_proof, desc, constraint_system, lpc_scheme
*lpc_preprocessed_public_data.common_data, lpc_proof, desc, constraint_system, lpc_scheme
);

/*
Expand All @@ -195,6 +195,7 @@ struct placeholder_lpc_proof_test_runner {
}

using PlaceholderParams = lpc_placeholder_params_type;

using ProofType = placeholder_proof<typename PlaceholderParams::field_type, PlaceholderParams>;
using CommitmentParamsType = typename lpc_type::fri_type::params_type;

Expand Down Expand Up @@ -263,8 +264,7 @@ struct placeholder_lpc_proof_test_runner {
using TTypeBase = nil::crypto3::marshalling::field_type<Endianness>;
using proof_marshalling_type = nil::crypto3::marshalling::types::placeholder_aggregated_proof_type<TTypeBase, ProofType>;

auto filled_placeholder_proof = types::fill_placeholder_aggregated_proof<Endianness, AggregatedProofType, ProofType>(
proof, params);
auto filled_placeholder_proof = types::fill_placeholder_aggregated_proof<Endianness, AggregatedProofType, ProofType>(proof);
AggregatedProofType _proof = types::make_placeholder_aggregated_proof<
Endianness, AggregatedProofType, ProofType>(filled_placeholder_proof);
BOOST_CHECK(_proof == proof);
Expand Down Expand Up @@ -593,8 +593,10 @@ struct placeholder_kzg_v2_proof_test_runner : public test_tools::random_test_ini
using Endianness = nil::crypto3::marshalling::option::big_endian;

test_placeholder_proof(kzg_proof, kzg_params);

kzg_scheme = kzg_scheme_type(kzg_params);
bool verifier_res = placeholder_verifier<field_type, kzg_placeholder_params_type>::process(
kzg_preprocessed_public_data.common_data, kzg_proof, desc, constraint_system, kzg_scheme);
*kzg_preprocessed_public_data.common_data, kzg_proof, desc, constraint_system, kzg_scheme);
BOOST_CHECK(verifier_res);
return true;
}
Expand Down
37 changes: 19 additions & 18 deletions crypto3/libs/transpiler/test/evm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie

auto printer = nil::blueprint::lpc_evm_verifier_printer<lpc_placeholder_params_type>(
constraint_system,
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
output
);
printer.print();
Expand Down Expand Up @@ -432,7 +432,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie
);

auto verifier_res = placeholder_verifier<field_type, lpc_placeholder_params_type>::process(
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
lpc_proof,
desc,
constraint_system,
Expand Down Expand Up @@ -512,7 +512,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie

auto printer = nil::blueprint::lpc_evm_verifier_printer<lpc_placeholder_params_type>(
constraint_system,
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
output
);
printer.print();
Expand Down Expand Up @@ -548,7 +548,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie
);

auto verifier_res = placeholder_verifier<field_type, lpc_placeholder_params_type>::process(
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
lpc_proof,
desc,
constraint_system,
Expand Down Expand Up @@ -632,7 +632,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie

auto printer = nil::blueprint::lpc_evm_verifier_printer<lpc_placeholder_params_type>(
constraint_system,
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
output
);
printer.print();
Expand Down Expand Up @@ -668,7 +668,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie
);

auto verifier_res = placeholder_verifier<field_type, lpc_placeholder_params_type>::process(
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
lpc_proof,
desc,
constraint_system,
Expand Down Expand Up @@ -751,7 +751,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie

auto printer = nil::blueprint::lpc_evm_verifier_printer<lpc_placeholder_params_type>(
constraint_system,
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
output
);
printer.print();
Expand Down Expand Up @@ -787,7 +787,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie
);

auto verifier_res = placeholder_verifier<field_type, lpc_placeholder_params_type>::process(
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
lpc_proof,
desc,
constraint_system,
Expand Down Expand Up @@ -870,7 +870,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie

auto printer = nil::blueprint::lpc_evm_verifier_printer<lpc_placeholder_params_type>(
constraint_system,
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
output
);
printer.print();
Expand Down Expand Up @@ -906,7 +906,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie
);

auto verifier_res = placeholder_verifier<field_type, lpc_placeholder_params_type>::process(
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
lpc_proof,
desc,
constraint_system,
Expand Down Expand Up @@ -952,7 +952,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test100, test_tools::random_test_initializer<

auto printer = nil::blueprint::lpc_evm_verifier_printer<lpc_placeholder_params_type>(
constraint_system,
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
output
);
printer.print();
Expand Down Expand Up @@ -988,7 +988,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test100, test_tools::random_test_initializer<
);

auto verifier_res = placeholder_verifier<field_type, lpc_placeholder_params_type>::process(
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
lpc_proof,
desc,
constraint_system,
Expand Down Expand Up @@ -1070,7 +1070,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie

auto printer = nil::blueprint::lpc_evm_verifier_printer<lpc_placeholder_params_type>(
constraint_system,
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
output
);
printer.print();
Expand Down Expand Up @@ -1106,7 +1106,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie
);

auto verifier_res = placeholder_verifier<field_type, lpc_placeholder_params_type>::process(
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
lpc_proof,
desc,
constraint_system,
Expand Down Expand Up @@ -1187,7 +1187,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie

auto printer = nil::blueprint::lpc_evm_verifier_printer<lpc_placeholder_params_type>(
constraint_system,
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
output
);
printer.print();
Expand Down Expand Up @@ -1223,7 +1223,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie
);

auto verifier_res = placeholder_verifier<field_type, lpc_placeholder_params_type>::process(
lpc_preprocessed_public_data.common_data,
*lpc_preprocessed_public_data.common_data,
lpc_proof,
desc,
constraint_system,
Expand Down Expand Up @@ -1359,7 +1359,7 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie

auto printer = nil::blueprint::kzg_evm_verifier_printer<kzg_placeholder_params_type>(
constraint_system,
kzg_preprocessed_public_data.common_data,
*kzg_preprocessed_public_data.common_data,
output
);
printer.print();
Expand Down Expand Up @@ -1389,8 +1389,9 @@ BOOST_FIXTURE_TEST_CASE(transpiler_test, test_tools::random_test_initializer<fie
output + "/" + public_input_filename
);

kzg_scheme = kzg_scheme_type(kzg_params);
oclaw marked this conversation as resolved.
Show resolved Hide resolved
bool verifier_res = placeholder_verifier<field_type, kzg_placeholder_params_type>::process(
kzg_preprocessed_public_data.common_data,
*kzg_preprocessed_public_data.common_data,
kzg_proof,
desc,
constraint_system,
Expand Down
Loading