Skip to content

Commit e2e2e91

Browse files
committed
Merge branch 'master' into 127-non-native-parser-compatible-json
2 parents adbb51b + fa9fc44 commit e2e2e91

34 files changed

+112
-102
lines changed

.github/workflows/build_linux.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,18 @@ jobs:
104104
run: |
105105
make -C build assigner clang transpiler -j$(nproc)
106106
107-
- name: Build IR of the examples
107+
- name: Build IR of the C++ examples
108108
run: |
109-
make -C build circuit_examples -j$(nproc)
110-
ls -al ./build/examples
109+
make -C build circuit_cpp_examples -j$(nproc)
110+
ls -al ./build/examples/cpp
111111
112-
- name: Build circuit and assigner of the examples
112+
- name: Build circuit and assigner of the C++ examples
113113
run: |
114-
make -C build assign_examples -j$(nproc)
114+
make -C build assign_cpp_examples -j$(nproc)
115115
116-
- name: Build proof for the circuit of the examples
116+
- name: Build proof for the circuit of the C++ examples
117117
run: |
118-
make -C build prove_examples -j$(nproc)
118+
make -C build prove_cpp_examples -j$(nproc)
119119
120120
- name: Build rslang
121121
run: |

.github/workflows/build_macos.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ jobs:
7676
run: |
7777
make -C build assigner clang transpiler -j$(sysctl -n hw.logicalcpu)
7878
79-
- name: Build IR of the examples
79+
- name: Build IR of the C++ examples
8080
run: |
81-
make -C build circuit_examples -j$(sysctl -n hw.logicalcpu)
82-
ls -al ./build/examples
81+
make -C build circuit_cpp_examples -j$(sysctl -n hw.logicalcpu)
82+
ls -al ./build/examples/cpp
8383
84-
- name: Build circuit and assigner of the examples
84+
- name: Build circuit and assigner of the C++ examples
8585
run: |
86-
make -C build assign_examples -j$(sysctl -n hw.logicalcpu)
86+
make -C build assign_cpp_examples -j$(sysctl -n hw.logicalcpu)
8787
88-
- name: Build proof for the circuit of the examples
88+
- name: Build proof for the circuit of the C++ examples
8989
run: |
90-
make -C build prove_examples -j$(sysctl -n hw.logicalcpu)
90+
make -C build prove_cpp_examples -j$(sysctl -n hw.logicalcpu)

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ Users can generate & inspect intermediate artifacts such as execution trace by r
186186
#### Linux
187187

188188
```bash
189-
make -C ${ZKLLVM_BUILD:-build} circuit_examples -j$(nproc)
190-
${ZKLLVM_BUILD:-build}/bin/assigner/assigner -b ${ZKLLVM_BUILD:-build}/examples/arithmetics_example.bc -i examples/arithmetics.inp -t assignment.tbl -c circuit.crct -e pallas
189+
make -C ${ZKLLVM_BUILD:-build} circuit_cpp_examples -j$(nproc)
190+
${ZKLLVM_BUILD:-build}/bin/assigner/assigner -b ${ZKLLVM_BUILD:-build}/examples/cpp/arithmetics_example.bc -i examples/inputs/arithmetics.inp -t assignment.tbl -c circuit.crct -e pallas
191191
```
192192

193193
#### macOS
194194
```bash
195-
make -C ${ZKLLVM_BUILD:-build} circuit_examples -j$(sysctl -n hw.logicalcpu)
196-
${ZKLLVM_BUILD:-build}/bin/assigner/assigner -b ${ZKLLVM_BUILD:-build}/examples/arithmetics_example.bc -i examples/arithmetics.inp -t assignment.tbl -c circuit.crct -e pallas
195+
make -C ${ZKLLVM_BUILD:-build} circuit_cpp_examples -j$(sysctl -n hw.logicalcpu)
196+
${ZKLLVM_BUILD:-build}/bin/assigner/assigner -b ${ZKLLVM_BUILD:-build}/examples/cpp/arithmetics_example.bc -i examples/inputs/arithmetics.inp -t assignment.tbl -c circuit.crct -e pallas
197197
```
198198

199199
### Validating the circuit
@@ -203,12 +203,12 @@ You can also run the `assigner` with `--check` flag to validate the satisfiabili
203203
#### Linux
204204

205205
```bash
206-
make -C ${ZKLLVM_BUILD:-build} circuit_examples -j$(nproc)
207-
${ZKLLVM_BUILD:-build}/bin/assigner/assigner -b ${ZKLLVM_BUILD:-build}/examples/arithmetics_example.bc -i examples/arithmetics.inp -t assignment.tbl -c circuit.crct -e pallas --check
206+
make -C ${ZKLLVM_BUILD:-build} circuit_cpp_examples -j$(nproc)
207+
${ZKLLVM_BUILD:-build}/bin/assigner/assigner -b ${ZKLLVM_BUILD:-build}/examples/cpp/arithmetics_example.bc -i examples/inputs/arithmetics.inp -t assignment.tbl -c circuit.crct -e pallas --check
208208
```
209209

210210
#### macOS
211211
```bash
212-
make -C ${ZKLLVM_BUILD:-build} circuit_examples -j$(sysctl -n hw.logicalcpu)
213-
${ZKLLVM_BUILD:-build}/bin/assigner/assigner -b ${ZKLLVM_BUILD:-build}/examples/arithmetics_example.bc -i examples/arithmetics.inp -t assignment.tbl -c circuit.crct -e pallas --check
212+
make -C ${ZKLLVM_BUILD:-build} circuit_cpp_examples -j$(sysctl -n hw.logicalcpu)
213+
${ZKLLVM_BUILD:-build}/bin/assigner/assigner -b ${ZKLLVM_BUILD:-build}/examples/cpp/arithmetics_example.bc -i examples/inputs/arithmetics.inp -t assignment.tbl -c circuit.crct -e pallas --check
214214
```

examples/CMakeLists.txt

Lines changed: 11 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,19 @@
1-
add_custom_target(circuit_examples)
2-
add_custom_target(assign_examples)
3-
add_custom_target(prove_examples)
1+
set(INPUTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inputs)
42

5-
function(add_example example_target)
6-
set(prefix ARG)
7-
set(noValues "")
8-
set(singleValues INPUT)
9-
set(multiValues SOURCES)
10-
cmake_parse_arguments(${prefix}
11-
"${noValues}"
12-
"${singleValues}"
13-
"${multiValues}"
14-
${ARGN})
15-
add_circuit(${example_target}
16-
SOURCES ${ARG_SOURCES}
17-
18-
LINK_LIBRARIES
19-
crypto3::algebra
20-
crypto3::block
21-
crypto3::blueprint
22-
crypto3::codec
23-
crypto3::containers
24-
crypto3::hash
25-
crypto3::kdf
26-
crypto3::mac
27-
marshalling::core
28-
marshalling::crypto3_algebra
29-
marshalling::crypto3_multiprecision
30-
marshalling::crypto3_zk
31-
crypto3::math
32-
crypto3::modes
33-
crypto3::multiprecision
34-
crypto3::passhash
35-
crypto3::pbkdf
36-
crypto3::threshold
37-
crypto3::pkpad
38-
crypto3::pubkey
39-
crypto3::random
40-
crypto3::stream
41-
crypto3::vdf
42-
crypto3::zk
43-
44-
${Boost_LIBRARIES})
45-
add_dependencies(circuit_examples "${example_target}")
46-
47-
if (CIRCUIT_ASSEMBLY_OUTPUT)
48-
set(binary_name ${example_target}.ll)
49-
else()
50-
set(binary_name ${example_target}.bc)
51-
endif()
52-
53-
add_custom_target(${example_target}_assign
54-
COMMAND $<TARGET_FILE:assigner> -b ${binary_name} -i ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_INPUT} -c circuit_${example_target}.crct -t assignment_${example_target}.tbl -e pallas --check
55-
DEPENDS ${example_target} ${ARG_INPUT} $<TARGET_FILE:assigner>
3+
function(assign_ir target binary_name input)
4+
add_custom_target(${target}_assign
5+
COMMAND $<TARGET_FILE:assigner> -b ${binary_name} -i ${INPUTS_DIR}/${input} -c circuit_${target}.crct -t assignment_${target}.tbl -e pallas --check
6+
DEPENDS ${target} ${INPUTS_DIR}/${input} $<TARGET_FILE:assigner>
567
COMMAND_EXPAND_LISTS
578
VERBATIM)
58-
add_dependencies(assign_examples ${example_target}_assign)
9+
endfunction()
5910

60-
add_custom_target(${example_target}_prove
61-
COMMAND $<TARGET_FILE:transpiler> -m gen-test-proof -i ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_INPUT} -c circuit_${example_target}.crct -t assignment_${example_target}.tbl -o .
62-
DEPENDS ${example_target} ${ARG_INPUT} $<TARGET_FILE:transpiler>
11+
function(gen_proof target input)
12+
add_custom_target(${target}_prove
13+
COMMAND $<TARGET_FILE:transpiler> -m gen-test-proof -i ${INPUTS_DIR}/${input} -c circuit_${target}.crct -t assignment_${target}.tbl -o .
14+
DEPENDS ${target}_assign $<TARGET_FILE:transpiler>
6315
COMMAND_EXPAND_LISTS
6416
VERBATIM)
65-
add_dependencies(prove_examples ${example_target}_prove)
6617
endfunction()
6718

68-
add_example(arithmetics_example SOURCES arithmetics.cpp INPUT arithmetics.inp)
69-
add_example(integer_arithmetics_example SOURCES integer_arithmetics.cpp INPUT integer_arithmetics.inp)
70-
add_example(poseidon_example SOURCES poseidon.cpp INPUT poseidon.inp)
71-
add_example(merkle_tree_poseidon_example SOURCES merkle_tree_poseidon.cpp INPUT merkle_tree_poseidon.inp)
72-
add_example(merkle_tree_sha2_256_example SOURCES merkle_tree_sha2_256.cpp INPUT merkle_tree_sha2_256.inp)
73-
add_example(sha256_example SOURCES sha2_256.cpp INPUT sha2_256.inp)
74-
add_example(balance_example SOURCES balance.cpp INPUT balance.inp)
75-
add_example(memory_example SOURCES memory.cpp INPUT memory.inp)
76-
add_example(polynomial_example SOURCES polynomial.cpp INPUT polynomial.inp)
77-
add_example(pallas_curve_addition_example
78-
SOURCES pallas_curve_examples/pallas_curve_add.cpp
79-
INPUT pallas_curve_examples/pallas_curve_add.inp)
80-
add_example(pallas_curve_multiplication_example
81-
SOURCES pallas_curve_examples/pallas_curve_mul.cpp
82-
INPUT pallas_curve_examples/pallas_curve_mul.inp)
83-
add_example(pallas_curve_mul_add_example
84-
SOURCES pallas_curve_examples/pallas_curve_mul_add.cpp
85-
INPUT pallas_curve_examples/pallas_curve_mul_add.inp)
86-
# add_example(ed25519_curve_add SOURCES ed25519_curve_add.cpp INPUT ed25519_curve_add.inp)
87-
add_example(strlen_example SOURCES strlen.cpp INPUT strlen.inp)
88-
add_example(ed25519_field_add SOURCES ed25519_field_add.cpp INPUT ed25519_field_add.inp)
19+
add_subdirectory(cpp)

examples/cpp/CMakeLists.txt

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
add_custom_target(circuit_cpp_examples)
2+
add_custom_target(assign_cpp_examples)
3+
add_custom_target(prove_cpp_examples)
4+
5+
function(add_example example_target)
6+
set(prefix ARG)
7+
set(noValues "")
8+
set(singleValues INPUT)
9+
set(multiValues SOURCES)
10+
cmake_parse_arguments(${prefix}
11+
"${noValues}"
12+
"${singleValues}"
13+
"${multiValues}"
14+
${ARGN})
15+
add_circuit(${example_target}
16+
SOURCES ${ARG_SOURCES}
17+
18+
LINK_LIBRARIES
19+
crypto3::algebra
20+
crypto3::block
21+
crypto3::blueprint
22+
crypto3::codec
23+
crypto3::containers
24+
crypto3::hash
25+
crypto3::kdf
26+
crypto3::mac
27+
marshalling::core
28+
marshalling::crypto3_algebra
29+
marshalling::crypto3_multiprecision
30+
marshalling::crypto3_zk
31+
crypto3::math
32+
crypto3::modes
33+
crypto3::multiprecision
34+
crypto3::passhash
35+
crypto3::pbkdf
36+
crypto3::threshold
37+
crypto3::pkpad
38+
crypto3::pubkey
39+
crypto3::random
40+
crypto3::stream
41+
crypto3::vdf
42+
crypto3::zk
43+
44+
${Boost_LIBRARIES})
45+
add_dependencies(circuit_cpp_examples "${example_target}")
46+
47+
if (CIRCUIT_ASSEMBLY_OUTPUT)
48+
set(binary_name ${example_target}.ll)
49+
else()
50+
set(binary_name ${example_target}.bc)
51+
endif()
52+
53+
assign_ir(${example_target} ${binary_name} ${ARG_INPUT})
54+
add_dependencies(assign_cpp_examples ${example_target}_assign)
55+
56+
gen_proof(${example_target} ${ARG_INPUT})
57+
add_dependencies(prove_cpp_examples ${example_target}_prove)
58+
endfunction()
59+
60+
add_example(arithmetics_cpp_example SOURCES arithmetics.cpp INPUT arithmetics.inp)
61+
add_example(integer_arithmetics_cpp_example SOURCES integer_arithmetics.cpp INPUT integer_arithmetics.inp)
62+
add_example(poseidon_cpp_example SOURCES poseidon.cpp INPUT poseidon.inp)
63+
add_example(merkle_tree_poseidon_cpp_example SOURCES merkle_tree_poseidon.cpp INPUT merkle_tree_poseidon.inp)
64+
add_example(merkle_tree_sha2_256_cpp_example SOURCES merkle_tree_sha2_256.cpp INPUT merkle_tree_sha2_256.inp)
65+
add_example(sha256_cpp_example SOURCES sha2_256.cpp INPUT sha2_256.inp)
66+
add_example(balance_cpp_example SOURCES balance.cpp INPUT balance.inp)
67+
add_example(memory_cpp_example SOURCES memory.cpp INPUT memory.inp)
68+
add_example(polynomial_cpp_example SOURCES polynomial.cpp INPUT polynomial.inp)
69+
add_example(pallas_curve_addition_cpp_example
70+
SOURCES pallas_curve_examples/pallas_curve_add.cpp
71+
INPUT pallas_curve_examples/pallas_curve_add.inp)
72+
#add_example(pallas_curve_multiplication_cpp_example
73+
# SOURCES pallas_curve_examples/pallas_curve_mul.cpp
74+
# INPUT pallas_curve_examples/pallas_curve_mul.inp)
75+
#add_example(pallas_curve_mul_add_cpp_example
76+
# SOURCES pallas_curve_examples/pallas_curve_mul_add.cpp
77+
# INPUT pallas_curve_examples/pallas_curve_mul_add.inp)
78+
add_example(ed25519_curve_add_cpp SOURCES ed25519_curve_add.cpp INPUT ed25519_curve_add.inp)
79+
add_example(strlen_cpp_example SOURCES strlen.cpp INPUT strlen.inp)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)