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

crates/stark/src/oods.rs:31:18: attempt to subtract with overflow #55

Closed
tdelabro opened this issue Dec 18, 2024 · 13 comments · Fixed by #56
Closed

crates/stark/src/oods.rs:31:18: attempt to subtract with overflow #55

tdelabro opened this issue Dec 18, 2024 · 13 comments · Fixed by #56
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@tdelabro
Copy link

          I changed my `cpu_air_params.json` to `"fri_step_list": [0, 4, 4, 4, 4]"` and it now crashes later in the verification:

At crates/stark/src/oods.rs:31:18 which is:

pub fn verify_oods<Layout: LayoutTrait>(
    oods: &[Felt],
    interaction_elements: &Layout::InteractionElements,
    public_input: &PublicInput,
    constraint_coefficients: &[Felt],
    oods_point: &Felt,
    trace_domain_size: &Felt,
    trace_generator: &Felt,
) -> Result<(), OodsVerifyError> {
    let composition_from_trace = Layout::eval_composition_polynomial(
        interaction_elements,
        public_input,
        &oods[0..oods.len() - 2], // < here
        constraint_coefficients,
        oods_point,
        trace_domain_size,
        trace_generator,
    )?;
    ...
}

Originally posted by @tdelabro in #54 (comment)

@tdelabro
Copy link
Author

Could it be that my annotations look like that:

		"V->P: /cpu air/STARK/Out Of Domain Sampling/OODS values: Evaluation point: Field Element(0x6554169f2c8b8fa0f8b0c2f65af48039f64ad47f2fd90caaa2bb808f600f829)",
		"P->V[96:128]: /cpu air/STARK/Out Of Domain Sampling/OODS values: 0: Field Element(0x40536e9e9158351e084b9ec5f9831c96969e4efd8f0b56f8532f377d2988483)",
		"P->V[128:160]: /cpu air/STARK/Out Of Domain Sampling/OODS values: 1: Field Element(0x369e29b182cf9accf1868d724708ba83a462c4c8fa425d0c9d5c956a43ec75a)",
		"P->V[160:192]: /cpu air/STARK/Out Of Domain Sampling/OODS values: 2: Field Element(0x2e553a9831fa0df8fa5d1029d152a7dcda95c310aa6bd5a9fe5b650abce5078)",
		"P->V[192:224]: /cpu air/STARK/Out Of Domain Sampling/OODS values: 3: Field Element(0x1f179c246f2d0347d1cad76a75781ef805854f85b3fe933c5179a0131a6b0d6)",

while your code expect the odds prefix to be "STARK/Out Of Domain Sampling/OODS values"
see proof_parser/src/annotations/annotation_kind.rs

            Annotation::OodsValues => PrefixAndKind {
                prefix: "STARK/Out Of Domain Sampling/OODS values".to_string(),
                kinds: AnnotationKinds::FieldElements,
            },

@tdelabro
Copy link
Author

tdelabro commented Dec 18, 2024

Yup, I think something is wrong in the parsing because I printed my oods:

    let x = stark_proof.unsent_commitment.oods_values;
    panic!("{:?}", x);

and got []

@Okm165
Copy link
Contributor

Okm165 commented Dec 18, 2024

do u have latest stone built?
i am asking this Q latest stone is annotating oods values like this
https://github.com/iosis-tech/swiftness/blob/main/examples/proofs/recursive/cairo0_stone5_example_proof.json#L16
your annotations way looks old

@tdelabro
Copy link
Author

I think I build it from source: https://github.com/starkware-libs/stone-prover
From a non-released commit:

cpu_air_prover -version
cpu_air_prover version INVALID_NAME-INVALID_PROOF_HASH-INVALID_COMMIT

Which version do you recommend I use?

@Okm165
Copy link
Contributor

Okm165 commented Dec 18, 2024

Oh It is not version issue latest Stone v3 is fine
What u are missing is the correct proof params especially "verifier_friendly_channel_updates" : true
Take a look at the proof params in the repo guide: https://github.com/iosis-tech/swiftness/blob/main/examples/proofs/cpu_air_params.json

@tdelabro
Copy link
Author

tdelabro commented Dec 18, 2024

Mine is currently:

{
    "field": "PrimeField0",
    "stark": {
        "fri": {
            "fri_step_list": [
                0,
                4,
                4,
                4,
                4
            ],
            "last_layer_degree_bound": 32,
            "n_queries": 18,
            "proof_of_work_bits": 30
        },
        "log_n_cosets": 4
    },
    "use_extension_field": false
}

What else should I change?

@Okm165
Copy link
Contributor

Okm165 commented Dec 18, 2024

Just copy json from my link and adjust fri layers for ur case

@tdelabro
Copy link
Author

tdelabro commented Dec 18, 2024

Is this the only configuration verifiable with swiftness? Or is there some room for configuration here?

@tdelabro
Copy link
Author

I tryied different mixed fri but always get the same error:

Caused by:
    0: OodsVerifyError Error
    1: oods invalid 709992957254620831002252392826336286100946637269575755219814514419612025930 - 1868104729289279686881179178362914385993703678119283254310630101746102206724

(actual values may vary)

Last I used is:

{
    "field": "PrimeField0",
    "channel_hash": "poseidon3",
    "commitment_hash": "blake256_masked248_lsb",
    "n_verifier_friendly_commitment_layers": 10,
    "pow_hash": "blake256",
    "statement": {
        "page_hash": "pedersen"
    },
    "stark": {
        "fri": {
            "fri_step_list": [
                0,
                4,
                4,
                4,
                2
            ],
            "last_layer_degree_bound": 128,
            "n_queries": 18,
            "proof_of_work_bits": 24
        },
        "log_n_cosets": 2
    },

    "use_extension_field": false,
    "verifier_friendly_channel_updates": true,
    "verifier_friendly_commitment_hash": "poseidon3"
}

@tdelabro
Copy link
Author

should n_verifier_friendly_commitment_layers be equal to the sum of fri_step_list?

I tried it (setting it to 14 while keeping the last config I showed) and it failed

@Okm165
Copy link
Contributor

Okm165 commented Dec 18, 2024

this command should verify proof with above configuration (i saw u use starknet layout in the prev proof)
cargo run --release --bin swiftness --features starknet,blake2s_248_lsb,stone6 --no-default-features -- --proof your_proof.json

@Okm165
Copy link
Contributor

Okm165 commented Dec 18, 2024

Given the correctly generated proof the verifier fails to verify with error Error: PublicInputError(MaxSteps)
This is due to this check failing https://github.com/iosis-tech/swiftness/blob/main/crates/air/src/layout/starknet/mod.rs#L525

More context:
This is due to verifier expects certain public memory fingerprint.
When we generate the proofs straight from Cairo1 the rust cairo-vm in proof_mode
has different memory fingerprint then python-vm in proof_mode

I created this #56 that just removes the vm specific final_pc check u can use it for now

Your proof is verified succesfully on branch https://github.com/iosis-tech/swiftness/tree/fix/final_pc
cd cli && cargo run --release --bin swiftness --features starknet,blake2s_248_lsb,stone6 --no-default-features -- --proof proof.json

@Okm165
Copy link
Contributor

Okm165 commented Dec 18, 2024

cargo run --release --bin swiftness --features starknet,blake2s_248_lsb,stone6 --no-default-features -- --proof proof.json 
    Finished `release` profile [optimized] target(s) in 0.04s
     Running `target/release/swiftness --proof proof.json`
(0x4ce57f0e77c4eb88291d6f5eebc334d2709efc403421dced632f24f48455b43, 0x2c97a976cb90de9489adf4a4b79a1e5661ad9ab3ac6a254f88f5b795ee6412)

@Okm165 Okm165 added bug Something isn't working enhancement New feature or request labels Dec 18, 2024
@Okm165 Okm165 self-assigned this Dec 18, 2024
@Okm165 Okm165 linked a pull request Dec 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants