mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 16:23:12 +00:00
Better error message when quotient hasn't correct degree
This commit is contained in:
parent
3ce9183970
commit
2e9d3f768e
@ -2,6 +2,8 @@ use std::cmp::max;
|
|||||||
use std::iter::Sum;
|
use std::iter::Sum;
|
||||||
use std::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
|
use std::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
|
||||||
|
|
||||||
|
use anyhow::{ensure, Result};
|
||||||
|
|
||||||
use crate::field::extension_field::Extendable;
|
use crate::field::extension_field::Extendable;
|
||||||
use crate::field::fft::{fft, ifft};
|
use crate::field::fft::{fft, ifft};
|
||||||
use crate::field::field::Field;
|
use crate::field::field::Field;
|
||||||
@ -139,19 +141,20 @@ impl<F: Field> PolynomialCoeffs<F> {
|
|||||||
self.padded(self.len() << rate_bits)
|
self.padded(self.len() << rate_bits)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn pad(&mut self, new_len: usize) {
|
pub(crate) fn pad(&mut self, new_len: usize) -> Result<()> {
|
||||||
assert!(
|
ensure!(
|
||||||
new_len >= self.len(),
|
new_len >= self.len(),
|
||||||
"Trying to pad a polynomial of length {} to a length of {}.",
|
"Trying to pad a polynomial of length {} to a length of {}.",
|
||||||
self.len(),
|
self.len(),
|
||||||
new_len
|
new_len
|
||||||
);
|
);
|
||||||
self.coeffs.resize(new_len, F::ZERO);
|
self.coeffs.resize(new_len, F::ZERO);
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn padded(&self, new_len: usize) -> Self {
|
pub(crate) fn padded(&self, new_len: usize) -> Self {
|
||||||
let mut poly = self.clone();
|
let mut poly = self.clone();
|
||||||
poly.pad(new_len);
|
poly.pad(new_len).unwrap();
|
||||||
poly
|
poly
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -107,7 +107,10 @@ pub(crate) fn prove<F: Extendable<D>, const D: usize>(
|
|||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.flat_map(|mut quotient_poly| {
|
.flat_map(|mut quotient_poly| {
|
||||||
quotient_poly.trim();
|
quotient_poly.trim();
|
||||||
quotient_poly.pad(quotient_degree);
|
quotient_poly.pad(quotient_degree).expect(
|
||||||
|
"The quotient polynomial doesn't have the right degree.\
|
||||||
|
This may be because the `Z`s polynomials are still too high degree.",
|
||||||
|
);
|
||||||
// Split t into degree-n chunks.
|
// Split t into degree-n chunks.
|
||||||
quotient_poly.chunks(degree)
|
quotient_poly.chunks(degree)
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user