Skip to content

Commit

Permalink
feat(starknet_os): integrate kzg hints
Browse files Browse the repository at this point in the history
  • Loading branch information
dorimedini-starkware committed Jan 28, 2025
1 parent 6dec1dd commit 11520f8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/starknet_os/src/hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ pub mod error;
pub mod execute_transactions;
pub mod execution;
pub mod find_element;
pub mod kzg;
pub mod stateless_compression;
pub mod types;
22 changes: 22 additions & 0 deletions crates/starknet_os/src/hints/enum_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ use crate::hints::execution::{
write_syscall_result_deprecated,
};
use crate::hints::find_element::search_sorted_optimistic;
use crate::hints::kzg::store_da_segment;
use crate::hints::stateless_compression::{
compression_hint,
dictionary_from_bucket,
Expand Down Expand Up @@ -957,6 +958,27 @@ segments.write_arg(ids.sha256_ptr_end, padding)"#}
else:
ids.index = n_elms
ids.exists = 0"#}
),
(
StoreDaSegment,
store_da_segment,
indoc! {r#"import itertools
from starkware.python.utils import blockify
kzg_manager.store_da_segment(
da_segment=memory.get_range_as_ints(addr=ids.state_updates_start, size=ids.da_size)
)
kzg_commitments = [
kzg_manager.polynomial_coefficients_to_kzg_commitment_callback(chunk)
for chunk in blockify(kzg_manager.da_segment, chunk_size=ids.BLOB_LENGTH)
]
ids.n_blobs = len(kzg_commitments)
ids.kzg_commitments = segments.add_temp_segment()
ids.evals = segments.add_temp_segment()
segments.write_arg(ids.kzg_commitments.address_, list(itertools.chain(*kzg_commitments)))"#}
)
);

Expand Down
19 changes: 19 additions & 0 deletions crates/starknet_os/src/hints/kzg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::collections::HashMap;

use cairo_vm::hint_processor::hint_processor_definition::HintReference;
use cairo_vm::serde::deserialize_program::ApTracking;
use cairo_vm::types::exec_scope::ExecutionScopes;
use cairo_vm::vm::vm_core::VirtualMachine;
use starknet_types_core::felt::Felt;

use crate::hints::error::HintResult;

pub fn store_da_segment(
_vm: &mut VirtualMachine,
_exec_scopes: &mut ExecutionScopes,
_ids_data: &HashMap<String, HintReference>,
_ap_tracking: &ApTracking,
_constants: &HashMap<String, Felt>,
) -> HintResult {
todo!()
}

0 comments on commit 11520f8

Please sign in to comment.