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

MSM/Serialization: start lookup #1944

Merged

Conversation

dannywillems
Copy link
Member

@dannywillems dannywillems commented Mar 8, 2024

Constraints coming in a follow-up PR.
We can verify that the commitments are handled properly by commenting in the verifier the absorption of the multiplicities, for instance.

@dannywillems dannywillems self-assigned this Mar 8, 2024
@dannywillems dannywillems added the enhancement New feature or request label Mar 8, 2024
@dannywillems dannywillems marked this pull request as draft March 8, 2024 15:22
@dannywillems dannywillems marked this pull request as ready for review March 12, 2024 10:11
@dannywillems dannywillems force-pushed the dw/implement-lookup-rangecheck-msm-serialization branch 3 times, most recently from ef67192 to bc46279 Compare March 12, 2024 10:53
Self::RangeCheck15 => (0..(1 << 15))
.map(|i| Lookup {
table_id: LookupTable::RangeCheck15,
numerator: -F::one(),
Copy link
Member

Choose a reason for hiding this comment

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

Why are these -1 by default? I'd assume that by default we are not using any of the elements, so they should have 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Ah, ok, I think I misunderstood what this function does. Please tell me if I'm right: what you're doing is given a fixed table you're building a set of queries for that table covering every element of this table?

@@ -102,11 +145,83 @@ mod tests {
constraints.push(cst.clone())
}
}

for (j, lookup) in witness_env.rangecheck4_lookups.iter().enumerate() {
Copy link
Member

Choose a reason for hiding this comment

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

Probably next step, but this code that collects something from witness and passes to MVLookup can be arguably moved to witness.rs so that witness_env.get_inputs would give you the inputs directly

pub lookup_t_multiplicities_rangecheck4: Box<[Fp; 1 << 4]>,

/// Keep track of the RangeCheck15 lookup multiplicities
/// No t multiplicities as we do suppose we have a domain of
Copy link
Member

Choose a reason for hiding this comment

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

How does this work? You still need to construct the multiplicities for t, I guess you wanted to say that it's easier in the case of 2^15 domain size, but why? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@volhovm volhovm Mar 12, 2024

Choose a reason for hiding this comment

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

I thought (14) does not apply to our case because our t(x) is fully injective, since every element in the range table is unique? Why do we need normalised multiplicities?

&self,
_domain: EvaluationDomains<Fp>,
) -> Vec<Fp> {
self.lookup_multiplicities_rangecheck15.to_vec()
Copy link
Member

Choose a reason for hiding this comment

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

Ah OK, answered my own question about why 15bit case does not have t. The multiplicities are /exactly/ equal to the "called" vector that we build in the witness, so they are much easier to compute.

.into_iter()
.zip(self.lookup_t_multiplicities_rangecheck4.iter())
.enumerate()
.for_each(|(i, (m_f, m_t))| m[i] = m_f / m_t);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to do this (field? or is it integer?) division here? Is it related to the dummy values?..

Copy link
Member Author

Choose a reason for hiding this comment

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

rangecheck15[j].push(lookup.clone())
}

witness_env.add_rangecheck4_table_value(i);
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this needs to be called somewhere from range_check4() function on the witness impl InterpreterEnv side, no?

Copy link
Member Author

@dannywillems dannywillems Mar 12, 2024

Choose a reason for hiding this comment

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

I would like to move it somewhere else, yes. The table should be built outside the interpreter as it is a fixed table. We should have a way to handle multiple domain sizes.

if i < (1 << 4) {
self.lookup_t_multiplicities_rangecheck4[i] += Fp::one();
} else {
self.lookup_t_multiplicities_rangecheck4[0] += Fp::one();
Copy link
Member

Choose a reason for hiding this comment

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

Is this dummy value handling? Wondering if it's not bringing any soundness issues, since in the first if case you also add to the [0] element, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

@dannywillems dannywillems force-pushed the dw/implement-lookup-rangecheck-msm-serialization branch from bc46279 to c9690f2 Compare March 12, 2024 11:04
@dannywillems dannywillems merged commit dc4dc9c into master Mar 12, 2024
4 checks passed
@dannywillems dannywillems deleted the dw/implement-lookup-rangecheck-msm-serialization branch March 12, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants