Skip to content

Commit 5bef51c

Browse files
committed
Use new division in VID prover
1 parent 934f30e commit 5bef51c

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

saffron/src/vid.rs

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub fn divide_by_sub_vanishing_poly(
4848
// which can be computed using the following algorithm.
4949
//
5050

51+
// TODO parallelise
5152
let mut quotient_vec = poly.coeffs[domain_size..].to_vec();
5253
//println!("poly.len(): {:?}", poly.len());
5354
//assert!(poly.len() / domain_size <= 2);
@@ -208,17 +209,21 @@ where
208209

209210
assert!(all_divisors[5].evaluate(&all_omegas[per_node_size + 5]) == ScalarField::zero());
210211

211-
for i in 0..proofs_number {
212+
for node_ix in 0..proofs_number {
212213
// TEMPORARILY skip most iterations
213-
if i > 4 {
214+
if node_ix > 4 {
214215
continue;
215216
}
216217

217-
println!("Creating proof number {:?}", i);
218-
let indices: Vec<usize> = (0..per_node_size).map(|j| j * proofs_number + i).collect();
218+
println!("Creating proof number {:?}", node_ix);
219+
let indices: Vec<usize> = (0..per_node_size)
220+
.map(|j| j * proofs_number + node_ix)
221+
.collect();
222+
223+
let coset_omega = all_omegas[node_ix * per_node_size].clone();
219224

220225
for j in indices.iter() {
221-
assert!(all_divisors[i].evaluate(&all_omegas[*j]) == ScalarField::zero());
226+
assert!(all_divisors[node_ix].evaluate(&all_omegas[*j]) == ScalarField::zero());
222227
}
223228

224229
println!("Quotient");
@@ -240,20 +245,25 @@ where
240245
println!("Division");
241246
// We compute the polynomial t(X) by dividing the constraints polynomial
242247
// by the vanishing polynomial, i.e. Z_H(X).
243-
let (quotient, res) = DenseOrSparsePolynomial::divide_with_q_and_r(
244-
&From::from(numerator_eval_interpolated),
245-
&From::from(all_divisors[i].clone()),
246-
)
247-
.unwrap();
248-
249-
// As the constraints must be verified on H, the rest of the division
250-
// must be equal to 0 as the constraints polynomial and Z_H(X) are both
251-
// equal on H.
252-
if !res.is_zero() {
253-
println!("res degree: {:?}", res.degree());
254-
let fail_final_q_division = || panic!("Division by poly must not fail");
255-
fail_final_q_division();
256-
}
248+
let quotient = divide_by_sub_vanishing_poly(
249+
&numerator_eval_interpolated,
250+
per_node_size,
251+
coset_omega,
252+
);
253+
// let (quotient, res) = DenseOrSparsePolynomial::divide_with_q_and_r(
254+
// &From::from(numerator_eval_interpolated),
255+
// &From::from(all_divisors[i].clone()),
256+
// )
257+
// .unwrap();
258+
259+
// // As the constraints must be verified on H, the rest of the division
260+
// // must be equal to 0 as the constraints polynomial and Z_H(X) are both
261+
// // equal on H.
262+
// if !res.is_zero() {
263+
// println!("res degree: {:?}", res.degree());
264+
// let fail_final_q_division = || panic!("Division by poly must not fail");
265+
// fail_final_q_division();
266+
// }
257267

258268
quotient
259269
};

0 commit comments

Comments
 (0)