From ae26b318d38e9de17b3865d153bd4706d7b3601a Mon Sep 17 00:00:00 2001 From: Federica Date: Tue, 30 May 2023 11:12:44 -0300 Subject: [PATCH 1/5] Add `as_int` logic to `assert_250_bit` hint --- src/hint_processor/builtin_hint_processor/math_utils.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hint_processor/builtin_hint_processor/math_utils.rs b/src/hint_processor/builtin_hint_processor/math_utils.rs index c7bb66058e..20b758155c 100644 --- a/src/hint_processor/builtin_hint_processor/math_utils.rs +++ b/src/hint_processor/builtin_hint_processor/math_utils.rs @@ -554,11 +554,12 @@ pub fn assert_250_bit( //Declare constant values let upper_bound = Felt252::one().shl(250u32); let shift = Felt252::one().shl(128u32); - let value = get_integer_from_var_name("value", vm, ids_data, ap_tracking)?; + let value = Felt252::from( + get_integer_from_var_name("value", vm, ids_data, ap_tracking)?.to_signed_felt(), + ); //Main logic - //can be deleted - if value.as_ref() > &upper_bound { - return Err(HintError::ValueOutside250BitRange(value.into_owned())); + if &value > &upper_bound { + return Err(HintError::ValueOutside250BitRange(value)); } let (high, low) = value.div_rem(&shift); insert_value_from_var_name("high", high, vm, ids_data, ap_tracking)?; From 95de634c7fa1ccd1a5784b2cca2769aadec26a64 Mon Sep 17 00:00:00 2001 From: Federica Date: Tue, 30 May 2023 12:11:01 -0300 Subject: [PATCH 2/5] Remove uneeded to_signed_felt in `SIGNED_DIV_REM` hint --- src/hint_processor/builtin_hint_processor/math_utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hint_processor/builtin_hint_processor/math_utils.rs b/src/hint_processor/builtin_hint_processor/math_utils.rs index 20b758155c..9225d94aa7 100644 --- a/src/hint_processor/builtin_hint_processor/math_utils.rs +++ b/src/hint_processor/builtin_hint_processor/math_utils.rs @@ -476,8 +476,8 @@ pub fn signed_div_rem( } let int_value = value.to_signed_felt(); - let int_div = div.to_signed_felt(); - let int_bound = bound.to_signed_felt(); + let int_div = div.to_bigint(); + let int_bound = bound.to_bigint(); let (q, r) = int_value.div_mod_floor(&int_div); if int_bound.abs() < q.abs() { From 47db38138058916b094c760930cd1df41754b85a Mon Sep 17 00:00:00 2001 From: Federica Date: Tue, 30 May 2023 12:35:46 -0300 Subject: [PATCH 3/5] Add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6804e66af..1b2c3edfaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ #### Upcoming Changes +* fix: Fix 'as_int' conversion usage in hints `ASSERT_250_BIt` & `SIGNED_DIV_REM` [#1191](https://github.com/lambdaclass/cairo-rs/pull/1191) + * bugfix: Fix `EC_DOUBLE_ASSIGN_NEW_X_V2` hint not taking `SECP_P` value from the current execution scope [#1186](https://github.com/lambdaclass/cairo-rs/pull/1186) * Fix possible subtraction overflow in `QUAD_BIT` & `DI_BIT` hints [#1185](https://github.com/lambdaclass/cairo-rs/pull/1185) From 99b43647d5fd0f50955fd83e0974fb29e2c99115 Mon Sep 17 00:00:00 2001 From: Federica Date: Wed, 31 May 2023 15:14:12 -0300 Subject: [PATCH 4/5] Clippy --- src/hint_processor/builtin_hint_processor/math_utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hint_processor/builtin_hint_processor/math_utils.rs b/src/hint_processor/builtin_hint_processor/math_utils.rs index 9225d94aa7..5730693526 100644 --- a/src/hint_processor/builtin_hint_processor/math_utils.rs +++ b/src/hint_processor/builtin_hint_processor/math_utils.rs @@ -558,7 +558,7 @@ pub fn assert_250_bit( get_integer_from_var_name("value", vm, ids_data, ap_tracking)?.to_signed_felt(), ); //Main logic - if &value > &upper_bound { + if value > upper_bound { return Err(HintError::ValueOutside250BitRange(value)); } let (high, low) = value.div_rem(&shift); From b6a75eecc0f1c1c014f152a2c941e202a3a85812 Mon Sep 17 00:00:00 2001 From: fmoletta <99273364+fmoletta@users.noreply.github.com> Date: Wed, 31 May 2023 15:17:54 -0300 Subject: [PATCH 5/5] Update CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tomás <47506558+MegaRedHand@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e243f9421a..e602082f56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ * fix: Handle the deserialization of serde_json::Number with scientific notation (e.g.: Number(1e27)) in felt_from_number function [#1188](https://github.com/lambdaclass/cairo-rs/pull/1188) -* fix: Fix 'as_int' conversion usage in hints `ASSERT_250_BIt` & `SIGNED_DIV_REM` [#1191](https://github.com/lambdaclass/cairo-rs/pull/1191) +* fix: Fix 'as_int' conversion usage in hints `ASSERT_250_BIT` & `SIGNED_DIV_REM` [#1191](https://github.com/lambdaclass/cairo-rs/pull/1191) * fix: Fix hint `BIGINT_PACK_DIV_MOD` [#1189](https://github.com/lambdaclass/cairo-rs/pull/1189)