From e1c336b99c5b0e7ebbb2bd00adc957845c206b5d Mon Sep 17 00:00:00 2001 From: thealmarty <“thealmartyblog@gmail.com”> Date: Mon, 18 Mar 2024 09:49:05 -0700 Subject: [PATCH] Fix constraint and test. --- alu_u32/src/lt/columns.rs | 2 +- alu_u32/src/lt/mod.rs | 2 +- alu_u32/src/lt/stark.rs | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/alu_u32/src/lt/columns.rs b/alu_u32/src/lt/columns.rs index 633baf2..55fa10c 100644 --- a/alu_u32/src/lt/columns.rs +++ b/alu_u32/src/lt/columns.rs @@ -10,7 +10,7 @@ pub struct Lt32Cols { pub input_2: Word, /// Boolean flags indicating which byte pair differs - pub byte_flag: [T; 3], + pub byte_flag: [T; 4], /// Bit decomposition of 256 + input_1 - input_2 pub bits: [T; 10], diff --git a/alu_u32/src/lt/mod.rs b/alu_u32/src/lt/mod.rs index c6ea04b..59f2aba 100644 --- a/alu_u32/src/lt/mod.rs +++ b/alu_u32/src/lt/mod.rs @@ -121,7 +121,7 @@ impl Lt32Chip { for i in 0..10 { cols.bits[i] = F::from_canonical_u16(z >> i & 1); } - if n < 3 { + if n < 4 { cols.byte_flag[n] = F::one(); } } diff --git a/alu_u32/src/lt/stark.rs b/alu_u32/src/lt/stark.rs index 44e7cb2..2180ce5 100644 --- a/alu_u32/src/lt/stark.rs +++ b/alu_u32/src/lt/stark.rs @@ -68,13 +68,10 @@ where .when_ne(local.bits[8], AB::Expr::one()) .assert_one(local.output); // output should be 1 if is_lte & input_1 == input_2 + let all_flag_sum = flag_sum + local.byte_flag[3]; builder .when(local.is_lte) - .when_ne(flag_sum, AB::Expr::one()) - .when_ne( - AB::Expr::from_canonical_u32(256) + local.input_1[3] - local.input_2[3], - AB::Expr::one(), - ) + .when_ne(all_flag_sum, AB::Expr::one()) .assert_one(local.output); // Check bit decomposition