File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -370,10 +370,8 @@ where
370370 Ok ( result)
371371 }
372372
373- pub ( crate ) fn check_degree_is_too_large (
374- num_coefficients : usize ,
375- num_powers : usize ,
376- ) -> Result < ( ) , Error > {
373+ pub ( crate ) fn check_degree_is_too_large ( degree : usize , num_powers : usize ) -> Result < ( ) , Error > {
374+ let num_coefficients = degree + 1 ;
377375 if num_coefficients > num_powers {
378376 Err ( Error :: TooManyCoefficients {
379377 num_coefficients,
@@ -642,4 +640,17 @@ mod tests {
642640 batch_check_test_template :: < Bls12_377 , UniPoly_377 > ( ) . expect ( "test failed for bls12-377" ) ;
643641 batch_check_test_template :: < Bls12_381 , UniPoly_381 > ( ) . expect ( "test failed for bls12-381" ) ;
644642 }
643+
644+ #[ test]
645+ fn test_degree_is_too_large ( ) {
646+ let rng = & mut test_rng ( ) ;
647+
648+ let max_degree = 123 ;
649+ let pp = KZG_Bls12_381 :: setup ( max_degree, false , rng) . unwrap ( ) ;
650+ let ( powers, _) = KZG_Bls12_381 :: trim ( & pp, max_degree) . unwrap ( ) ;
651+
652+ let p = DensePoly :: < Fr > :: rand ( max_degree + 1 , rng) ;
653+ assert ! ( p. degree( ) > max_degree) ;
654+ assert ! ( KZG_Bls12_381 :: check_degree_is_too_large( p. degree( ) , powers. size( ) ) . is_err( ) ) ;
655+ }
645656}
You can’t perform that action at this time.
0 commit comments