diff --git a/src/ipa_pc/mod.rs b/src/ipa_pc/mod.rs index e069fee2..0fd249e7 100644 --- a/src/ipa_pc/mod.rs +++ b/src/ipa_pc/mod.rs @@ -187,9 +187,7 @@ impl InnerProductArgPC { supported_degree: usize, p: &LabeledPolynomial, ) -> Result<(), Error> { - if p.degree() < 1 { - return Err(Error::DegreeIsZero); - } else if p.degree() > supported_degree { + if p.degree() > supported_degree { return Err(Error::TooManyCoefficients { num_coefficients: p.degree() + 1, num_powers: supported_degree + 1, @@ -1085,6 +1083,12 @@ mod tests { type PC = InnerProductArgPC; type PC_DEE = PC; + #[test] + fn constant_poly_test() { + use crate::tests::*; + constant_poly_test::<_, PC_DEE>().expect("test failed for tweedle_dee-blake2s"); + } + #[test] fn single_poly_test() { use crate::tests::*; diff --git a/src/lib.rs b/src/lib.rs index ada1881b..983f6718 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -755,8 +755,11 @@ pub mod tests { let pp = PC::setup(max_degree, rng)?; for _ in 0..num_iters { - let supported_degree = supported_degree - .unwrap_or(rand::distributions::Uniform::from(1..=max_degree).sample(rng)); + let supported_degree = match supported_degree { + Some(0) => 0, + Some(d) => d, + None => rand::distributions::Uniform::from(1..=max_degree).sample(rng) + }; assert!( max_degree >= supported_degree, "max_degree < supported_degree" @@ -777,7 +780,11 @@ pub mod tests { for i in 0..num_polynomials { let label = format!("Test{}", i); labels.push(label.clone()); - let degree = rand::distributions::Uniform::from(1..=supported_degree).sample(rng); + let degree = if supported_degree > 0 { + rand::distributions::Uniform::from(1..=supported_degree).sample(rng) + } else { + 0 + }; let poly = Polynomial::rand(degree, rng); let degree_bound = if let Some(degree_bounds) = &mut degree_bounds { @@ -1042,6 +1049,23 @@ pub mod tests { Ok(()) } + pub fn constant_poly_test() -> Result<(), PC::Error> + where + F: Field, + PC: PolynomialCommitment, + { + let info = TestInfo { + num_iters: 100, + max_degree: None, + supported_degree: Some(0), + num_polynomials: 1, + enforce_degree_bounds: false, + max_num_queries: 1, + ..Default::default() + }; + test_template::(info) + } + pub fn single_poly_test() -> Result<(), PC::Error> where F: Field,