-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,32 @@ | ||
use cairo_vm::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::HintProcessorData; | ||
use cairo_vm::hint_processor::builtin_hint_processor::hint_utils::{ | ||
get_integer_from_var_name, insert_value_into_ap, | ||
}; | ||
use cairo_vm::types::exec_scope::ExecutionScopes; | ||
use cairo_vm::types::relocatable::MaybeRelocatable; | ||
use cairo_vm::vm::{errors::hint_errors::HintError, vm_core::VirtualMachine}; | ||
use cairo_vm::Felt252; | ||
use std::cmp::Ordering; | ||
use std::collections::HashMap; | ||
|
||
pub const HINT_RLP_BIGINT_SIZE: &str = "memory[ap] = 1 if ids.byte <= 127 else 0"; | ||
|
||
const FELT_127: Felt252 = Felt252::from_hex_unchecked("0x7F"); | ||
|
||
pub fn hint_rlp_bigint_size( | ||
vm: &mut VirtualMachine, | ||
_exec_scope: &mut ExecutionScopes, | ||
hint_data: &HintProcessorData, | ||
_constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
match get_integer_from_var_name("byte", vm, &hint_data.ids_data, &hint_data.ap_tracking)? | ||
.cmp(&FELT_127) | ||
{ | ||
Ordering::Less | Ordering::Equal => { | ||
insert_value_into_ap(vm, MaybeRelocatable::Int(Felt252::ONE))? | ||
} | ||
Ordering::Greater => insert_value_into_ap(vm, MaybeRelocatable::Int(Felt252::ZERO))?, | ||
}; | ||
|
||
Ok(()) | ||
} |