NilFoundation / proof-market-toolchain

A toolchain for interaction with the Proof Market protocol.
https://docs.nil.foundation/proof-market
MIT License
23 stars 5 forks source link

`proof-generator` not working with input strings #62

Closed Robertorosmaninho closed 1 year ago

Robertorosmaninho commented 1 year ago

Steps to reproduce:

Test File: charcpp_test.cpp

#include <cstddef>
[[circuit]] size_t strlen(const char *str) {
    size_t counter = 0;
    while (str[counter++] != '\0');
    return counter - 1;
}

Input File: charcpp_input.json

{
    "input": "abcdefgh"
}

Commands to reproduce

Getting the circuit with zkLLVM:

/home/robertorosmaninho/rv/zk-experiments/zkllvm/build/libs/circifier/llvm/bin/clang-16 -target assigner -Xclang -no-opaque-pointers -Xclang -fpreserve-vec3-type -std=c++20 -D__ZKLLVM__ -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/algebra/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/build/include -I /home/robertorosmaninho/rv/boost_1_76_0/build/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/block/include -I /home/robertorosmaninho/rv/boost_1_76_0/build/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/blueprint/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/codec/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/containers/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/hash/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/kdf/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/mac/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/marshalling/core/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/marshalling/algebra/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/marshalling/multiprecision/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/marshalling/zk/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/math/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/modes/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/multiprecision/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/passhash/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/pbkdf/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/pkmodes/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/pkpad/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/pubkey/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/random/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/stream/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/vdf/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/zk/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/stdlib/libcpp -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/stdlib/libc/include -emit-llvm -O1 -S charcpp_test.cpp

Getting the circuit statement:

python ./scripts/prepare_statement.py -c=charcpp_test.ll -o=test_statement.json -n=test -t=placeholder-zkllvm

Generate the proof:

./build/bin/proof-generator/proof-generator --proof_out=test_output.bin --circuit_input=test_statement.json --public_input=charcpp_input.json

Current Output from proof-generator:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

Expected output:

generatring zkllvm proof...
Proof is verified

Tools Version

zkLLVM

clang version 16.0.0 (https://github.com/NilFoundation/zkllvm-circifier.git 9e73aecf0f3db71cb1fb433f65d56a63654afd1a)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/robertorosmaninho/rv/zk-experiments/zkllvm/build/libs/circifier/llvm/bin

Proof Market

$> git log
commit 992025ddbf89a4dbd0c7c1512b25704846577daf (HEAD -> master, tag: v0.0.30, origin/master, origin/HEAD)

$> l
total 16K
drwxrwxr-x 4 robertorosmaninho robertorosmaninho 4.0K May 30 13:27 .
drwxrwxr-x 7 robertorosmaninho robertorosmaninho 4.0K Jun 15 16:20 ..
drwxrwxr-x 3 robertorosmaninho robertorosmaninho 4.0K Jun 15 16:25 proof-generator

I couldn't find a way to output the current version, so I just used git log and l.