From 417927a8b5eb6ba6ed2a48c0f0b53cd51a5b8e8e Mon Sep 17 00:00:00 2001 From: Aleksandr Cherenkov Date: Wed, 7 Feb 2024 18:14:49 +0000 Subject: [PATCH] add initial examples from zkllvm --- .github/workflows/main.yml | 28 ++++++++++++++++++---------- CMakeLists.txt | 2 ++ src/CMakeLists.txt | 12 ++++++++++-- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5c16781..900431c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,25 +53,33 @@ jobs: - name: Configure CMake env: BOOST_ROOT: "${{ steps.install-boost.outputs.BOOST_ROOT }}" - run: cmake -G "Unix Makefiles" -B ${ZKLLVM_BUILD:-build} -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang-zkllvm . + run: cmake -G "Unix Makefiles" -B ${ZKLLVM_BUILD:-build} -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang-zkllvm -DCI_RUN=TRUE . - - name: Compile circuit + - name: Compile main.cpp circuit run: make -C ${ZKLLVM_BUILD:-build} template - - name: Build circuit file and assignment table + - name: Build main.cpp circuit file and assignment table run: assigner -b build/src/template.ll -i src/public-input.json -p src/private-input.json --circuit template.crct --assignment-table template.tbl -e pallas - - name: Generate proof + - name: Generate main.cpp proof run: proof-generator-single-threaded --circuit="template.crct" --assignment-table="template.tbl" --proof="proof.bin" - # - name: Compile a circuit in IR format - # run: scripts/run.sh --verbose --docker compile + - name: Generate main.cpp proof + run: proof-generator-single-threaded --circuit="template.crct" --assignment-table="template.tbl" --proof="proof.bin" + + + - name: Clone zkllvm repository + run: git clone https://github.com/NilFoundation/zkLLVM.git + + + - name: Compile arithmetics example + run: make -C ${ZKLLVM_BUILD:-build} arithmetics_cpp_example - # - name: Build a binary circuit and assignment table - # run: scripts/run.sh --verbose --docker run_assigner + - name: Build arithmetics circuit file and assignment table + run: assigner -b build/src/arithmetics_cpp_example.ll -i zkLLVM/examples/inputs/arithmetics.inp --circuit arithmetics_cpp_example.crct --assignment-table arithmetics_cpp_example.tbl -e pallas - # - name: Calculate a proof - # run: scripts/run.sh --verbose --docker prove + - name: Generate arithmetics proof + run: proof-generator-single-threaded --circuit="arithmetics_cpp_example.crct" --assignment-table="arithmetics_cpp_example.tbl" --proof="arithmetics_cpp_example.bin" # - name: Build circuit parameters for EVM verifier endpoint # run: scripts/run.sh --verbose --docker build_circuit_params diff --git a/CMakeLists.txt b/CMakeLists.txt index 05e304d..c75d961 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,8 @@ include(CircuitCompile) cm_workspace(crypto3) +option(CI_RUN "Enable examples for CI run" FALSE) + macro(cm_find_package NAME) if(NOT "${NAME}" MATCHES "^${CMAKE_WORKSPACE_NAME}_.*$" AND NOT "${NAME}" STREQUAL CM) find_package(${ARGV}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e4dc54b..a3c52c7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ function(add_example example_target) set(prefix ARG) set(noValues "") - set(singleValues INPUT) + set(singleValues) set(multiValues SOURCES) cmake_parse_arguments(${prefix} "${noValues}" @@ -39,4 +39,12 @@ function(add_example example_target) ${Boost_LIBRARIES}) endfunction() -add_example(template SOURCES main.cpp INPUT main.inp) +add_example(template SOURCES main.cpp) + +if(CI_RUN) + add_example(arithmetics_cpp_example SOURCES "../CI/zkLLVM/examples/cpp/arithmetics.cpp") + add_example(ed25519_field_add SOURCES "../CI/zkLLVM/examples/cpp/ed25519_field_add.cpp") + add_example(ed25519_curve_add SOURCES "../CI/zkLLVM/examples/cpp/ed25519_curve_add.cpp") + add_example(sha2_256 SOURCES "../CI/zkLLVM/examples/cpp/sha2_256.cpp") + add_example(merkle_poseidon_1prover SOURCES "../CI/zkLLVM/examples/cpp/merkle_poseidon_1prover.cpp") +endif()