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::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
|
||||
|
||||
use anyhow::{ensure, Result};
|
||||
|
||||
use crate::field::extension_field::Extendable;
|
||||
use crate::field::fft::{fft, ifft};
|
||||
use crate::field::field::Field;
|
||||
@ -139,19 +141,20 @@ impl<F: Field> PolynomialCoeffs<F> {
|
||||
self.padded(self.len() << rate_bits)
|
||||
}
|
||||
|
||||
pub(crate) fn pad(&mut self, new_len: usize) {
|
||||
assert!(
|
||||
pub(crate) fn pad(&mut self, new_len: usize) -> Result<()> {
|
||||
ensure!(
|
||||
new_len >= self.len(),
|
||||
"Trying to pad a polynomial of length {} to a length of {}.",
|
||||
self.len(),
|
||||
new_len
|
||||
);
|
||||
self.coeffs.resize(new_len, F::ZERO);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn padded(&self, new_len: usize) -> Self {
|
||||
let mut poly = self.clone();
|
||||
poly.pad(new_len);
|
||||
poly.pad(new_len).unwrap();
|
||||
poly
|
||||
}
|
||||
|
||||
|
||||
@ -107,7 +107,10 @@ pub(crate) fn prove<F: Extendable<D>, const D: usize>(
|
||||
.into_par_iter()
|
||||
.flat_map(|mut quotient_poly| {
|
||||
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.
|
||||
quotient_poly.chunks(degree)
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user