-
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
11 changed files
with
524 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,29 @@ | ||
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 BIT_LENGTH_MMR: &str = "ids.bit_length = ids.mmr_len.bit_length()"; | ||
|
||
pub fn bit_length_mmr( | ||
vm: &mut VirtualMachine, | ||
_exec_scope: &mut ExecutionScopes, | ||
hint_data: &HintProcessorData, | ||
_constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
let x = get_integer_from_var_name("mmr_len", vm, &hint_data.ids_data, &hint_data.ap_tracking)?; | ||
insert_value_from_var_name( | ||
"bit_length", | ||
MaybeRelocatable::Int(x.bits().into()), | ||
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
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,43 @@ | ||
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 starknet_types_core::felt::Felt; | ||
use std::collections::HashMap; | ||
|
||
pub const MMR_LEFT_CHILD: &str = "ids.in_mmr = 1 if ids.left_child<=ids.mmr_len else 0"; | ||
|
||
pub fn mmr_left_child( | ||
vm: &mut VirtualMachine, | ||
_exec_scope: &mut ExecutionScopes, | ||
hint_data: &HintProcessorData, | ||
_constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
let left_child = get_integer_from_var_name( | ||
"left_child", | ||
vm, | ||
&hint_data.ids_data, | ||
&hint_data.ap_tracking, | ||
)?; | ||
let mmr_len = | ||
get_integer_from_var_name("mmr_len", vm, &hint_data.ids_data, &hint_data.ap_tracking)?; | ||
|
||
let in_mmr = if left_child <= mmr_len { | ||
Felt::ONE | ||
} else { | ||
Felt::ZERO | ||
}; | ||
insert_value_from_var_name( | ||
"in_mmr", | ||
MaybeRelocatable::Int(in_mmr), | ||
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
Oops, something went wrong.