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

Contain queries in FRI. #355

Merged
merged 1 commit into from
Feb 20, 2024
Merged

Contain queries in FRI. #355

merged 1 commit into from
Feb 20, 2024

Conversation

alonh5
Copy link
Contributor

@alonh5 alonh5 commented Feb 18, 2024

This change is Reviewable

Copy link
Contributor Author

@alonh5 alonh5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @andrewmilson, @shaharsamocha7, and @spapinistarkware)


src/core/fri.rs line 330 at r1 (raw file):

            last_layer_domain,
            last_layer_poly,
            queries: None,

Not sure about this but I couldn't find another way to contain the queries inside the FRI protocol. Would be happy to hear what you think.

@alonh5 alonh5 force-pushed the 02-18-Get_opening_positions_from_FRI branch from bccbf21 to 3315d99 Compare February 18, 2024 13:37
@alonh5 alonh5 force-pushed the 02-18-Contain_queries_in_FRI branch 2 times, most recently from 775f7b7 to 079069a Compare February 18, 2024 13:45
Copy link
Contributor

@andrewmilson andrewmilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 files reviewed, 4 unresolved discussions (waiting on @alonh5, @shaharsamocha7, and @spapinistarkware)


src/core/fri.rs line 330 at r1 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

Not sure about this but I couldn't find another way to contain the queries inside the FRI protocol. Would be happy to hear what you think.

LGTM but do you mind documenting it?


src/core/fri.rs line 348 at r2 (raw file):

        decommitted_values: Vec<SparseCircleEvaluation<SecureField>>,
    ) -> Result<(), VerificationError> {
        let queries = self.queries.clone().unwrap();

Suggestion

Code snippet:

let queries = self.queries.as_ref().unwrap();

src/core/fri.rs line 361 at r2 (raw file):

        SecureField: ExtensionOf<F>,
    {
        assert_eq!(queries.log_domain_size, self.expected_query_log_domain_size);

Can we add an assertion

Code snippet:

assert_eq!(queries.len(), self.config.n_queries);

src/core/fri.rs line 439 at r2 (raw file):

    }

    pub fn opening_positions(

Can you add documentation please? and add a test for this and D

Also, what do you think about renaming it column_opening_positions?


src/core/fri.rs line 450 at r2 (raw file):

        let queries = Queries::generate(channel, column_log_sizes[0], self.config.n_queries);
        self.queries = Some(queries.clone());
        get_opening_positions(&queries, &column_log_sizes)

Suggestion:

Code snippet:

let res = get_opening_positions(&queries, &column_log_sizes);
self.queries = Some(queries);
res

@alonh5 alonh5 force-pushed the 02-18-Get_opening_positions_from_FRI branch from 3315d99 to a9e47a9 Compare February 19, 2024 10:51
@alonh5 alonh5 force-pushed the 02-18-Contain_queries_in_FRI branch from 079069a to 8bf0292 Compare February 19, 2024 12:49
Copy link
Contributor Author

@alonh5 alonh5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 files reviewed, 4 unresolved discussions (waiting on @andrewmilson, @shaharsamocha7, and @spapinistarkware)


src/core/fri.rs line 330 at r1 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

LGTM but do you mind documenting it?

Done.


src/core/fri.rs line 348 at r2 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

Suggestion

Done. I had make some methods get self by reference, does that look fine to you?


src/core/fri.rs line 361 at r2 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

Can we add an assertion

Same as in the previous PR (this assertion is problematic because the queries are deduped which could cause the actual query number to be less than the config).


src/core/fri.rs line 439 at r2 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

Can you add documentation please? and add a test for this and D

Also, what do you think about renaming it column_opening_positions?

Done.


src/core/fri.rs line 450 at r2 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

Suggestion:

Done.

@alonh5 alonh5 force-pushed the 02-18-Get_opening_positions_from_FRI branch from a9e47a9 to d4c0d58 Compare February 19, 2024 14:49
@alonh5 alonh5 force-pushed the 02-18-Contain_queries_in_FRI branch from 8bf0292 to e5cc06e Compare February 19, 2024 14:49
Copy link
Contributor

@andrewmilson andrewmilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 6 unresolved discussions (waiting on @alonh5, @shaharsamocha7, and @spapinistarkware)


src/core/fri.rs line 348 at r2 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

Done. I had make some methods get self by reference, does that look fine to you?

To keep it owned can do let queries = self.queries.take().expect("queries not sampled")


src/core/fri.rs line 361 at r2 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

Same as in the previous PR (this assertion is problematic because the queries are deduped which could cause the actual query number to be less than the config).

Ahh yeah forgot about that. Thanks


src/core/fri.rs line 256 at r3 (raw file):

    last_layer_poly: LinePoly<SecureField>,
    /// The queries used for decommitment. Initialized when calling
    /// `self.column_opening_positions`.

Can do [`FriVerifier::column_opening_positions`] to make it link


src/core/fri.rs line 1228 at r3 (raw file):

    #[test]
    fn test_opening_positions() {

Personally I think this test should be removed since it's looking a bit like a change detector test https://testing.googleblog.com/2015/01/testing-on-toilet-change-detector-tests.html

I think it's better to just have the valid_mixed_degree_end_to_end_proof_passes_verification test and add an assert that verifier.column_opening_positions equals what prover.decommit returns.

@alonh5 alonh5 force-pushed the 02-18-Get_opening_positions_from_FRI branch 2 times, most recently from a943eb7 to 83f0e3e Compare February 19, 2024 15:52
@alonh5 alonh5 force-pushed the 02-18-Contain_queries_in_FRI branch from e5cc06e to 62b0dcf Compare February 19, 2024 16:20
Copy link
Contributor Author

@alonh5 alonh5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 6 unresolved discussions (waiting on @andrewmilson, @shaharsamocha7, and @spapinistarkware)


src/core/fri.rs line 348 at r2 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

To keep it owned can do let queries = self.queries.take().expect("queries not sampled")

Done.


src/core/fri.rs line 361 at r2 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

Ahh yeah forgot about that. Thanks

Done.


src/core/fri.rs line 256 at r3 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

Can do [`FriVerifier::column_opening_positions`] to make it link

Cool, thanks.


src/core/fri.rs line 1228 at r3 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

Personally I think this test should be removed since it's looking a bit like a change detector test https://testing.googleblog.com/2015/01/testing-on-toilet-change-detector-tests.html

I think it's better to just have the valid_mixed_degree_end_to_end_proof_passes_verification test and add an assert that verifier.column_opening_positions equals what prover.decommit returns.

Good idea. Thanks.

@alonh5 alonh5 force-pushed the 02-18-Get_opening_positions_from_FRI branch from 83f0e3e to e87e5dd Compare February 19, 2024 16:24
@alonh5 alonh5 force-pushed the 02-18-Contain_queries_in_FRI branch from 62b0dcf to 1d3e659 Compare February 19, 2024 16:24
Copy link
Contributor

@andrewmilson andrewmilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: 0 of 3 files reviewed, 7 unresolved discussions (waiting on @alonh5, @shaharsamocha7, and @spapinistarkware)


src/core/fri.rs line 439 at r2 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

Done.

Might be worth mentioning that the order of the SparseSubCircleDomains matches the order of column commitment.


src/core/fri.rs line 1067 at r5 (raw file):

        let bounds = LOG_DEGREES.map(CirclePolyDegreeBound::new).to_vec();
        let mut verifier = FriVerifier::commit(&mut test_channel(), config, proof, bounds).unwrap();
        let verifier_opening_positions = verifier.column_opening_positions(&mut test_channel());

Can we keep it arrange act assert.

Code snippet:

fn column_opening_positions_for_mixed_degree_are_valid() -> Result<(), VerificationError> {
    ...
    let mut verifier = FriVerifier::commit(&mut test_channel(), config, proof, bounds).unwrap();
    
    let verifier_opening_positions = verifier.decommit(decommitment_values);
    
    assert_eq!(prover_opening_positions, verifier_opening_positions);
    verifier.decommit(decommitment_values)
}

Copy link
Contributor Author

@alonh5 alonh5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 7 unresolved discussions (waiting on @andrewmilson, @shaharsamocha7, and @spapinistarkware)


src/core/fri.rs line 439 at r2 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

Might be worth mentioning that the order of the SparseSubCircleDomains matches the order of column commitment.

Done.


src/core/fri.rs line 1067 at r5 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

Can we keep it arrange act assert.

Done. Regarding the test name proposal, I think it's mainly testing the protocol end to end and secondarily testing the column opening positions, so I kept the name as is and included the verifier commitment in the "act" stage.

@alonh5 alonh5 force-pushed the 02-18-Contain_queries_in_FRI branch from 1d3e659 to 2a3e8c0 Compare February 20, 2024 08:29
@alonh5 alonh5 mentioned this pull request Feb 20, 2024
@alonh5 alonh5 force-pushed the 02-18-Get_opening_positions_from_FRI branch from e87e5dd to 29a3ed9 Compare February 20, 2024 12:50
@alonh5 alonh5 force-pushed the 02-18-Contain_queries_in_FRI branch from 2a3e8c0 to d75a7d2 Compare February 20, 2024 12:50
@alonh5 alonh5 force-pushed the 02-18-Get_opening_positions_from_FRI branch from 29a3ed9 to a224718 Compare February 20, 2024 13:51
Copy link
Contributor

@andrewmilson andrewmilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 3 files at r3, 2 of 2 files at r6, all commit messages.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @alonh5, @shaharsamocha7, and @spapinistarkware)


src/core/fri.rs line 1067 at r5 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

Done. Regarding the test name proposal, I think it's mainly testing the protocol end to end and secondarily testing the column opening positions, so I kept the name as is and included the verifier commitment in the "act" stage.

SGTM

Copy link
Contributor Author

@alonh5 alonh5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @andrewmilson, @shaharsamocha7, and @spapinistarkware)


src/core/fri.rs line 1067 at r5 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

SGTM

Done.

@alonh5 alonh5 force-pushed the 02-18-Get_opening_positions_from_FRI branch from a224718 to cf0b4d1 Compare February 20, 2024 14:20
@alonh5 alonh5 force-pushed the 02-18-Contain_queries_in_FRI branch from a361ae2 to 0b08352 Compare February 20, 2024 14:20
@alonh5 alonh5 force-pushed the 02-18-Get_opening_positions_from_FRI branch from cf0b4d1 to afec224 Compare February 20, 2024 14:26
@alonh5 alonh5 force-pushed the 02-18-Contain_queries_in_FRI branch from 0b08352 to 3d7e129 Compare February 20, 2024 14:28
Copy link
Contributor

@andrewmilson andrewmilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @shaharsamocha7 and @spapinistarkware)

andrewmilson
andrewmilson previously approved these changes Feb 20, 2024
Copy link
Contributor

@andrewmilson andrewmilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: 1 of 3 files reviewed, all discussions resolved (waiting on @shaharsamocha7 and @spapinistarkware)

@alonh5 alonh5 changed the base branch from 02-18-Get_opening_positions_from_FRI to dev February 20, 2024 15:18
@alonh5 alonh5 dismissed andrewmilson’s stale review February 20, 2024 15:18

The base branch was changed.

@alonh5 alonh5 force-pushed the 02-18-Contain_queries_in_FRI branch 3 times, most recently from af57fa7 to 841f576 Compare February 20, 2024 15:31
Copy link
Contributor

@andrewmilson andrewmilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 3 files reviewed, 2 unresolved discussions (waiting on @alonh5, @shaharsamocha7, and @spapinistarkware)


src/core/fri.rs line 457 at r8 (raw file):

    /// Samples queries and returns the opening positions for each unique column size.
    /// The order of the opening positions corresponds to the order of the column commitment.

nit: https://doc.rust-lang.org/rustdoc/how-to-write-documentation.html#documenting-components

Code snippet:

/// Samples queries and returns the opening positions for each unique column size.
///
/// The order of the opening positions corresponds to the order of the column commitment.

src/core/fri.rs line 476 at r8 (raw file):

/// Returns the column opening positions needed for verification.
/// The domain log sizes must be unique and in descending order.

nit: https://doc.rust-lang.org/rustdoc/how-to-write-documentation.html#documenting-components

Code snippet:

/// Returns the column opening positions needed for verification.
///
/// The domain log sizes must be unique and in descending order.

@alonh5 alonh5 force-pushed the 02-18-Contain_queries_in_FRI branch from 841f576 to 724f03a Compare February 20, 2024 15:39
Copy link
Contributor

@andrewmilson andrewmilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 2 files at r7, 1 of 1 files at r10, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @shaharsamocha7 and @spapinistarkware)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants