From 4a27a67bab071ee773ccf8515e98bead437ee55d Mon Sep 17 00:00:00 2001 From: wborgeaud Date: Tue, 6 Jul 2021 11:10:08 +0200 Subject: [PATCH] Constraint degree should be at least 3 --- src/circuit_builder.rs | 1 + src/util/partial_products.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/circuit_builder.rs b/src/circuit_builder.rs index 93b440ab..f1db3ae3 100644 --- a/src/circuit_builder.rs +++ b/src/circuit_builder.rs @@ -403,6 +403,7 @@ impl, const D: usize> CircuitBuilder { let gates = self.gates.iter().cloned().collect(); let (gate_tree, max_filtered_constraint_degree, num_constants) = Tree::from_gates(gates); + let max_filtered_constraint_degree = max_filtered_constraint_degree.max(3); let prefixed_gates = PrefixedGate::from_tree(gate_tree); let degree_bits = log2_strict(degree); diff --git a/src/util/partial_products.rs b/src/util/partial_products.rs index e7c9069b..c3e5c2cd 100644 --- a/src/util/partial_products.rs +++ b/src/util/partial_products.rs @@ -25,6 +25,7 @@ pub fn partial_products(v: &[T], max_degree: usize) -> Vec /// Returns a tuple `(a,b)`, where `a` is the length of the output of `partial_products()` on a /// vector of length `n`, and `b` is the number of elements needed to compute the final product. pub fn num_partial_products(n: usize, max_degree: usize) -> (usize, usize) { + debug_assert!(max_degree > 1); let mut res = 0; let mut remainder = n; while remainder > max_degree {