From c6a32f967924da695dfb9210330c59c84822d5aa Mon Sep 17 00:00:00 2001 From: akokoshn Date: Wed, 6 Mar 2024 08:44:26 +0200 Subject: [PATCH] Pure private input or eq example --- examples/CMakeLists.txt | 52 ++++++++++++++++++++++-------------- examples/cpp/CMakeLists.txt | 13 ++++++--- examples/rust/CMakeLists.txt | 4 +-- 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 76f7e54..54862c8 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -8,6 +8,10 @@ function(assign_ir target binary_name input private_input curve_type max_num_pro set(max_num_provers_amount ${max_num_provers_amount}) endif() + if(NOT input STREQUAL "") + set (minus_i -i) + set(input_string ${INPUTS_DIR}/${input}) + endif() if(NOT private_input STREQUAL "") set (minus_p -p) set(private_input_string ${INPUTS_DIR}/${private_input}) @@ -27,7 +31,7 @@ function(assign_ir target binary_name input private_input curve_type max_num_pro add_custom_target(${target}_generate_both COMMAND $ -b ${binary_name} - -i ${INPUTS_DIR}/${input} + ${minus_i} ${input_string} ${minus_p} ${private_input_string} -c circuit_${target}.crct -t assignment_${target}.tbl -e ${curve_type} --check @@ -40,7 +44,7 @@ function(assign_ir target binary_name input private_input curve_type max_num_pro add_custom_target(${target}_generate_tbl COMMAND $ -b ${binary_name} - -i ${INPUTS_DIR}/${input} + ${minus_i} ${input_string} ${minus_p} ${private_input_string} -t assignment_${target}.tbl -e ${curve_type} --check --generate-type assignment @@ -59,28 +63,36 @@ function(assign_ir target binary_name input private_input curve_type max_num_pro COMMAND_EXPAND_LISTS VERBATIM) - add_custom_target(${target}_prepare_input - COMMAND $ - -b ${binary_name} - -i ${INPUTS_DIR}/${input} - --generate-type public-input-column - --input-column ${target}_input_column.inp - -e ${curve_type} - DEPENDS ${target} ${INPUTS_DIR}/${input} - COMMAND_EXPAND_LISTS - VERBATIM) + if(NOT input STREQUAL "") + add_custom_target(${target}_prepare_input + COMMAND $ + -b ${binary_name} + -i ${INPUTS_DIR}/${input} + --generate-type public-input-column + --input-column ${target}_input_column.inp + -e ${curve_type} + DEPENDS ${target} ${INPUTS_DIR}/${input} + COMMAND_EXPAND_LISTS + VERBATIM) + else() + add_custom_target(${target}_prepare_input + COMMAND touch ${target}_input_column.inp + VERBATIM) + endif() + endfunction() -function(gen_proof target input curve_type provers_amount) +function(gen_proof target curve_type provers_amount) + message("TARGET = ${target}, PROVERS = ${provers_amount}") if(provers_amount EQUAL 0) - gen_single_proof(${target} ${input} ${curve_type} 0) + gen_single_proof(${target} ${curve_type} 0) else() add_custom_target(${target}_prove) foreach(prover_num RANGE 1 ${provers_amount}) math(EXPR prover_num_minus_1 "${prover_num} - 1") - gen_single_proof(${target} ${input} ${curve_type} ${prover_num}) + gen_single_proof(${target} ${curve_type} ${prover_num}) add_dependencies(${target}_prove ${target}_prove${prover_num_minus_1}) endforeach() @@ -94,7 +106,7 @@ function(gen_proof target input curve_type provers_amount) endif() endfunction() -function(gen_single_proof target input curve_type provers_amount) +function(gen_single_proof target curve_type provers_amount) if(NOT provers_amount EQUAL 0) set(multi_prover_flag --multi-prover) @@ -115,16 +127,16 @@ function(gen_single_proof target input curve_type provers_amount) VERBATIM) endfunction() -function(gen_evm_verifier target input curve_type provers_amount) +function(gen_evm_verifier target curve_type provers_amount) if(provers_amount EQUAL 0) - gen_single_evm_verifier(${target} ${input} ${curve_type} 0) + gen_single_evm_verifier(${target} ${curve_type} 0) else() add_custom_target(${target}_evm_verifier) foreach(prover_num RANGE 1 ${provers_amount}) math(EXPR prover_num_minus_1 "${prover_num} - 1") - gen_single_evm_verifier(${target} ${input} ${curve_type} ${prover_num}) + gen_single_evm_verifier(${target} ${curve_type} ${prover_num}) add_dependencies(${target}_evm_verifier ${target}_evm_verifier${prover_num_minus_1}) endforeach() @@ -137,7 +149,7 @@ function(gen_evm_verifier target input curve_type provers_amount) add_dependencies(${target}_evm_verifier ${target}_copy_input_for_evm_verifier) endfunction() -function(gen_single_evm_verifier target input curve_type provers_amount) +function(gen_single_evm_verifier target curve_type provers_amount) if(NOT provers_amount EQUAL 0) set(multi_prover_flag --multi-prover) diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt index 70abcc5..b7a5ef0 100644 --- a/examples/cpp/CMakeLists.txt +++ b/examples/cpp/CMakeLists.txt @@ -55,7 +55,11 @@ function(add_example_without_proving example_target) if(DEFINED ARG_MAX_NUM_PROVERS) assign_ir(${example_target} ${binary_name} ${ARG_INPUT} ${ARG_PRIVATE_INPUT} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS}) else() - assign_ir(${example_target} ${binary_name} ${ARG_INPUT} ${ARG_PRIVATE_INPUT} ${ARG_CURVE_TYPE} 0) + if(DEFINED ARG_INPUT) + assign_ir(${example_target} ${binary_name} ${ARG_INPUT} ${ARG_PRIVATE_INPUT} ${ARG_CURVE_TYPE} 0) + else() + assign_ir(${example_target} ${binary_name} "" ${ARG_PRIVATE_INPUT} ${ARG_CURVE_TYPE} 0) + endif() endif() else() if(DEFINED ARG_MAX_NUM_PROVERS) @@ -88,11 +92,12 @@ function(add_example_with_proving example_target) set(ARG_MAX_NUM_PROVERS 0) endif() - gen_proof(${example_target} ${ARG_INPUT} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS}) + gen_proof(${example_target} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS}) + add_dependencies(prove_cpp_examples ${example_target}_prove) if(GENERATE_EVM_VERIFIER) - gen_evm_verifier(${example_target} ${ARG_INPUT} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS}) + gen_evm_verifier(${example_target} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS}) add_dependencies(prove_cpp_examples ${example_target}_evm_verifier) endif() @@ -138,7 +143,7 @@ add_example_with_proving(uint_bit_decomposition SOURCES bit_operations/bit_decom add_example_with_proving(uint_bit_composition SOURCES bit_operations/bit_composition.cpp INPUT bit_operations/bit_composition.inp CURVE_TYPE pallas) add_example_with_proving(compare_neq_cpp SOURCES compare/neq.cpp INPUT compare/neq.inp CURVE_TYPE pallas) -add_example_with_proving(compare_eq_cpp SOURCES compare/eq.cpp INPUT compare/eq.inp CURVE_TYPE pallas) +add_example_with_proving(compare_eq_cpp SOURCES compare/eq.cpp PRIVATE_INPUT compare/eq.inp CURVE_TYPE pallas) # Comparison component is disabled due to issue with negative numbers, so we can't prove an empty circuit add_example_without_proving(compare_grequal_cpp SOURCES compare/grequal.cpp INPUT compare/grequal.inp CURVE_TYPE pallas) add_example_without_proving(compare_lequal_cpp SOURCES compare/lequal.cpp INPUT compare/lequal.inp CURVE_TYPE pallas) diff --git a/examples/rust/CMakeLists.txt b/examples/rust/CMakeLists.txt index 057984d..7de8021 100644 --- a/examples/rust/CMakeLists.txt +++ b/examples/rust/CMakeLists.txt @@ -72,11 +72,11 @@ function(add_rust_example_with_proving example_target) set(ARG_MAX_NUM_PROVERS 0) endif() - gen_proof(${example_target} ${ARG_INPUT} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS}) + gen_proof(${example_target} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS}) add_dependencies(prove_rust_examples ${example_target}_prove) if(GENERATE_EVM_VERIFIER) - gen_evm_verifier(${example_target} ${ARG_INPUT} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS}) + gen_evm_verifier(${example_target} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS}) add_dependencies(prove_rust_examples ${example_target}_evm_verifier) endif() -- 2.25.1