starkware-libs / cairo-lang

Apache License 2.0
1.33k stars 260 forks source link

Whether the proof generated by stone-prover can be verified in stark_test.py in the starkware-libs/cairo-lang repo? #172

Open abel-byte opened 8 months ago

abel-byte commented 8 months ago

Whether the proof generated by stone-prover can be verified in stark_test.py in the starkware-libs/cairo-lang repo? I tried to generate proofs (the proofs is verified by stone-prover) of two layout types, small and recursive, from stone-prover and put them in the cairo-lang repo for verification, but they both failed. I would like to ask if it is feasible for stone-prover to generate a proof and then verify it with verify.cairo.

/usr/bin/env /bin/python3.9 /home/ken/.vscode-server/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 45831 -- /home/ken/workspaces/starkware/cairo-lang/src/starkware/cairo/stark_verifier/air/stark_test.py
...
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/ken/.vscode-server/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/home/ken/.vscode-server/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/home/ken/.vscode-server/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/home/ken/.vscode-server/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/home/ken/.vscode-server/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/home/ken/.vscode-server/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "/home/ken/workspaces/starkware/cairo-lang/src/starkware/cairo/stark_verifier/air/stark_test.py", line 18, in <module>
    test_stark()
  File "/home/ken/workspaces/starkware/cairo-lang/src/starkware/cairo/stark_verifier/air/stark_test.py", line 14, in test_stark
    run_test(proof_file=PROOF_FILE, layout="small")
  File "/home/ken/workspaces/starkware/cairo-lang/src/starkware/cairo/stark_verifier/air/stark_test_utils.py", line 37, in run_test
    runner.run(
  File "/home/ken/.local/lib/python3.9/site-packages/starkware/cairo/common/cairo_function_runner.py", line 178, in run
    self.run_from_entrypoint(
  File "/home/ken/.local/lib/python3.9/site-packages/starkware/cairo/common/cairo_function_runner.py", line 277, in run_from_entrypoint
    self.run_until_pc(addr=end, run_resources=run_resources)
  File "/home/ken/.local/lib/python3.9/site-packages/starkware/cairo/lang/vm/cairo_runner.py", line 325, in run_until_pc
    self.vm_step()
  File "/home/ken/.local/lib/python3.9/site-packages/starkware/cairo/lang/vm/cairo_runner.py", line 339, in vm_step
    self.vm.step()
  File "/home/ken/.local/lib/python3.9/site-packages/starkware/cairo/lang/vm/vm_core.py", line 486, in step
    self.run_instruction(instruction)
  File "/home/ken/.local/lib/python3.9/site-packages/starkware/cairo/lang/vm/vm_core.py", line 421, in run_instruction
    raise self.as_vm_exception(exc) from None
starkware.cairo.lang.vm.vm_exceptions.VmException: /home/ken/workspaces/starkware/cairo-lang/src/starkware/cairo/stark_verifier/core/stark.cairo:322:5: Error at pc=0:12709:
An ASSERT_EQ instruction failed: 3234953506123557673888864199017091438480321017107689376836404068674598653026 != 2136170429113342763579528520850391853488563282241066013961023191400830285589.
    assert composition_from_trace_values = claimed_composition;
    ^*********************************************************^
Cairo traceback (most recent call last):
/home/ken/workspaces/starkware/cairo-lang/src/starkware/cairo/stark_verifier/air/layouts/small/verify.cairo:73:12: (pc=0:12850)
    return verify_stark_proof(
           ^*****************^
/home/ken/workspaces/starkware/cairo-lang/src/starkware/cairo/stark_verifier/core/stark.cairo:172:34: (pc=0:12466)
        let (stark_commitment) = stark_commit(
                                 ^***********^
/home/ken/workspaces/starkware/cairo-lang/src/starkware/cairo/stark_verifier/core/stark.cairo:257:5: (pc=0:12608)
    verify_oods(
    ^**********^
Okm165 commented 6 months ago

@abel-byte I went through this, checkout working repo, study the commits for details https://github.com/Okm165/stone-prover-cairo0-verifier I am happy to connect btw, so ask any questions if needed