Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verification (started to) always fails after transpiler update #78

Open
color-typea opened this issue Oct 8, 2023 · 5 comments
Open
Assignees

Comments

@color-typea
Copy link

color-typea commented Oct 8, 2023

There seems to have been a recent update to circuit_params.json produced by the transpiler (added commitment_params_node and moved some attributes inside it - e.g. lambda and D_omegas)

Steps to reproduce:
Using repo with end-to-end circuit lifecycle: https://github.com/color-typea/zkllvm-playground

Difference in CircuitParams.sol before and after change: color-typea/zkllvm-playground#1

Before the change: first 2 tests (correct proofs) pass as expected, second 2 tests (incorrect proofs) fail (this is a known separate issue)
After the change: first 2 tests (correct proofs) fail, second 2 tests (incorrect proofs) pass - this essentially means it rejects even correct proofs.

How to run tests:

  • make test should do everything. Note it includes producing "new" CircuitParams.sol, so you'll end up in the "after the change" state
  • To go to "before the change", the old CircuitParams.sol is available at zkllvm-playground

Toolchain versions:

  • Compiler: clang version 16.0.0 ([email protected]:NilFoundation/zkllvm-circifier.git 9470dd7ed89d89edfd596c397b8c7c37b0dce2a0)
  • Assigner: 0.1.2-12 (built from source @ 9482a3f01e1138a69ff5d096b9ff7e811b59cf0b)
  • Transpiler: 0.1.2-12 (built from source @ 9482a3f01e1138a69ff5d096b9ff7e811b59cf0b)
  • evm-placeholder-verification: 1.1.1
@ETatuzova
Copy link
Contributor

Hello!

You are right. We released a new version of zkllvm-transpiler too early and temporary lost compatibility with evm-placeholder-verification.

Not only circuit_params.json file format has been changed, but also the proof format, some interfaces, etc.

You can use versions of zkllvm, which are still compatible with the main branch
(for example, zkllvm @ 6f3a3bd4d7185223a248361bb1cb657ccb80d5cf version).

This issue will be fixed in the next patch. We will do this as soon as possible.
Sorry for any inconvenience caused!

@ETatuzova
Copy link
Contributor

Hi!

You can use our working branch to verify proofs from zkllvm: #74
Building instructions are a bit different:

  1. Checkout zkllvm master branch.

  2. Compile your code, build assigner, transpiler.

  3. Use gen-evm-verifier transpiler mode instead of gen-gate-argument. For example,

#${ZKLLVM_BUILD:-build}/bin/transpiler/transpiler -m gen-evm-verifier -t ./build/examples/cpp/assignment_pallas_curve_multiplication_cpp_example.tbl -c ./build/examples/cpp/circuit_pallas_curve_multiplication_cpp_example.crct -o ./output_folder

#${ZKLLVM_BUILD:-build}/bin/transpiler/transpiler -m gen-test-proof -t ./build/examples/cpp/assignment_pallas_curve_multiplication_cpp_example.tbl -c ./build/examples/cpp/circuit_pallas_curve_multiplication_cpp_example.crct -o ./output_folder
  1. After this we'll have all data we need for in-EVM verification in 'output_folder'.

  2. Checkout evm-placeholder-verification Lookup compatibility #74 branch.

  3. Copy output_folder to evm-placeholder-verification/contracts/zkllvm subfolder.

  4. Run npx hardhat deploy from evm-placeholder-verification folder

  5. Run npx hardhat verify-circuit-proof-all or npx hardhat verify-circuit-proof --test output_folder

If you execute cmake with -DGENERATE_EVM_VERIFIER=TRUE in zkllvm , you can use make targets to prepare proof and evm verifier for cpp examples.

For example,
make -C ${ZKLLVM_BUILD:-build} arithmetics_cpp_example_evm_verifier -j4
generates proof and all necessary evm-verifier files in build/examples/cpp/transpiler_output_arithmeitcs_cpp_example folder.

For zkllvm examples you may also use target arithmetics_cpp_example_assign to generate only assignment table and constraint system and arithmetics_cpp_example_prove to generate proof. All output files will be placed in build/examples/cpp subfolder.

@color-typea
Copy link
Author

@ETatuzova Thanks! Confirm this works, but I have a small ask - could the 74th branch be published to npm as package? The workflow you described above works as a workaround, but is a somewhat slower/harder to use compared to using evm-placeholder-verifier as a library, rather than a "test runner".

@color-typea
Copy link
Author

color-typea commented Nov 2, 2023

@ETatuzova , @alexandra-mara follow up - the instruction above is missing one thing that actually masks a different problem.

Transpiler puts public input into public_input.json, while modular-test.js expects to see it in input.json. So probably should be step 6.1. Rename public_input.json to input.json.

The issue is:

  • With public_input.json, the test runs without public input and succeeds.
  • With input.json, the test runs with specified input, and always fail with "Wrong public input!"

In other words, checking public input seems to be broken. Tested with both standalone proof-generator and transpiler-generated proofs.

@alexandra-mara
Copy link
Contributor

Closed by #87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants