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

Marlin refactoring #34

Closed
wants to merge 70 commits into from
Closed

Marlin refactoring #34

wants to merge 70 commits into from

Conversation

lgiussan
Copy link

@lgiussan lgiussan commented Nov 12, 2021

This pull request addresses Issue #27.
The high level changes are the following:

  • There is no longer the need to explicitly pad R1CS matrices with dummy variables or constraints to make them square. Instead the padding is implicit in matrix-vector operations.
  • The UnnormalizedBivariateLagrangePoly is replaced with the normalized LagrangeKernel.
  • Matrix arithmetization is updated to use LagrangeKernel.
  • Prover no longer needs to supply an oracle for T_eta(alpha, X).
  • The query of the verifier to the oracle for T_eta(alpha, X) during outer sumcheck is substituted with the computation of the unique value v which satisfies the outer sumcheck. Later v is used in place of T_eta(alpha, beta) in the inner sumcheck. Explicit checking of the outer sumcheck equality is no longer needed with this optimization.
  • The names of some variables, functions, and files have been changed to better reflect the notation of https://arxiv.org/abs/2107.04315

@DanieleDiBenedetto
Copy link
Collaborator

DanieleDiBenedetto commented Jan 14, 2022

Okey I left unresolved the comment related to stuff that should be addressed in the monorepo.
When the monorepo branch is stable let's bring the current Marlin inside it.
Then we will open a PR addressing the remaining changes so we can keep track of them
PS. The ToBytes deprecation was already performed by me in ginger-lib's sponge branch, so no need to address it here anymore.

src/iop/prover.rs Outdated Show resolved Hide resolved
This was linked to issues Feb 21, 2022
Copy link

@UlrichHaboeck75 UlrichHaboeck75 left a comment

Choose a reason for hiding this comment

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

Most of my comments address outdated inline comments. However, two "major" findings:

  • The max_degree() function, which is used in the setup, does not use the correct formula.
  • The prover third round for the inner sumcheck seems to do some computations twice.

Details are found below.

README.md Outdated Show resolved Hide resolved
src/iop/mod.rs Outdated Show resolved Hide resolved
src/iop/mod.rs Outdated Show resolved Hide resolved
src/iop/mod.rs Outdated Show resolved Hide resolved
src/iop/mod.rs Outdated Show resolved Hide resolved
src/iop/prover.rs Outdated Show resolved Hide resolved
src/iop/prover.rs Outdated Show resolved Hide resolved
src/iop/prover.rs Outdated Show resolved Hide resolved
let dist = Bernoulli::new(fill_factor).unwrap();
let val: Vec<F> = (0..num_elems)
.map(|_| match dist.sample(rng) {
true => UniformRand::rand(rng),

Choose a reason for hiding this comment

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

Does UniformRand sample from the entire field?

src/iop/sparse_linear_algebra.rs Outdated Show resolved Hide resolved
@lgiussan
Copy link
Author

lgiussan commented Mar 4, 2022

Besides the requested changes, I did an additional change. At matrix construction time I re-index the columns of the matrix to be coherent with the treatment of public input domain X as a subdomain of the domain H. In this way there is no need to re-index matrix columns during computations.

Copy link

@UlrichHaboeck75 UlrichHaboeck75 left a comment

Choose a reason for hiding this comment

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

I added minor comments, which are not mandatory for a merge.

Comment on lines 277 to 279
a_arith: a_star_arith,
b_arith: b_star_arith,
c_arith: c_star_arith,

Choose a reason for hiding this comment

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

I would have renamed also here the *_star_arith to *_star.

Copy link
Author

Choose a reason for hiding this comment

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

Done

) -> Option<(SparseMatrix<F>, SparseMatrix<F>, SparseMatrix<F>)> {
balance_matrices(&mut cs.at, &mut cs.bt);

Choose a reason for hiding this comment

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

What is the reason for moving the balancer out of the function?

Copy link
Author

Choose a reason for hiding this comment

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

Now function to_matrix_helper()needs to take in input domain_h and domain_x, which are returned by function build_domains(). And build_domains() should be called after having called balance_matrices(), because balancing the matrices could possibly affect the size of the domains (more precisely of domain_k and domain_b).

/// Lagrange domain `domain_h`.
pub fn full_variable_vector(&self) -> Vec<F> {
let domain_x_size = self.domain_x.size();
let mut padded_public_input = vec![F::zero(); self.domain_h.size()];

Choose a reason for hiding this comment

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

Just a side question: Why don't we use slices in stead of vectors here? Do we really need the functionalities provided for vectors (such as appending/concatenating)?

Copy link
Author

Choose a reason for hiding this comment

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

The reason is that slices are just a pointer (plus length) to a contiguous sequence of data. A function cannot return references to data allocated inside the function itself, because they would be dangling references after the function returns.

let c_scaled_val_row_col_on_b = compute_scaled_val_row_col(c_arith, scaled_eta_c);
end_timer!(scale_val_row_col_time);

let step = Self::get_subdomain_step(&domain_b, &domain_k)?;

Choose a reason for hiding this comment

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

I would move the declaration of step after Line 701.

Copy link
Author

Choose a reason for hiding this comment

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

Done

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.

Cleaning up / refactoring Marlin Optimized zk randomization
4 participants