Avoid underflow when checking the length of terms

This commit is contained in:
wborgeaud 2021-11-15 19:46:28 +01:00
parent 49e4307820
commit 799ff26e71

View File

@ -107,7 +107,7 @@ impl<const D: usize> ReducingFactorTarget<D> {
let l = terms.len();
// For small reductions, use an arithmetic gate.
if l - 1 <= ArithmeticExtensionGate::<D>::new_from_config(&builder.config).num_ops {
if l <= ArithmeticExtensionGate::<D>::new_from_config(&builder.config).num_ops + 1 {
let terms_ext = terms
.iter()
.map(|&t| builder.convert_to_ext(t))
@ -162,7 +162,7 @@ impl<const D: usize> ReducingFactorTarget<D> {
let l = terms.len();
// For small reductions, use an arithmetic gate.
if l - 1 <= ArithmeticExtensionGate::<D>::new_from_config(&builder.config).num_ops {
if l <= ArithmeticExtensionGate::<D>::new_from_config(&builder.config).num_ops + 1 {
return self.reduce_arithmetic(terms, builder);
}