starkware-libs / cairo-lang

Apache License 2.0
1.35k stars 266 forks source link

Error in Public Input Verification with `cairo_verifier` on `example_proof` #179

Closed Okm165 closed 11 months ago

Okm165 commented 11 months ago

Description:

Issue Summary:

I am facing a challenge with running the cairo_verifier on the cairo-lang, specifically with the version tagged as v0.12.3 using Python 3.9.0. While I am able to compile and run cairo_verifier, an error occurs when executing it with a example proof.

Steps to Reproduce:

  1. Clone the cairo-lang repository from this link (branch v0.12.3-run-proof). This repo has bazel build fixed manually see this issue for more info
  2. Setup a Python 3.9.0 environment and create a zip package:
    zip -r cairo-lang-0.12.3.zip cairo-lang-0.12.3
    pip install cairo-lang-0.12.3.zip
  3. Compile cairo_verifier using:
    cairo-compile --cairo_path=./src src/starkware/cairo/cairo_verifier/layouts/starknet_with_keccak/cairo_verifier.cairo --output cairo_verifier.json
  4. Execute cairo_verifier with:
    cairo-run \
      --program=cairo_verifier.json \
      --layout=starknet_with_keccak \
      --program_input=cairo_verifier_input.json \
      --trace_file=cairo_verifier_trace.json \
      --memory_file=cairo_verifier_memory.json \
      --print_output

    Using cairo_verifier_input.json with the content from src/starkware/cairo/stark_verifier/air/example_proof.json.

Expected Result:

The cairo_verifier should execute successfully without any errors.

Actual Result:

The program executes but fails during the _verify_public_input function this assertion. The error message is as follows:

[src/starkware/cairo/cairo_verifier/layouts/starknet_with_keccak/cairo_verifier.cairo:74:5: Error at pc=0:31735]
An ASSERT_EQ instruction failed: 0 != 3.
    assert public_input.n_continuous_pages = 0;
    ^*****************************************^
Cairo traceback (most recent call last):
src/starkware/cairo/cairo_verifier/layouts/starknet_with_keccak/cairo_verifier.cairo:199:39: (pc=0:31899)
    let (program_hash, output_hash) = verify_cairo_proof(proof);
                                      ^***********************^
src/starkware/cairo/cairo_verifier/layouts/starknet_with_keccak/cairo_verifier.cairo:52:12: (pc=0:31709)
    return _verify_public_input(public_input=cast(proof.public_input, PublicInput*));

This indicates an issue with the public input verification, even though the core stark verification seems to work fine.

Additional Information:

Questions:

ilyalesokhin-starkware commented 11 months ago

Continuous memory pages are not supported by the Cairo verifier.

Okm165 commented 11 months ago

@ilyalesokhin-starkware Are u able to provide example proof with starknet_with_keccak layout, proof in the repo has multiple memory pages and I have trouble generating one from stone-prover as mentioned here https://github.com/starkware-libs/cairo-lang/issues/180