Skip to content

can't verify proof locallyΒ #168

@rnbguy

Description

@rnbguy

I have a sha256 verifier using the sha256 implementation from alexandria project. (I can't use core::sha256::compute_sha256_byte_array because I hit on this error.)

#[feature("deprecated-sha256")]
use alexandria_math::sha256::sha256;

fn main(args: Array<felt252>) -> Array<felt252> {
    let mut span = args.span();
    let data = Serde::<Array<u8>>::deserialize(ref span).unwrap();
    assert(data == array![97, 98, 99], 'Invalid input data');
    let hash: Array<u8> = sha256(data);
    let mut result = array![];
    Serde::serialize(@hash, ref result);
    result
}

I compile it using scarb as instructed and produced sha256.sierra.json. Then I follow the instructions from stone-prover repo to set it up.

git clone https://github.com/starkware-libs/stone-prover
cd e2e_test/Cairo
git clone https://github.com/lambdaclass/cairo-vm
cd cairo-vm/cairo1-run
make deps

Now I generate proof artifacts.

cargo run sha256.sierra.json --layout recursive --air_public_input=sha256_public_input.json --air_private_input=sha256_private_input.json --trace_file=sha256_trace.bin --memory_file=sha256_memory.bin --print_output --proof_mode --args '[3 97 98 99]'
...
Program Output : [32 186 120 22 191 143 1 207 234 65 65 64 222 93 174 34 35 176 3 97 163 150 23 122 156 180 16 255 97 242 0 21 173]

The program output is correct (for "abc").

I use recursive as integrity uses recursive, keccak and monolith features by default.

Now I try to generate the proof.

cpu_air_prover --out_file=sha256_proof.json --private_input_file=sha256_private_input.json --public_input_file=sha256_public_input.json --prover_config_file=../../cpu_air_prover_config.json --parameter_file=../../cpu_air_params.json --generate_annotations

But I hit on the following error.

Fri parameters do not match stark degree bound. Expected FRI degree from FriParameters: 8192. STARK: 4194304

Following the instruction for stone-prover, I set the cpu_air_params.json to the following

{
    "field": "PrimeField0",
    "stark": {
        "fri": {
            "fri_step_list": [
                0,
                4,
                3,
                4,
                3,
                2
            ],
            "last_layer_degree_bound": 64,
            "n_queries": 18,
            "proof_of_work_bits": 24
        },
        "log_n_cosets": 4
    },
    "use_extension_field": false
}

The above cpu_air_prover works now and generates sha256_proof.json.

Now I come back to integrity repo.

git clone https://github.com/HerodotusDev/integrity
cd integrity

Then I generate the felt calldata from the sha256_proof.json.

cargo run --release --bin proof_serializer < sha256_proof.json
...
7 26 0 3 26 0 2 26 0 26 6 15 16 22 ...

Now I try to verify the proof locally using integrity. But I hit on errors.

scarb build
cargo run --release --bin runner -- --program sha256.sierra.json --memory-verification strict --stone-version stone6 --hasher-bit-length 160_lsb < sha256_proof.json
...
proof size: 12134 felts

thread 'main' panicked at runner/src/main.rs:69:6:
called `Result::unwrap()` on an `Err` value: BuildError(FailedGasCalculation(UnexpectedCycle))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

What am I doing wrong ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions