Skip to content

Commit 917b5cc

Browse files
akokoshnakokoshn
authored andcommitted
Pass arithmetization parameters to the cmake function assigner_ir
1 parent d0bfb78 commit 917b5cc

File tree

5 files changed

+66
-43
lines changed

5 files changed

+66
-43
lines changed

bin/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ set(WITNESS_COLUMNS 15 CACHE STRING "Number of witness columns")
3434
set(PUBLIC_INPUT_COLUMNS 1 CACHE STRING "Number of public input columns")
3535
set(COMPONENT_CONSTANT_COLUMNS 5 CACHE STRING "Number of component constant columns")
3636
set(LOOKUP_CONSTANT_COLUMNS 30 CACHE STRING "Number of lookup constant columns")
37-
set(COMPONENT_SELECTOR_COLUMNS 50 CACHE STRING "Number of lookup selector columns")
37+
set(COMPONENT_SELECTOR_COLUMNS 50 CACHE STRING "Number of component selector columns")
3838
set(LOOKUP_SELECTOR_COLUMNS 6 CACHE STRING "Number of lookup selector columns")
3939
set(SECURITY_PARAMETER_LAMBDA 9 CACHE STRING "Number of FRI queries")
4040
set(SECURITY_PARAMETER_GRINDING_BITS 0 CACHE STRING "Number of FRI grinding bits")

bin/assigner/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ int main(int argc, char *argv[]) {
838838
if (vm.count("max-num-provers")) {
839839
max_num_provers = vm["max-num-provers"].as<int>();
840840
if (max_num_provers < 1) {
841-
std::cerr << "Invalid command line argument - max-num-provers. " << max_num_provers << " is wrong value." << std::endl;
841+
std::cerr << "Invalid command line argument --max-num-provers. " << max_num_provers << " is wrong value." << std::endl;
842842
std::cout << options_desc << std::endl;
843843
return 1;
844844
}

examples/CMakeLists.txt

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
set(INPUTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inputs)
22

33
#generate assignment table and circuit
4-
function(assign_ir target binary_name input private_input curve_type max_num_provers_amount)
4+
function(assign_ir)
5+
list(POP_FRONT ARGV target)
6+
list(POP_FRONT ARGV binary_name)
7+
list(POP_FRONT ARGV input)
8+
list(POP_FRONT ARGV private_input)
9+
list(POP_FRONT ARGV curve_type)
10+
list(POP_FRONT ARGV arithmetization)
11+
if(NOT arithmetization STREQUAL "none")
12+
set(witness_cols ${arithmetization})
13+
list(POP_FRONT ARGV public_input_cols)
14+
list(POP_FRONT ARGV component_constant_cols)
15+
list(POP_FRONT ARGV lookup_constant_cols)
16+
list(POP_FRONT ARGV component_selector_cols)
17+
list(POP_FRONT ARGV lookup_selector_cols)
18+
set(arithmetization_flag --column-sizes)
19+
set(arithmetization_amount ${witness_cols} ${public_input_cols} ${component_constant_cols} ${lookup_constant_cols} ${component_selector_cols} ${lookup_selector_cols})
20+
endif()
21+
list(POP_FRONT ARGV max_num_provers_amount)
522

623
if(NOT max_num_provers_amount EQUAL 0)
724
set(max_num_provers_flag --max-num-provers)
825
set(max_num_provers_amount ${max_num_provers_amount})
926
endif()
1027

11-
if(NOT private_input STREQUAL "")
12-
set (minus_p -p)
28+
if(NOT private_input STREQUAL "none")
29+
set(minus_p -p)
1330
set(private_input_string ${INPUTS_DIR}/${private_input})
1431
endif()
1532

@@ -20,6 +37,7 @@ function(assign_ir target binary_name input private_input curve_type max_num_pro
2037
-e ${curve_type}
2138
--generate-type circuit
2239
${max_num_provers_flag} ${max_num_provers_amount}
40+
${arithmetization_flag} ${arithmetization_amount}
2341
DEPENDS ${target} $<TARGET_FILE:assigner>
2442
COMMAND_EXPAND_LISTS
2543
VERBATIM)
@@ -33,6 +51,7 @@ function(assign_ir target binary_name input private_input curve_type max_num_pro
3351
-t assignment_${target}.tbl -e ${curve_type} --check
3452
--generate-type circuit-assignment
3553
${max_num_provers_flag} ${max_num_provers_amount}
54+
${arithmetization_flag} ${arithmetization_amount}
3655
DEPENDS ${target} ${INPUTS_DIR}/${input} $<TARGET_FILE:assigner>
3756
COMMAND_EXPAND_LISTS
3857
VERBATIM)
@@ -45,6 +64,7 @@ function(assign_ir target binary_name input private_input curve_type max_num_pro
4564
-t assignment_${target}.tbl -e ${curve_type} --check
4665
--generate-type assignment
4766
${max_num_provers_flag} ${max_num_provers_amount}
67+
${arithmetization_flag} ${arithmetization_amount}
4868
DEPENDS ${target} ${INPUTS_DIR}/${input} $<TARGET_FILE:assigner>
4969
COMMAND_EXPAND_LISTS
5070
VERBATIM)
@@ -55,6 +75,7 @@ function(assign_ir target binary_name input private_input curve_type max_num_pro
5575
-e ${curve_type}
5676
--generate-type size_estimation
5777
${max_num_provers_flag} ${max_num_provers_amount}
78+
${arithmetization_flag} ${arithmetization_amount}
5879
DEPENDS ${target} $<TARGET_FILE:assigner>
5980
COMMAND_EXPAND_LISTS
6081
VERBATIM)
@@ -66,21 +87,22 @@ function(assign_ir target binary_name input private_input curve_type max_num_pro
6687
--generate-type public-input-column
6788
--input-column ${target}_input_column.inp
6889
-e ${curve_type}
90+
${arithmetization_flag} ${arithmetization_amount}
6991
DEPENDS ${target} ${INPUTS_DIR}/${input}
7092
COMMAND_EXPAND_LISTS
7193
VERBATIM)
7294
endfunction()
7395

74-
function(gen_proof target input curve_type provers_amount)
96+
function(gen_proof target curve_type provers_amount)
7597

7698
if(provers_amount EQUAL 0)
77-
gen_single_proof(${target} ${input} ${curve_type} 0)
99+
gen_single_proof(${target} ${curve_type} 0)
78100
else()
79101
add_custom_target(${target}_prove)
80102

81103
foreach(prover_num RANGE 1 ${provers_amount})
82104
math(EXPR prover_num_minus_1 "${prover_num} - 1")
83-
gen_single_proof(${target} ${input} ${curve_type} ${prover_num})
105+
gen_single_proof(${target} ${curve_type} ${prover_num})
84106
add_dependencies(${target}_prove ${target}_prove${prover_num_minus_1})
85107
endforeach()
86108

@@ -94,7 +116,7 @@ function(gen_proof target input curve_type provers_amount)
94116
endif()
95117
endfunction()
96118

97-
function(gen_single_proof target input curve_type provers_amount)
119+
function(gen_single_proof target curve_type provers_amount)
98120

99121
if(NOT provers_amount EQUAL 0)
100122
set(multi_prover_flag --multi-prover)
@@ -115,16 +137,16 @@ function(gen_single_proof target input curve_type provers_amount)
115137
VERBATIM)
116138
endfunction()
117139

118-
function(gen_evm_verifier target input curve_type provers_amount)
140+
function(gen_evm_verifier target curve_type provers_amount)
119141

120142
if(provers_amount EQUAL 0)
121-
gen_single_evm_verifier(${target} ${input} ${curve_type} 0)
143+
gen_single_evm_verifier(${target} ${curve_type} 0)
122144
else()
123145
add_custom_target(${target}_evm_verifier)
124146

125147
foreach(prover_num RANGE 1 ${provers_amount})
126148
math(EXPR prover_num_minus_1 "${prover_num} - 1")
127-
gen_single_evm_verifier(${target} ${input} ${curve_type} ${prover_num})
149+
gen_single_evm_verifier(${target} ${curve_type} ${prover_num})
128150
add_dependencies(${target}_evm_verifier ${target}_evm_verifier${prover_num_minus_1})
129151
endforeach()
130152

@@ -137,7 +159,7 @@ function(gen_evm_verifier target input curve_type provers_amount)
137159
add_dependencies(${target}_evm_verifier ${target}_copy_input_for_evm_verifier)
138160
endfunction()
139161

140-
function(gen_single_evm_verifier target input curve_type provers_amount)
162+
function(gen_single_evm_verifier target curve_type provers_amount)
141163

142164
if(NOT provers_amount EQUAL 0)
143165
set(multi_prover_flag --multi-prover)

examples/cpp/CMakeLists.txt

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ function(add_example_without_proving example_target)
99
set(prefix ARG)
1010
set(noValues "")
1111
set(singleValues INPUT PRIVATE_INPUT CURVE_TYPE MAX_NUM_PROVERS)
12-
set(multiValues SOURCES COMPILER_OPTIONS)
12+
set(multiValues SOURCES COMPILER_OPTIONS ARITHMETIZARION)
1313
cmake_parse_arguments(${prefix}
1414
"${noValues}"
1515
"${singleValues}"
1616
"${multiValues}"
1717
${ARGN})
18+
1819
add_circuit(${example_target}
1920
SOURCES ${ARG_SOURCES}
2021
COMPILER_OPTIONS ${ARG_COMPILER_OPTIONS}
@@ -51,20 +52,20 @@ function(add_example_without_proving example_target)
5152

5253
add_dependencies(compile_cpp_examples ${example_target})
5354

54-
if(DEFINED ARG_PRIVATE_INPUT)
55-
if(DEFINED ARG_MAX_NUM_PROVERS)
56-
assign_ir(${example_target} ${binary_name} ${ARG_INPUT} ${ARG_PRIVATE_INPUT} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS})
57-
else()
58-
assign_ir(${example_target} ${binary_name} ${ARG_INPUT} ${ARG_PRIVATE_INPUT} ${ARG_CURVE_TYPE} 0)
59-
endif()
60-
else()
61-
if(DEFINED ARG_MAX_NUM_PROVERS)
62-
assign_ir(${example_target} ${binary_name} ${ARG_INPUT} "" ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS})
63-
else()
64-
assign_ir(${example_target} ${binary_name} ${ARG_INPUT} "" ${ARG_CURVE_TYPE} 0)
65-
endif()
55+
if(NOT DEFINED ARG_PRIVATE_INPUT)
56+
set(ARG_PRIVATE_INPUT "none")
57+
endif()
58+
59+
if(NOT DEFINED ARG_MAX_NUM_PROVERS)
60+
set(ARG_MAX_NUM_PROVERS 0)
61+
endif()
62+
63+
if(NOT DEFINED ARG_ARITHMETIZARION)
64+
set(ARG_ARITHMETIZARION "none")
6665
endif()
6766

67+
assign_ir(${example_target} ${binary_name} ${ARG_INPUT} ${ARG_PRIVATE_INPUT} ${ARG_CURVE_TYPE} ${ARG_ARITHMETIZARION} ${ARG_MAX_NUM_PROVERS})
68+
6869
add_dependencies(cpp_examples_generate_tbl ${example_target}_generate_tbl)
6970
add_dependencies(cpp_examples_generate_crct ${example_target}_generate_crct)
7071
add_dependencies(cpp_examples_generate_both ${example_target}_generate_both)
@@ -88,11 +89,11 @@ function(add_example_with_proving example_target)
8889
set(ARG_MAX_NUM_PROVERS 0)
8990
endif()
9091

91-
gen_proof(${example_target} ${ARG_INPUT} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS})
92+
gen_proof(${example_target} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS})
9293
add_dependencies(prove_cpp_examples ${example_target}_prove)
9394

9495
if(GENERATE_EVM_VERIFIER)
95-
gen_evm_verifier(${example_target} ${ARG_INPUT} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS})
96+
gen_evm_verifier(${example_target} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS})
9697
add_dependencies(prove_cpp_examples ${example_target}_evm_verifier)
9798
endif()
9899

@@ -149,7 +150,7 @@ add_example_without_proving(compare_less_than_cpp SOURCES compare/less_than.cpp
149150
add_example_without_proving(balances_tree_cpp_example SOURCES balances_tree.cpp INPUT balances_tree_public.inp PRIVATE_INPUT balances_tree_private.inp CURVE_TYPE pallas)
150151

151152
add_example_without_proving(eddsa_signature_verification_cpp SOURCES eddsa_signature_verification.cpp INPUT eddsa_signature_verification.inp CURVE_TYPE pallas)
152-
add_example_without_proving(zkbridge_cpp SOURCES zkbridge.cpp INPUT zkbridge.inp CURVE_TYPE pallas)
153+
add_example_without_proving(zkbridge_cpp SOURCES zkbridge.cpp INPUT zkbridge.inp CURVE_TYPE pallas ARITHMETIZARION 15 1 5 30 50 6)
153154

154155
add_example_with_proving(private_input_cpp SOURCES private_input.cpp INPUT private_input_public.inp PRIVATE_INPUT private_input_private.inp CURVE_TYPE pallas)
155156
add_example_with_proving(private_input_array_cpp SOURCES private_input_array.cpp INPUT private_input_array_public.inp PRIVATE_INPUT private_input_array_private.inp CURVE_TYPE pallas)

examples/rust/CMakeLists.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ function(add_rust_example_without_proving example_target)
3636

3737
set(binary_name ${EXAMPLES_BINARY_DIR}/${ARG_EXAMPLE_NAME}.ll)
3838

39-
if(DEFINED ARG_PRIVATE_INPUT)
40-
if(DEFINED ARG_MAX_NUM_PROVERS)
41-
assign_ir(${example_target} ${binary_name} ${ARG_INPUT} ${ARG_PRIVATE_INPUT} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS})
42-
else()
43-
assign_ir(${example_target} ${binary_name} ${ARG_INPUT} ${ARG_PRIVATE_INPUT} ${ARG_CURVE_TYPE} 0)
44-
endif()
45-
else()
46-
if(DEFINED ARG_MAX_NUM_PROVERS)
47-
assign_ir(${example_target} ${binary_name} ${ARG_INPUT} "" ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS})
48-
else()
49-
assign_ir(${example_target} ${binary_name} ${ARG_INPUT} "" ${ARG_CURVE_TYPE} 0)
50-
endif()
39+
if(NOT DEFINED ARG_PRIVATE_INPUT)
40+
set(ARG_PRIVATE_INPUT "none")
5141
endif()
5242

43+
if(NOT DEFINED ARG_MAX_NUM_PROVERS)
44+
set(ARG_MAX_NUM_PROVERS 0)
45+
endif()
46+
47+
if(NOT DEFINED ARG_ARITHMETIZARION)
48+
set(ARG_ARITHMETIZARION "none")
49+
endif()
50+
51+
assign_ir(${example_target} ${binary_name} ${ARG_INPUT} ${ARG_PRIVATE_INPUT} ${ARG_CURVE_TYPE} ${ARG_ARITHMETIZARION} ${ARG_MAX_NUM_PROVERS})
52+
5353
add_dependencies(rust_examples_generate_crct ${example_target}_generate_crct)
5454
add_dependencies(rust_examples_generate_tbl ${example_target}_generate_tbl)
5555
add_dependencies(rust_examples_generate_both ${example_target}_generate_both)
@@ -72,11 +72,11 @@ function(add_rust_example_with_proving example_target)
7272
set(ARG_MAX_NUM_PROVERS 0)
7373
endif()
7474

75-
gen_proof(${example_target} ${ARG_INPUT} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS})
75+
gen_proof(${example_target} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS})
7676
add_dependencies(prove_rust_examples ${example_target}_prove)
7777

7878
if(GENERATE_EVM_VERIFIER)
79-
gen_evm_verifier(${example_target} ${ARG_INPUT} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS})
79+
gen_evm_verifier(${example_target} ${ARG_CURVE_TYPE} ${ARG_MAX_NUM_PROVERS})
8080
add_dependencies(prove_rust_examples ${example_target}_evm_verifier)
8181
endif()
8282

0 commit comments

Comments
 (0)