From d1132cc3cb526e9dda0176e9841517bb0db8d1ff Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:07:09 +0000 Subject: [PATCH 1/2] fix: correct type checking to handle `false` bools --- crates/noirc_abi/src/input_parser/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/noirc_abi/src/input_parser/mod.rs b/crates/noirc_abi/src/input_parser/mod.rs index 368adb45cfb..b69637486a3 100644 --- a/crates/noirc_abi/src/input_parser/mod.rs +++ b/crates/noirc_abi/src/input_parser/mod.rs @@ -28,7 +28,7 @@ impl InputValue { (InputValue::Field(field_element), AbiType::Integer { width, .. }) => { field_element.num_bits() <= *width } - (InputValue::Field(field_element), AbiType::Boolean) => field_element.num_bits() == 1, + (InputValue::Field(field_element), AbiType::Boolean) => field_element.num_bits() <= 1, (InputValue::Vec(field_elements), AbiType::Array { length, typ, .. }) => { if field_elements.len() != *length as usize { From c2f9875cfb651f96e820eb35bcec41652fc15af3 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Wed, 22 Feb 2023 10:44:43 +0000 Subject: [PATCH 2/2] chore: replace abi type match check for bools with explicit equality check --- crates/noirc_abi/src/input_parser/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/noirc_abi/src/input_parser/mod.rs b/crates/noirc_abi/src/input_parser/mod.rs index b69637486a3..352694821e2 100644 --- a/crates/noirc_abi/src/input_parser/mod.rs +++ b/crates/noirc_abi/src/input_parser/mod.rs @@ -28,7 +28,9 @@ impl InputValue { (InputValue::Field(field_element), AbiType::Integer { width, .. }) => { field_element.num_bits() <= *width } - (InputValue::Field(field_element), AbiType::Boolean) => field_element.num_bits() <= 1, + (InputValue::Field(field_element), AbiType::Boolean) => { + field_element.is_one() || field_element.is_zero() + } (InputValue::Vec(field_elements), AbiType::Array { length, typ, .. }) => { if field_elements.len() != *length as usize {