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

Why does fri_strep_list must start with 0x0? #54

Closed
tdelabro opened this issue Dec 18, 2024 · 3 comments · Fixed by #60
Closed

Why does fri_strep_list must start with 0x0? #54

tdelabro opened this issue Dec 18, 2024 · 3 comments · Fixed by #60
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@tdelabro
Copy link
Contributor

tdelabro commented Dec 18, 2024

The verification of my proof fails with error:

Caused by:
    0: Fri Error
    1: invalid first fri step

Looking at the code it appears this error is only raised in one place in the code, in crates/fri/src/config.rs:

impl Config {
    pub fn validate(
        &self,
        log_n_cosets: Felt,
        n_verifier_friendly_commitment_layers: Felt,
    ) -> Result<Felt, Error> {
        ...
        if *self.fri_step_sizes.first().ok_or(Error::FirstFriStepInvalid)? != Felt::ZERO {
            return Err(Error::FirstFriStepInvalid);
        }
        ...
    }

I debugged this and found the following value: fri_step_sizes: [0x4, 0x4, 0x4, 0x4], which match the content of my proof.json:

	"proof_parameters" : 
	{
		"field" : "PrimeField0",
		"stark" : 
		{
			"fri" : 
			{
				"fri_step_list" : 
				[
					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
	},

This value is inherited from my cpu_air_params.json file

{
    "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
}

which is fed to the prover:

cpu_air_prover \
  --out_file=$PROOF_OUTPUT_DIR/proof.json \
  --private_input_file=$TRACE_OUTPUT_DIR/private-input.json \
  --public_input_file=$TRACE_OUTPUT_DIR/public-input.json \
  --prover_config_file=$CFG_AND_PARAMS_DIR/cpu_air_prover_config.json \
  --parameter_file=$CFG_AND_PARAMS_DIR/cpu_air_params.json \
  --generate_annotations

Your code seems to expect the first value to be 0. Why is this a requirement?
If it has to be a requirement can you add it to the list of requirements you have for the prover config?

@Okm165 Okm165 added the documentation Improvements or additions to documentation label Dec 18, 2024
@Okm165 Okm165 self-assigned this Dec 18, 2024
@tdelabro
Copy link
Contributor Author

tdelabro commented Dec 18, 2024

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,
    )?;
    ...
}

@Okm165
Copy link
Contributor

Okm165 commented Dec 18, 2024

First FRI layer is for gather_first_layer_queries we denote it as a layer but with no folding action happening that is why 0x0.
It is analogous to the cairo0 STARK verifier

@Okm165
Copy link
Contributor

Okm165 commented Dec 18, 2024

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,
    )?;
    ...
}

I need more information to help, what is the layout u use?
How can i reproduce it? Do u have repo with it?
Issue continues here #55

@Okm165 Okm165 linked a pull request Dec 21, 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
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants