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

Increase blinding #148

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 36 additions & 33 deletions plonk-core/src/constraint_system/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,10 @@ where
where
R: CryptoRng + RngCore + ?Sized,
{
let mut rand_var_1 = self.zero_var();
let mut rand_var_2 = self.zero_var();
// Blinding wires
for _ in 0..2 {
rand_var_1 = self.add_input(F::rand(rng));
rand_var_2 = self.add_input(F::rand(rng));
for _ in 0..3 {
let rand_var_1 = self.add_input(F::rand(rng));
let rand_var_2 = self.add_input(F::rand(rng));
let rand_var_3 = self.add_input(F::rand(rng));
let rand_var_4 = self.add_input(F::rand(rng));

Expand All @@ -591,39 +589,44 @@ where
self.perm.add_variables_to_map(
rand_var_1, rand_var_2, rand_var_3, rand_var_4, self.n,
);

self.n += 1;
}

// Blinding Z
// We add 2 pairs of equal random points
// Blinding Z
// We add 2 pairs of equal random points
// When blinding Z we only need one random value in the rows. This
// is because Z is computed compressing the the wire columns. We need a
// second random value here, so we can later swap them creating a
// non trivial permutation.

self.w_l.push(rand_var_1);
self.w_r.push(rand_var_2);
self.w_o.push(self.zero_var());
self.w_4.push(self.zero_var());
self.w_l.push(rand_var_1);
self.w_r.push(rand_var_2);
self.w_o.push(self.zero_var());
self.w_4.push(self.zero_var());

// All selectors fixed to 0 so that the constraints are satisfied
self.q_m.push(F::zero());
self.q_l.push(F::zero());
self.q_r.push(F::zero());
self.q_o.push(F::zero());
self.q_c.push(F::zero());
self.q_4.push(F::zero());
self.q_arith.push(F::zero());
self.q_range.push(F::zero());
self.q_logic.push(F::zero());
self.q_fixed_group_add.push(F::zero());
self.q_variable_group_add.push(F::zero());
self.q_lookup.push(F::zero());
// All selectors fixed to 0 so that the constraints are satisfied
self.q_m.push(F::zero());
self.q_l.push(F::zero());
self.q_r.push(F::zero());
self.q_o.push(F::zero());
self.q_c.push(F::zero());
self.q_4.push(F::zero());
self.q_arith.push(F::zero());
self.q_range.push(F::zero());
self.q_logic.push(F::zero());
self.q_fixed_group_add.push(F::zero());
self.q_variable_group_add.push(F::zero());
self.q_lookup.push(F::zero());

self.perm.add_variables_to_map(
rand_var_1,
rand_var_2,
self.zero_var(),
self.zero_var(),
self.n,
);
self.n += 1;
self.perm.add_variables_to_map(
rand_var_1,
rand_var_2,
self.zero_var(),
self.zero_var(),
self.n,
);
self.n += 1;
}
}
/// Utility function that checks on the "front-end"
/// side of the PLONK implementation if the identity polynomial
Expand Down