Coder Social home page Coder Social logo

zkllvm-template's Introduction

Tutorial check

zkLLVM Tutorial and Template Project

This repository serves as both a tutorial and a template project for creating an application based on the zkLLVM toolchain. Use it to learn about developing zk-enabled apps with zkLLVM step-by-step.

Prerequisites

For this tutorial, ensure you have an amd64 machine equipped with Docker or Podman (Linux) or Docker Desktop (macOS). For Windows users, Docker in WSL is recommended. While Docker Desktop may work on Windows, it is not officially supported in this tutorial.

Table of Contents

Introduction

This tutorial is structured into sequential steps, each executed as a command within the scripts/run.sh script. For first-time users, we strongly recommend utilizing this script.

After completing the tutorial, you can revisit the steps by manually executing commands in the console. Detailed explanations of commands, parameters, file formats, and more can be found under the ๐Ÿงฐ [manual mode] sections in the collapsed blocks.

Getting started

1. Repository setup

Begin by cloning the repository and its submodules:

git clone --recurse-submodules https://github.com/NilFoundation/zkllvm-template.git
cd zkllvm-template

If you initially cloned without --recurse-submodules, update submodules explicitly:

git submodule update --init --recursive

2. Toolchain installation

zkLLVM is distributed as a deb package, so you can install it using the following commands (Ubuntu 20.04):

echo 'deb [trusted=yes]  http://deb.nil.foundation/ubuntu/ all main' >>/etc/apt/sources.list
apt update
apt install -y zkllvm proof-producer

The packages cmake and libboost-all-dev are required for building the template project:

apt install -y cmake libboost-all-dev

For the additional installation options, check our docs.

Circuit development workflow

In the first part of this tutorial, we'll walk through the development workflow of a circuit developer. Most operations will be done on a local machine, without using the Proof Market. We will build a circuit, pack it into a circuit statement, and then use it to build a proof for a particular input. Last thing, we'll post the statement on the Proof Market, so that zk application developers will be able to request proofs with this statement.

Code in ./src implements the logic of a storage proof on Ethereum by validating Merkle Tree path of the commited data. It reuses algorithms and data structures from the the Crypto3 C++ high efficiency cryptography library.

Step 0: Check the toolchain versions

To check the versions of the tools that we will use, run the following commands:

assigner --version
clang-zkllvm --version
proof-generator-multi-threaded --version
proof-generator-single-threaded --version

Steps 1-3: Let script perform steps 1-3

bash scripts/run.sh

or run them manually:

Step 1: Configure the project and compile the circuit

In ./src/main.cpp, we have a function starting with [[circuit]]. This code definition is what we call the circuit itself. We will use zkLLVM compiler to make a byte-code representation of this circuit.

Run the commands from the root of your project.

Configure the project with cmake:

cmake -G "Unix Makefiles" -B ${ZKLLVM_BUILD:-build} -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang-zkllvm .

Compile the circuit:

make -C ${ZKLLVM_BUILD:-build} template

This will create a template.ll file in the build/src directory. This file contains the compiled circuit intermediate representation.

Step 2: Build a circuit file and an assignment table

Next step is to make a compiled circuit and assignment table.

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

On this step, we run the assigner, giving it the circuit in LLVM IR format (template.ll) and the input data (./src/public-input.json). The assigner produces two following files:

  • Circuit file template.crct is the circuit in a binary format that is usable by the proof-generator.
  • Assignment table template.tbl is a representation of input data, prepared for proof computation with this particular circuit.

Step 3: Produce and verify a proof locally

Now we have everything ready to produce our first proof. As a circuit developer, we want to first build it locally, to check that our circuit is working. We'll use the proof-generator-single-threaded CLI, which is a part of the =nil; toolchain.

proof-generator-single-threaded \
    --circuit="template.crct" \
    --assignment-table="template.tbl" \
    --proof="proof.bin"

Note the following lines in the build log:

Preprocessing public data...
Preprocessing private data...
Generating proof...
Proof generated
Proof is verified
...

In the first lines, proof-generator creates a proof, and in the last one it verifies the proof. The resulting proof is in the file ./proof.bin.

Congratulations! You've produced a non-interactive zero-knowledge proof, or, formally speaking, a zero-knowledge succinct non-interactive argument of knowledge (zk-SNARK).

Application developer workflow

In this part, we will act as a developer of a zk application. Our task is to order a proof on the Proof Market:

  1. Find a circuit statement. We will be using one that has active proof producers, who will respond to our request.
  2. Post a request for a proof with given statement and particular input.
  3. Check that a request was matched and the proof is ready.
  4. Download the proof.

All commands in this section run in the container nilfoundation/proof-market-toolchain:

cd /opt/zkllvm-template
scripts/run.sh run_proof_market_toolchain

Step 1: See the statements available on the Proof Market

First, let's see what statements are available on the Proof Market.

python3 scripts/statement_tools.py get

If you're on a live workshop by =nil;, use the statement with id 96079532. It's built from the circuit code in this template, and accepts input from ./src/public-input.json.

Step 2: Post a proof request

python3 scripts/request_tools.py push \
    --key 96079532 \
    --cost 10 \
    --file /opt/zkllvm-template/src/public-input.json

The output will look like the following, but with different key values.

Limit request:	 {
    "_key": "99887766",
    "statement_key": "96079532",
    "cost": 10,
    "sender": "zkdev",
    "status": "created"
}

Step 3: Check if the proof is ready

You can check the request status at any time:

python3 scripts/request_tools.py get --key 99887766

You should see almost the same output as before. Note the status field: it reflects whether the Proof Market has assigned your request to a particular producer, and whether they have provided the proof.

Limit request:	 {
    "_key": "99887766",
    "statement_key": "96079532",
    "cost": 10,
    "sender": "zkdev",
    "status": "created"
}

Step 4: Download the proof

When the proof is ready, download it:

python3 scripts/proof_tools.py get \
    --request_key 99887766 \
    --file /tmp/example.proof

ls -l /tmp/example.proof

Now the proof can be verified, both off-chain and on-chain. These steps will be added soon.

zkllvm-template's People

Contributors

cblpok-git avatar hgedia avatar makxenov avatar manylov avatar nemothenoone avatar nickvolynkin avatar nkaskov avatar sk0m0r0h avatar zontec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zkllvm-template's Issues

ZKLLVM_VERSION: unbound variable

Command:

 scripts/ci.sh --docker compile

Log and error message:

+++ dirname -- scripts/ci.sh
++ cd -- scripts
++ pwd
+ SCRIPT_DIR=/Users/robertorosmaninho/rv/zk-experiments/zkllvm-template/scripts
+ REPO_ROOT=/Users/robertorosmaninho/rv/zk-experiments/zkllvm-template/scripts/..
+ command -v podman
+ DOCKER=docker
+ DOCKER_OPTS=
+ USE_DOCKER=false
+ SUBCOMMAND=run_all
+ [[ 2 -gt 0 ]]
+ case $1 in
+ USE_DOCKER=true
+ shift
+ [[ 1 -gt 0 ]]
+ case $1 in
+ SUBCOMMAND=run_all
+ shift
+ [[ 0 -gt 0 ]]
+ echo 'Running run_all'
Running run_all
+ run_all
+ compile
+ '[' true = true ']'
+ cd /Users/robertorosmaninho/rv/zk-experiments/zkllvm-template/scripts/..
++ id -u robertorosmaninho
++ id -g robertorosmaninho
++ pwd
scripts/ci.sh: line 35: ZKLLVM_VERSION: unbound variable

Possible fix:

Add the variable ZKLLVM_VERSION to the ci.sh with the current version!

[build circuit params] elliptic curve type is not specified

Description

If we uncomment build_circuit_params job inside scripts/run.sh to generate inputs for the EVM Placeholder Verifier it will fail because we are missing elliptic curve type

Commit Hash

aa8bd37

How to reproduce:

  1. Uncomment build_circuit_params here https://github.com/NilFoundation/zkllvm-template/blob/master/scripts/run.sh#L266
  2. Run bash scripts/run.sh

Solution:

Add necnecessary elliptic curve type in the transpiler command https://github.com/NilFoundation/zkllvm-template/blob/master/scripts/run.sh#L151

Add verification on EVM testsnet

In order to show the full pipeline we need to change the last step and allow user to verify their proof on the testnet. It can be done the same way we do it for the local node, so it shouldn't be a problem to add.

Extend readme with a revise step

After we add testnet verification, it may make sense to extend readme with the last step, where the user will be able to check their verification result on EthScan or similar resource.

Depends on #48

โ˜‚๏ธ Development workflow: EVM verifier

This is the next stage of template development after #3.

To enable verifying proofs on-chain, circuit developers need to deploy an EVM verifier endpoint based on our EVM verifier and their circuits.

All tasks should include:

  • Implementation in the run.sh script, checked in CI
  • One-command instructions in the README
  • Detailed [manual mode] instructions in the README

This part is required to complete the https://github.com/NilFoundation/zkllvm-tutorials/issues/4

Failing to build circuits

Recent changes have disabled building circuits. The resulting file has the extension .pc (not .bc or .ll).

Log fragments:

$ cmake -D CIRCUIT_ASSEMBLY_OUTPUT ..
...
CMake Warning:
  Manually-specified variables were not used by the project:

    CIRCUIT_ASSEMBLY_OUTPUT
...
$ make zkllvm_template
...
[100%] Building CXX object src/CMakeFiles/zkllvm_template.dir/main.cpp.o
/opt/zkllvm-template/src/main.cpp:17:76: warning: 'circuit' attribute directive ignored [-Wattributes]
   17 |                              typename pallas::base_field_type::value_type b) {
      |                                                                            ^
In file included from /opt/zkllvm-template/libs/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/modular/modular_functions_fixed.hpp:15,
                 from /opt/zkllvm-template/libs/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int/eval_jacobi.hpp:15,
                 from /opt/zkllvm-template/libs/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int.hpp:2772,
                 from /opt/zkllvm-template/libs/crypto3/libs/algebra/include/nil/crypto3/algebra/fields/detail/exponentiation.hpp:33,
                 from /opt/zkllvm-template/libs/crypto3/libs/algebra/include/nil/crypto3/algebra/fields/detail/element/fp.hpp:29,
                 from /opt/zkllvm-template/libs/crypto3/libs/algebra/include/nil/crypto3/algebra/fields/pallas/base_field.hpp:29,
                 from /opt/zkllvm-template/libs/crypto3/libs/algebra/include/nil/crypto3/algebra/curves/detail/pallas/types.hpp:29,
                 from /opt/zkllvm-template/libs/crypto3/libs/algebra/include/nil/crypto3/algebra/curves/pallas.hpp:29,
                 from /opt/zkllvm-template/src/main.cpp:1:
/opt/zkllvm-template/libs/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/modular/asm_functions.hpp: In function 'bool nil::crypto3::multiprecision::backends::reduce_limb_asm(const size_t&, Limb1*, const Limb2*, const Limb3&) [with Limb1 = long long unsigned int; Limb2 = long long unsigned int; Limb3 = __int128 unsigned]':
/opt/zkllvm-template/libs/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/modular/asm_functions.hpp:95:17: warning: unsupported size for integer register
   95 |                 }
      |                 ^
[100%] Built target zkllvm_template

Tutorial: describe the zkLLVM stage

Describe the zkLLVM stage of the tutorial

  1. Setting up a development environment
  2. Compiling a circuit to .ll
  3. Making .tbl and .crct Don't need them yet.

Add an example of unit-tests

A normal development workflow includes writing and running unit-tests. We should have an example of tests in this template.

For reference, see https://github.com/color-typea/lido-zkllvm-accounting-curcuit/tree/minimal_setup_with_tests_and_crypto3 (commit color-typea/lido-zkllvm-accounting-circuit@41327cb)

Updated version of this branch is in https://github.com/NilFoundation/zkllvm-template/tree/minimal_setup_with_tests_and_crypto3 and #28

Smaller example is shown in #29

โ˜‚๏ธ Production-ready zkLLVM project template, stage 1

The purpose of this epic is to make a template that just works.

https://www.notion.so/nilfoundation/zkLLVM-project-template-36efd1df8a41468ea7b5451c74b00916?pvs=4

A good template should:

  • Cover the whole development process:
    1. Compiling a circuit
    2. Making an assignment table for particular input
    3. Preparing a statement for proving
    4. Proving the statement
    5. Verifying the proof
  • Build successfully on all (supported) platforms.
  • Have tests and CI so developers won't have to set them up from scratch.
  • Have good enough documentation.

A success criterion is that developers from our community use and contribute to this template. The contribution can be in the form of pull requests, issues, and just friendly advice to other folks in the community.

Sub-tasks

zkLLVM part

Proof & Proof Market part

Ideas/backlog

  • Build circuits & proofs on Linux/aarch64
  • Build circuits & proofs on macOS/x86/64
  • Build a common application for Linux/x86_64
    • Add unit tests and run them in CI
  • Auto-update dependencies
    • Docs: updating dependencies
  • Test installing from a deb package in CI
  • Implement SDK versioning for https://github.com/NilFoundation/crypto3. (Further on, crypto3 should replace this template). Maybe we should work in crypto3 initially?

Cannot test circuit based on sha256

Example with minimal changes compared to template master branch:
https://github.com/color-typea/lido-zkllvm-accounting-curcuit/tree/minimal_setup_with_tests_and_crypto3

Steps to reproduce:
See README.md on the branch, but essentially just

cmake -DBUILD_TESTS=TRUE -S . -B ./build && cmake --build ./build --target test

Expected outcome:

  • test/lib.cpp is compiled and run.
  • test_sum pass (100% sure it will... Ok, 99%)
  • test_balance might pass (not 100% sure the "supporting" code is implemented correctly)

Actual outcome:

CMake Error at cmake/modules/share/modules/cmake/CMFuture.cmake:83 (_add_library):
  Target "zkllvm_circuit" links to target "crypto3::blueprint" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  src/CMakeLists.txt:24 (add_library)

Success criteria: it is possible to write and run tests against code using crypto3::sha256

No rule to make target 'zkllvm_zkllvm'.

Hello,

I have followed the instructions to try to get this working. When I get to the cmake .. && make zkllvm_zkllvm instruction I get the following error:

root@41d4bdedd740:/opt/zkllvm-template# mkdir build && cd build
root@41d4bdedd740:/opt/zkllvm-template/build# cmake .. && make zkllvm_zkllvm
CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is Clang 16.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: container random system unit_test_framework 
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Looking for clock_gettime
-- Looking for clock_gettime - not found
-- Looking for gettimeofday
-- Looking for gettimeofday - found
-- Could not find support for SSE2 on this machine.
-- Could not find support for SSE3 on this machine.
-- Could not find support for SSSE3 on this machine.
-- Could not find support for SSE4.1 on this machine.
-- Could not find support for SSE4.2 on this machine.
-- Performing Test C_HAS_AVX_1
-- Performing Test C_HAS_AVX_1 - Failed
-- Performing Test C_HAS_AVX_2
-- Performing Test C_HAS_AVX_2 - Success
-- Performing Test C_HAS_AVX2_1
-- Performing Test C_HAS_AVX2_1 - Failed
-- Performing Test C_HAS_AVX2_2
-- Performing Test C_HAS_AVX2_2 - Success
-- Performing Test CXX_HAS_AVX_1
-- Performing Test CXX_HAS_AVX_1 - Failed
-- Performing Test CXX_HAS_AVX_2
-- Performing Test CXX_HAS_AVX_2 - Success
-- Performing Test CXX_HAS_AVX2_1
-- Performing Test CXX_HAS_AVX2_1 - Failed
-- Performing Test CXX_HAS_AVX2_2
-- Performing Test CXX_HAS_AVX2_2 - Success
CMake Deprecation Warning at libs/crypto3/libs/containers/CMakeLists.txt:32 (cmake_policy):
  The OLD behavior for policy CMP0079 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Could not find support for SSE2 on this machine.
-- Could not find support for SSE3 on this machine.
-- Could not find support for SSSE3 on this machine.
-- Could not find support for SSE4.1 on this machine.
-- Could not find support for SSE4.2 on this machine.
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0")  
-- Could not find support for SSE2 on this machine.
-- Could not find support for SSE3 on this machine.
-- Could not find support for SSSE3 on this machine.
-- Could not find support for SSE4.1 on this machine.
-- Could not find support for SSE4.2 on this machine.
-- Could not find support for SSE2 on this machine.
-- Could not find support for SSE3 on this machine.
-- Could not find support for SSSE3 on this machine.
-- Could not find support for SSE4.1 on this machine.
-- Could not find support for SSE4.2 on this machine.
-- Could NOT find TomMath (missing: TomMath_LIBRARY TomMath_INCLUDE_DIRS) 
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/zkllvm-template/build
make: *** No rule to make target 'zkllvm_zkllvm'.  Stop.
root@41d4bdedd740:/opt/zkllvm-template/build# ls
CMakeCache.txt  CMakeFiles  CTestTestfile.cmake  Makefile  arch.c  cmake_install.cmake  libs  src
root@41d4bdedd740:/opt/zkllvm-template/build# 

Pin the installed zkLLVM version

The latest-released version is sometimes not the latest when sorted by version. Currently, the latest version is 0.0.71, but we have the following packages:

# apt-cache policy zkllvm
zkllvm:
  Installed: (none)
  Candidate: 0.1.0
  Version table:
     0.1.0 500
        500 http://deb.nil.foundation/ubuntu all/main amd64 Packages
     0.0.71 500
        500 http://deb.nil.foundation/ubuntu all/main amd64 Packages
     0.0.68 500
        500 http://deb.nil.foundation/ubuntu all/main amd64 Packages
     0.0.58 500
        500 http://deb.nil.foundation/ubuntu all/main amd64 Packages
     0.0.0-45 500
        500 http://deb.nil.foundation/ubuntu all/main amd64 Packages

More details can be found in NilFoundation/zkLLVM#120.

Solution:

  • pin the installed version in Dockerfile
  • tag images like nilfoundation/zkllvm-template:0.0.71
  • use specific versions ci.sh

CI: make & prove a statement, verify a proof

Now that we've got circuits from #5, we can prove and verify them.

Use ghcr.io/nilfoundation/proof-market-toolchain

  1. Build a proof market statement.
  2. Prove the statement
  3. Verify the proof

If there's an error on any step, fail the build with a clear error message.

Crypto3-hash compilation bug

Steps to reproduce:
0. Start with the template "as is"

  1. Configure according to the instructions in the README (docker variant)
  2. Add <nil/crypto3/hash/algorithm/hash.hpp> to the src/main.cpp
  3. Run build/make template

Expected result: compilation succeeds
Actual result: Compilation fails with the following errors:

In file included from /opt/zkllvm-template/src/main.cpp:2:
In file included from /opt/zkllvm-template/libs/crypto3/libs/hash/include/nil/crypto3/hash/algorithm/hash.hpp:28:
In file included from /opt/zkllvm-template/libs/crypto3/libs/hash/include/nil/crypto3/hash/hash_value.hpp:36:
In file included from /opt/zkllvm-template/libs/crypto3/libs/codec/include/nil/crypto3/detail/pack.hpp:31:
In file included from /opt/zkllvm-template/libs/crypto3/libs/codec/include/nil/crypto3/detail/exploder.hpp:31:
/opt/zkllvm-template/libs/crypto3/libs/codec/include/nil/crypto3/detail/reverser.hpp:69:2: error: "BOOST_ARCH_CURRENT_WORD_BITS not set"
#error "BOOST_ARCH_CURRENT_WORD_BITS not set"
 ^
In file included from /opt/zkllvm-template/src/main.cpp:2:
In file included from /opt/zkllvm-template/libs/crypto3/libs/hash/include/nil/crypto3/hash/algorithm/hash.hpp:28:
In file included from /opt/zkllvm-template/libs/crypto3/libs/hash/include/nil/crypto3/hash/hash_value.hpp:36:
/opt/zkllvm-template/libs/crypto3/libs/codec/include/nil/crypto3/detail/pack.hpp:109:74: error: use of undeclared identifier 'ValueBits'
            struct can_memcpy<stream_endian::big_unit_big_bit<UnitBits>, ValueBits, InT, OutT>
                                                                         ^
/opt/zkllvm-template/libs/crypto3/libs/codec/include/nil/crypto3/detail/pack.hpp:112:77: error: use of undeclared identifier 'ValueBits'
            struct can_memcpy<stream_endian::big_unit_little_bit<UnitBits>, ValueBits, InT, OutT>
                                                                            ^
/opt/zkllvm-template/libs/crypto3/libs/codec/include/nil/crypto3/detail/pack.hpp:113:68: error: expected expression
                : host_can_memcpy<UnitBits, InputBits, OutputBits, , InT, OutT> { };
                                                                   ^
4 errors generated.
make[3]: *** [src/CMakeFiles/template.dir/build.make:70: src/CMakeFiles/template] Error 1
make[2]: *** [CMakeFiles/Makefile2:527: src/CMakeFiles/template.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:534: src/CMakeFiles/template.dir/rule] Error 2
make: *** [Makefile:179: template] Error 2
root@1ef363b2ef3f:/opt/zkllvm-template/build# make template
Built target template
root@1ef363b2ef3f:/opt/zkllvm-template/build# make template
In file included from /opt/zkllvm-template/src/main.cpp:2:
In file included from /opt/zkllvm-template/libs/crypto3/libs/hash/include/nil/crypto3/hash/algorithm/hash.hpp:28:
In file included from /opt/zkllvm-template/libs/crypto3/libs/hash/include/nil/crypto3/hash/hash_value.hpp:36:
In file included from /opt/zkllvm-template/libs/crypto3/libs/codec/include/nil/crypto3/detail/pack.hpp:31:
In file included from /opt/zkllvm-template/libs/crypto3/libs/codec/include/nil/crypto3/detail/exploder.hpp:31:
/opt/zkllvm-template/libs/crypto3/libs/codec/include/nil/crypto3/detail/reverser.hpp:69:2: error: "BOOST_ARCH_CURRENT_WORD_BITS not set"
#error "BOOST_ARCH_CURRENT_WORD_BITS not set"
 ^
In file included from /opt/zkllvm-template/src/main.cpp:2:
In file included from /opt/zkllvm-template/libs/crypto3/libs/hash/include/nil/crypto3/hash/algorithm/hash.hpp:28:
In file included from /opt/zkllvm-template/libs/crypto3/libs/hash/include/nil/crypto3/hash/hash_value.hpp:36:
/opt/zkllvm-template/libs/crypto3/libs/codec/include/nil/crypto3/detail/pack.hpp:109:74: error: use of undeclared identifier 'ValueBits'
            struct can_memcpy<stream_endian::big_unit_big_bit<UnitBits>, ValueBits, InT, OutT>
                                                                         ^
/opt/zkllvm-template/libs/crypto3/libs/codec/include/nil/crypto3/detail/pack.hpp:112:77: error: use of undeclared identifier 'ValueBits'
            struct can_memcpy<stream_endian::big_unit_little_bit<UnitBits>, ValueBits, InT, OutT>
                                                                            ^
/opt/zkllvm-template/libs/crypto3/libs/codec/include/nil/crypto3/detail/pack.hpp:113:68: error: expected expression
                : host_can_memcpy<UnitBits, InputBits, OutputBits, , InT, OutT> { };
                                                                   ^
4 errors generated.
make[3]: *** [src/CMakeFiles/template.dir/build.make:70: src/CMakeFiles/template] Error 1
make[2]: *** [CMakeFiles/Makefile2:527: src/CMakeFiles/template.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:534: src/CMakeFiles/template.dir/rule] Error 2
make: *** [Makefile:179: template] Error 2

Also:

  1. Tried running with Boost_1.81 - same outcome
  2. Tried running outside docker container in the host system - same outcome
  3. Compilation succeeds with "stock" example (without the added import)

macOS-based deployment usage cannot find CircuitCompile.cmake

/opt/local/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/.zkllvm/relwithdebinfo/bin/clang-16 -DCMAKE_CXX_COMPILER=/.zkllvm/relwithdebinfo/bin/clang-16 -DBUILD_TESTS=FALSE -DCMAKE_DEPENDS_USE_COMPILER=FALSE -G "CodeBlocks - Unix Makefiles" -S ./zkllvm-template -B ~/.build/zkllvm-template/debug

CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at CMakeLists.txt:9 (include):
  include could not find requested file:

    CircuitCompile


-- Found Boost: /opt/local/include (found version "1.76.0") found components: container random system unit_test_framework 
-- Could not find support for SSE2 on this machine.
-- Could not find support for SSE3 on this machine.
-- Could not find support for SSSE3 on this machine.
-- Could not find support for SSE4.1 on this machine.
-- Could not find support for SSE4.2 on this machine.
CMake Deprecation Warning at libs/crypto3/libs/containers/CMakeLists.txt:32 (cmake_policy):
  The OLD behavior for policy CMP0079 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Could not find support for SSE2 on this machine.
-- Could not find support for SSE3 on this machine.
-- Could not find support for SSSE3 on this machine.
-- Could not find support for SSE4.1 on this machine.
-- Could not find support for SSE4.2 on this machine.
-- Found Boost: /opt/local/include (found version "1.76.0")  
-- Could not find support for SSE2 on this machine.
-- Could not find support for SSE3 on this machine.
-- Could not find support for SSSE3 on this machine.
-- Could not find support for SSE4.1 on this machine.
-- Could not find support for SSE4.2 on this machine.
-- Could not find support for SSE2 on this machine.
-- Could not find support for SSE3 on this machine.
-- Could not find support for SSSE3 on this machine.
-- Could not find support for SSE4.1 on this machine.
-- Could not find support for SSE4.2 on this machine.
-- Could NOT find TomMath (missing: TomMath_LIBRARY TomMath_INCLUDE_DIRS) 
CMake Error at src/CMakeLists.txt:11 (add_circuit):
  Unknown CMake command "add_circuit".
Call Stack (most recent call first):
  src/CMakeLists.txt:42 (add_example)


-- Configuring incomplete, errors occurred!
See also "zkllvm-template/debug/CMakeFiles/CMakeOutput.log".
See also "zkllvm-template/debug/CMakeFiles/CMakeError.log".

[Failed to reload]

Make template app compilable both to circuits and x86

Developers who start working with zkllvm often want to see a simple application that compiles both to a normal amd64 application and to a circuit with zkllvm.

Otherwise it's hard to understand how to make an app that compiles in both ways and how to run tests on it.

DoD:

  • Simple app with main.
  • Unit-tests for this app.
  • (optionally) functional test for a compiled app.
  • Cicruit compilation

CI: build circuits & assignment tables on Linux/x86_64

Run CI workflows to test instructions against the current version of template.

  • Use prebuilt image ghcr.io/nilfoundation/zkllvm-template:latest
  • Build circuit in .ll
  • Build .crct and .tbl
  • If any operation exits non-zero, fail CI and block PR merging.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.