From a46f4a193388d7f73b68ea5873afe9a34e0c4cf5 Mon Sep 17 00:00:00 2001 From: Enrico Bottazzi <85900164+enricobottazzi@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:32:55 +0100 Subject: [PATCH] feat: minor efficiency improvement --- src/poly_chip.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/poly_chip.rs b/src/poly_chip.rs index f599b4e..c9cd091 100644 --- a/src/poly_chip.rs +++ b/src/poly_chip.rs @@ -294,8 +294,7 @@ impl PolyChip { for coeff in self.assigned_coefficients.iter() { // First of all, enforce that coefficient is in the [0, 2^y_bits] range - let bool = range.is_less_than_safe(ctx, *coeff, (1 << y_bits) + 1); - range.gate().assert_is_const(ctx, &bool, &F::from(1)); + range.check_less_than_safe(ctx, *coeff, (1 << y_bits) + 1); // Check for the range [0, z] // coeff is known are known to have <= `y_bits` bits according to the constraint set above @@ -381,11 +380,11 @@ impl PolyChip { } /// Safely trim the first leading zeroes of the polynomial up to `degree` - /// Example: if self of degree 8 is [0, 0, 1, 1, 1, 1, 1, 1, 1] and degree = 6, then the output is [1, 1, 1, 1, 1, 1, 1] + /// Example: if self of degree 8 is `[0, 0, 1, 1, 1, 1, 1, 1, 1]` and degree = 6, then the output is `[1, 1, 1, 1, 1, 1, 1]` /// /// # Assumptions - /// * The first `degree` coefficients of the polynomial are known to be zero, otherwise the constraint will fail - /// * `degree` <= `self.degree`` + /// * The first `self.degree - degree` coefficients of the polynomial are known to be zero, otherwise the constraint will fail + /// * `degree <= self.degree` fn safe_trim_leading_zeroes( &self, ctx: &mut Context,