-
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
6 changed files
with
113 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
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_from_var_name, | ||
}; | ||
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::collections::HashMap; | ||
|
||
pub const HINT_BIT_LENGTH_ASSIGN_140: &str = "ids.bit_length = 140"; | ||
|
||
pub fn hint_bit_length_assign_140( | ||
vm: &mut VirtualMachine, | ||
_exec_scope: &mut ExecutionScopes, | ||
hint_data: &HintProcessorData, | ||
_constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
insert_value_from_var_name( | ||
"bit_length", | ||
MaybeRelocatable::Int(Felt252::from_hex_unchecked("0x8C")), | ||
vm, | ||
&hint_data.ids_data, | ||
&hint_data.ap_tracking, | ||
)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub const HINT_BIT_LENGTH_ASSIGN_NEGATIVE_ONE: &str = "ids.bit_length = -1"; | ||
|
||
pub fn hint_bit_length_assign_negative_one( | ||
vm: &mut VirtualMachine, | ||
_exec_scope: &mut ExecutionScopes, | ||
hint_data: &HintProcessorData, | ||
_constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
insert_value_from_var_name( | ||
"bit_length", | ||
MaybeRelocatable::Int(Felt252::ZERO - Felt252::ONE), | ||
vm, | ||
&hint_data.ids_data, | ||
&hint_data.ap_tracking, | ||
)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub const HINT_BIT_LENGTH_ASSIGN_2500: &str = "ids.bit_length = 2500"; | ||
|
||
pub fn hint_bit_length_assign_2500( | ||
vm: &mut VirtualMachine, | ||
_exec_scope: &mut ExecutionScopes, | ||
hint_data: &HintProcessorData, | ||
_constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
insert_value_from_var_name( | ||
"bit_length", | ||
MaybeRelocatable::Int(Felt252::from_hex_unchecked("0x9C4")), | ||
vm, | ||
&hint_data.ids_data, | ||
&hint_data.ap_tracking, | ||
)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub const HINT_PRINT_NS: &str = "print(\"N\", ids.N, \"n\", ids.n)"; | ||
|
||
pub fn hint_print_ns( | ||
vm: &mut VirtualMachine, | ||
_exec_scope: &mut ExecutionScopes, | ||
hint_data: &HintProcessorData, | ||
_constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
println!( | ||
"N: {}, n: {}", | ||
get_integer_from_var_name("N", vm, &hint_data.ids_data, &hint_data.ap_tracking)?, | ||
get_integer_from_var_name("n", vm, &hint_data.ids_data, &hint_data.ap_tracking)? | ||
); | ||
Ok(()) | ||
} |
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,2 +1,3 @@ | ||
pub mod dw_hack; | ||
pub mod mmr_size_generate; | ||
pub mod print; |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use super::run_cairo_program; | ||
|
||
#[test] | ||
fn test() { | ||
let cairo_runner = run_cairo_program(include_bytes!( | ||
"../../../build/compiled_cairo_files/dw_hack_test.json" | ||
)) | ||
.unwrap(); | ||
|
||
let execution_resources = cairo_runner.get_execution_resources().unwrap(); | ||
println!("n_steps: {}", execution_resources.n_steps) | ||
} |
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,3 +1,4 @@ | ||
pub mod dw_hack_test; | ||
pub mod is_valid_mmr_size; | ||
|
||
use crate::ExtendedHintProcessor; | ||
|
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