Skip to content

Commit

Permalink
Merge pull request #2887 from o1-labs/dw/mvpoly-forbid-mul-monomials
Browse files Browse the repository at this point in the history
MVPoly: additional checks reg. multiplication of polynomials
  • Loading branch information
dannywillems authored Dec 22, 2024
2 parents 09d4ce0 + acc6602 commit d1e0008
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mvpoly/src/monomials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ impl<const N: usize, const D: usize, F: PrimeField> Mul for Sparse<F, N, D> {

fn mul(self, other: Self) -> Self {
let mut monomials = HashMap::new();
let degree_lhs = unsafe { self.degree() };
let degree_rhs = unsafe { other.degree() };
assert!(degree_lhs + degree_rhs <= D, "The degree of the output is expected to be maximum {D}, but the resulting output would be larger than {D} ({res})", res=degree_lhs + degree_rhs);
self.monomials.iter().for_each(|(exponents1, coeff1)| {
other
.monomials
Expand Down

0 comments on commit d1e0008

Please sign in to comment.