From 941fc63861b5b189b521e6b8324af713158de140 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 28 Oct 2025 12:58:34 +0200 Subject: [PATCH 1/2] refactor: use `hash_memory_words` under the hood of SDK `hash_words` --- .../src/miden_abi/stdlib/crypto/hashes/rpo.rs | 6 + frontend/wasm/src/miden_abi/transform.rs | 3 +- sdk/stdlib-sys/src/stdlib/crypto/hashes.rs | 20 +- sdk/stdlib-sys/stubs/crypto/hashes_rpo.rs | 10 + .../examples/auth_component_rpo_falcon512.hir | 1327 +++++++++-------- .../auth_component_rpo_falcon512.masm | 19 +- .../examples/auth_component_rpo_falcon512.wat | 7 +- tests/integration/expected/hash_words.hir | 625 ++++---- tests/integration/expected/hash_words.masm | 19 +- tests/integration/expected/hash_words.wat | 7 +- 10 files changed, 1043 insertions(+), 1000 deletions(-) diff --git a/frontend/wasm/src/miden_abi/stdlib/crypto/hashes/rpo.rs b/frontend/wasm/src/miden_abi/stdlib/crypto/hashes/rpo.rs index 54c8bc9ed..5e636b30d 100644 --- a/frontend/wasm/src/miden_abi/stdlib/crypto/hashes/rpo.rs +++ b/frontend/wasm/src/miden_abi/stdlib/crypto/hashes/rpo.rs @@ -9,6 +9,7 @@ use crate::miden_abi::{FunctionTypeMap, ModuleFunctionTypeMap}; pub const MODULE_ID: &str = "std::crypto::hashes::rpo"; pub const HASH_MEMORY: &str = "hash_memory"; +pub const HASH_MEMORY_WORDS: &str = "hash_memory_words"; pub(crate) fn signatures() -> ModuleFunctionTypeMap { let mut m: ModuleFunctionTypeMap = Default::default(); @@ -18,6 +19,11 @@ pub(crate) fn signatures() -> ModuleFunctionTypeMap { Symbol::from(HASH_MEMORY), FunctionType::new(CallConv::Wasm, [I32, I32], [Felt, Felt, Felt, Felt]), ); + // hash_memory_words takes (start_addr: u32, end_addr: u32) and returns 4 Felt values on the stack + rpo.insert( + Symbol::from(HASH_MEMORY_WORDS), + FunctionType::new(CallConv::Wasm, [I32, I32], [Felt, Felt, Felt, Felt]), + ); let module_path = SymbolPath::from_iter([ SymbolNameComponent::Root, diff --git a/frontend/wasm/src/miden_abi/transform.rs b/frontend/wasm/src/miden_abi/transform.rs index 096fe3375..e5b5d857f 100644 --- a/frontend/wasm/src/miden_abi/transform.rs +++ b/frontend/wasm/src/miden_abi/transform.rs @@ -46,7 +46,8 @@ fn get_transform_strategy(path: &SymbolPath) -> Option { } name if name == Symbol::intern("rpo") => { match components.next_if(|c| c.is_leaf())?.as_symbol_name().as_str() { - stdlib::crypto::hashes::rpo::HASH_MEMORY => { + stdlib::crypto::hashes::rpo::HASH_MEMORY + | stdlib::crypto::hashes::rpo::HASH_MEMORY_WORDS => { Some(TransformStrategy::ReturnViaPointer) } _ => None, diff --git a/sdk/stdlib-sys/src/stdlib/crypto/hashes.rs b/sdk/stdlib-sys/src/stdlib/crypto/hashes.rs index 7d88b8008..2b7d3017f 100644 --- a/sdk/stdlib-sys/src/stdlib/crypto/hashes.rs +++ b/sdk/stdlib-sys/src/stdlib/crypto/hashes.rs @@ -112,6 +112,18 @@ extern "C" { /// The output is passed back to the caller via a pointer. #[link_name = "std::crypto::hashes::rpo::hash_memory"] pub fn extern_hash_memory(ptr: u32, num_elements: u32, result_ptr: *mut Felt); + + /// Computes the hash of a sequence of words using the Rescue Prime Optimized (RPO) hash + /// function. + /// + /// This maps to the `std::crypto::hashes::rpo::hash_memory_words` procedure in the Miden + /// stdlib. + /// + /// Input: The start and end addresses (in field elements) of the words to hash. + /// Output: One digest (4 field elements) + /// The output is passed back to the caller via a pointer. + #[link_name = "std::crypto::hashes::rpo::hash_memory_words"] + pub fn extern_hash_memory_words(start_addr: u32, end_addr: u32, result_ptr: *mut Felt); } /// Hashes a 32-byte input to a 32-byte output using the given hash function. @@ -220,8 +232,7 @@ pub fn hash_elements(elements: Vec) -> Digest { /// Computes the hash of a sequence of words using the Rescue Prime Optimized (RPO) /// hash function. /// -/// This maps to the `std::crypto::rpo::hash_memory` procedure in the Miden stdlib treating the -/// `words` as an array of fielt elements. +/// This maps to the `std::crypto::hashes::rpo::hash_memory_words` procedure in the Miden stdlib. /// /// # Arguments /// * `words` - A slice of words to be hashed @@ -236,8 +247,9 @@ pub fn hash_words(words: &[Word]) -> Digest { // It's safe to assume the `words` ptr is word-aligned. assert_eq(Felt::from_u32(miden_ptr % 4), felt!(0)); - let num_elements = (words.len() * 4) as u32; - extern_hash_memory(miden_ptr, num_elements, result_ptr); + let start_addr = miden_ptr; + let end_addr = start_addr + (words.len() as u32 * 4); + extern_hash_memory_words(start_addr, end_addr, result_ptr); Digest::from_word(ret_area.assume_init().reverse()) } diff --git a/sdk/stdlib-sys/stubs/crypto/hashes_rpo.rs b/sdk/stdlib-sys/stubs/crypto/hashes_rpo.rs index 2049ad39a..3eaddd1ba 100644 --- a/sdk/stdlib-sys/stubs/crypto/hashes_rpo.rs +++ b/sdk/stdlib-sys/stubs/crypto/hashes_rpo.rs @@ -8,3 +8,13 @@ pub extern "C" fn rpo_hash_memory_stub(ptr: u32, num_elements: u32, result_ptr: unsafe { core::hint::unreachable_unchecked() } } +/// Unreachable stub for std::crypto::hashes::rpo::hash_memory_words +#[export_name = "std::crypto::hashes::rpo::hash_memory_words"] +pub extern "C" fn rpo_hash_memory_words_stub( + start_addr: u32, + end_addr: u32, + result_ptr: *mut c_void, +) { + let _ = (start_addr, end_addr, result_ptr); + unsafe { core::hint::unreachable_unchecked() } +} diff --git a/tests/integration/expected/examples/auth_component_rpo_falcon512.hir b/tests/integration/expected/examples/auth_component_rpo_falcon512.hir index 656d36d48..c6af8a36d 100644 --- a/tests/integration/expected/examples/auth_component_rpo_falcon512.hir +++ b/tests/integration/expected/examples/auth_component_rpo_falcon512.hir @@ -37,24 +37,24 @@ builtin.component miden:base/authentication-component@1.0.0 { v29 = arith.constant 104 : u32; v28 = hir.bitcast v14 : u32; v30 = arith.add v28, v29 : u32 #[overflow = checked]; - v837 = arith.constant 8 : u32; - v32 = arith.mod v30, v837 : u32; + v838 = arith.constant 8 : u32; + v32 = arith.mod v30, v838 : u32; hir.assertz v32 #[code = 250]; v33 = hir.int_to_ptr v30 : ptr; hir.store v33, v27; v35 = arith.constant 80 : u32; v34 = hir.bitcast v14 : u32; v36 = arith.add v34, v35 : u32 #[overflow = checked]; - v836 = arith.constant 8 : u32; - v38 = arith.mod v36, v836 : u32; + v837 = arith.constant 8 : u32; + v38 = arith.mod v36, v837 : u32; hir.assertz v38 #[code = 250]; v39 = hir.int_to_ptr v36 : ptr; v40 = hir.load v39 : i64; v42 = arith.constant 96 : u32; v41 = hir.bitcast v14 : u32; v43 = arith.add v41, v42 : u32 #[overflow = checked]; - v835 = arith.constant 8 : u32; - v45 = arith.mod v43, v835 : u32; + v836 = arith.constant 8 : u32; + v45 = arith.mod v43, v836 : u32; hir.assertz v45 #[code = 250]; v46 = hir.int_to_ptr v43 : ptr; hir.store v46, v40; @@ -69,8 +69,8 @@ builtin.component miden:base/authentication-component@1.0.0 { hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden_base_sys::bindings::tx::get_output_notes_commitment(v52) v4 = arith.constant 0 : i32; v55 = hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/intrinsics::felt::from_u32(v4) : felt - v834 = arith.constant 0 : i32; - v57 = hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/intrinsics::felt::from_u32(v834) : felt + v835 = arith.constant 0 : i32; + v57 = hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/intrinsics::felt::from_u32(v835) : felt v59 = arith.constant 60 : u32; v58 = hir.bitcast v14 : u32; v60 = arith.add v58, v59 : u32 #[overflow = checked]; @@ -82,303 +82,304 @@ builtin.component miden:base/authentication-component@1.0.0 { v65 = arith.constant 56 : u32; v64 = hir.bitcast v14 : u32; v66 = arith.add v64, v65 : u32 #[overflow = checked]; - v833 = arith.constant 4 : u32; - v68 = arith.mod v66, v833 : u32; + v834 = arith.constant 4 : u32; + v68 = arith.mod v66, v834 : u32; hir.assertz v68 #[code = 250]; v69 = hir.int_to_ptr v66 : ptr; hir.store v69, v17; v71 = arith.constant 52 : u32; v70 = hir.bitcast v14 : u32; v72 = arith.add v70, v71 : u32 #[overflow = checked]; - v832 = arith.constant 4 : u32; - v74 = arith.mod v72, v832 : u32; + v833 = arith.constant 4 : u32; + v74 = arith.mod v72, v833 : u32; hir.assertz v74 #[code = 250]; v75 = hir.int_to_ptr v72 : ptr; hir.store v75, v57; v77 = arith.constant 48 : u32; v76 = hir.bitcast v14 : u32; v78 = arith.add v76, v77 : u32 #[overflow = checked]; - v831 = arith.constant 4 : u32; - v80 = arith.mod v78, v831 : u32; + v832 = arith.constant 4 : u32; + v80 = arith.mod v78, v832 : u32; hir.assertz v80 #[code = 250]; v81 = hir.int_to_ptr v78 : ptr; hir.store v81, v55; + v831 = arith.constant 0 : i32; + v83 = hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/intrinsics::felt::from_u32(v831) : felt v830 = arith.constant 0 : i32; - v83 = hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/intrinsics::felt::from_u32(v830) : felt - v829 = arith.constant 0 : i32; - v85 = hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/intrinsics::felt::from_u32(v829) : felt + v85 = hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/intrinsics::felt::from_u32(v830) : felt hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/intrinsics::felt::assert_eq(v83, v85) - v827 = arith.constant 80 : i32; - v93 = arith.add v14, v827 : i32 #[overflow = wrapping]; - v828 = arith.constant 16 : i32; - v648 = arith.constant 2 : u32; + v649 = arith.constant 2 : u32; v87 = hir.bitcast v14 : u32; - v89 = arith.shr v87, v648 : u32; + v89 = arith.shr v87, v649 : u32; v90 = hir.bitcast v89 : i32; - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/std::crypto::hashes::rpo::hash_memory(v90, v828, v93) - v826 = arith.constant 88 : u32; - v94 = hir.bitcast v14 : u32; - v96 = arith.add v94, v826 : u32 #[overflow = checked]; - v825 = arith.constant 8 : u32; - v98 = arith.mod v96, v825 : u32; - hir.assertz v98 #[code = 250]; - v99 = hir.int_to_ptr v96 : ptr; - v100 = hir.load v99 : i64; - v824 = arith.constant 104 : u32; - v101 = hir.bitcast v14 : u32; - v103 = arith.add v101, v824 : u32 #[overflow = checked]; - v823 = arith.constant 8 : u32; - v105 = arith.mod v103, v823 : u32; - hir.assertz v105 #[code = 250]; - v106 = hir.int_to_ptr v103 : ptr; - hir.store v106, v100; - v822 = arith.constant 80 : u32; - v107 = hir.bitcast v14 : u32; - v109 = arith.add v107, v822 : u32 #[overflow = checked]; - v821 = arith.constant 8 : u32; - v111 = arith.mod v109, v821 : u32; - hir.assertz v111 #[code = 250]; - v112 = hir.int_to_ptr v109 : ptr; - v113 = hir.load v112 : i64; - v820 = arith.constant 96 : u32; - v114 = hir.bitcast v14 : u32; - v116 = arith.add v114, v820 : u32 #[overflow = checked]; - v819 = arith.constant 8 : u32; - v118 = arith.mod v116, v819 : u32; - hir.assertz v118 #[code = 250]; - v119 = hir.int_to_ptr v116 : ptr; - hir.store v119, v113; - v818 = arith.constant 96 : i32; - v123 = arith.add v14, v818 : i32 #[overflow = wrapping]; - v120 = arith.constant 64 : i32; - v121 = arith.add v14, v120 : i32 #[overflow = wrapping]; - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden_stdlib_sys::intrinsics::word::Word::reverse(v121, v123) - v125 = arith.constant 64 : u32; - v124 = hir.bitcast v14 : u32; - v126 = arith.add v124, v125 : u32 #[overflow = checked]; + v828 = arith.constant 80 : i32; + v94 = arith.add v14, v828 : i32 #[overflow = wrapping]; + v829 = arith.constant 16 : i32; + v92 = arith.add v90, v829 : i32 #[overflow = wrapping]; + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/std::crypto::hashes::rpo::hash_memory_words(v90, v92, v94) + v827 = arith.constant 88 : u32; + v95 = hir.bitcast v14 : u32; + v97 = arith.add v95, v827 : u32 #[overflow = checked]; + v826 = arith.constant 8 : u32; + v99 = arith.mod v97, v826 : u32; + hir.assertz v99 #[code = 250]; + v100 = hir.int_to_ptr v97 : ptr; + v101 = hir.load v100 : i64; + v825 = arith.constant 104 : u32; + v102 = hir.bitcast v14 : u32; + v104 = arith.add v102, v825 : u32 #[overflow = checked]; + v824 = arith.constant 8 : u32; + v106 = arith.mod v104, v824 : u32; + hir.assertz v106 #[code = 250]; + v107 = hir.int_to_ptr v104 : ptr; + hir.store v107, v101; + v823 = arith.constant 80 : u32; + v108 = hir.bitcast v14 : u32; + v110 = arith.add v108, v823 : u32 #[overflow = checked]; + v822 = arith.constant 8 : u32; + v112 = arith.mod v110, v822 : u32; + hir.assertz v112 #[code = 250]; + v113 = hir.int_to_ptr v110 : ptr; + v114 = hir.load v113 : i64; + v821 = arith.constant 96 : u32; + v115 = hir.bitcast v14 : u32; + v117 = arith.add v115, v821 : u32 #[overflow = checked]; + v820 = arith.constant 8 : u32; + v119 = arith.mod v117, v820 : u32; + hir.assertz v119 #[code = 250]; + v120 = hir.int_to_ptr v117 : ptr; + hir.store v120, v114; + v819 = arith.constant 96 : i32; + v124 = arith.add v14, v819 : i32 #[overflow = wrapping]; + v121 = arith.constant 64 : i32; + v122 = arith.add v14, v121 : i32 #[overflow = wrapping]; + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden_stdlib_sys::intrinsics::word::Word::reverse(v122, v124) + v126 = arith.constant 64 : u32; + v125 = hir.bitcast v14 : u32; + v127 = arith.add v125, v126 : u32 #[overflow = checked]; + v818 = arith.constant 4 : u32; + v129 = arith.mod v127, v818 : u32; + hir.assertz v129 #[code = 250]; + v130 = hir.int_to_ptr v127 : ptr; + v131 = hir.load v130 : felt; + v133 = arith.constant 68 : u32; + v132 = hir.bitcast v14 : u32; + v134 = arith.add v132, v133 : u32 #[overflow = checked]; v817 = arith.constant 4 : u32; - v128 = arith.mod v126, v817 : u32; - hir.assertz v128 #[code = 250]; - v129 = hir.int_to_ptr v126 : ptr; - v130 = hir.load v129 : felt; - v132 = arith.constant 68 : u32; - v131 = hir.bitcast v14 : u32; - v133 = arith.add v131, v132 : u32 #[overflow = checked]; + v136 = arith.mod v134, v817 : u32; + hir.assertz v136 #[code = 250]; + v137 = hir.int_to_ptr v134 : ptr; + v138 = hir.load v137 : felt; + v140 = arith.constant 72 : u32; + v139 = hir.bitcast v14 : u32; + v141 = arith.add v139, v140 : u32 #[overflow = checked]; v816 = arith.constant 4 : u32; - v135 = arith.mod v133, v816 : u32; - hir.assertz v135 #[code = 250]; - v136 = hir.int_to_ptr v133 : ptr; - v137 = hir.load v136 : felt; - v139 = arith.constant 72 : u32; - v138 = hir.bitcast v14 : u32; - v140 = arith.add v138, v139 : u32 #[overflow = checked]; + v143 = arith.mod v141, v816 : u32; + hir.assertz v143 #[code = 250]; + v144 = hir.int_to_ptr v141 : ptr; + v145 = hir.load v144 : felt; + v147 = arith.constant 76 : u32; + v146 = hir.bitcast v14 : u32; + v148 = arith.add v146, v147 : u32 #[overflow = checked]; v815 = arith.constant 4 : u32; - v142 = arith.mod v140, v815 : u32; - hir.assertz v142 #[code = 250]; - v143 = hir.int_to_ptr v140 : ptr; - v144 = hir.load v143 : felt; - v146 = arith.constant 76 : u32; - v145 = hir.bitcast v14 : u32; - v147 = arith.add v145, v146 : u32 #[overflow = checked]; - v814 = arith.constant 4 : u32; - v149 = arith.mod v147, v814 : u32; - hir.assertz v149 #[code = 250]; - v150 = hir.int_to_ptr v147 : ptr; - v151 = hir.load v150 : felt; - v152 = arith.constant 48 : i32; - v153 = arith.add v14, v152 : i32 #[overflow = wrapping]; - v813 = arith.constant 0 : i32; - v746, v747, v748, v749, v750, v751, v752, v753, v754, v755, v756, v757 = scf.while v813, v14, v153, v151, v144, v137, v130 : i32, i32, i32, felt, felt, felt, felt, i32, felt, felt, felt, felt { - ^block85(v758: i32, v759: i32, v760: i32, v761: felt, v762: felt, v763: felt, v764: felt): - v811 = arith.constant 0 : i32; - v812 = arith.constant 32 : i32; - v156 = arith.eq v758, v812 : i1; - v157 = arith.zext v156 : u32; - v158 = hir.bitcast v157 : i32; - v160 = arith.neq v158, v811 : i1; - v737, v738 = scf.if v160 : i32, i32 { + v150 = arith.mod v148, v815 : u32; + hir.assertz v150 #[code = 250]; + v151 = hir.int_to_ptr v148 : ptr; + v152 = hir.load v151 : felt; + v153 = arith.constant 48 : i32; + v154 = arith.add v14, v153 : i32 #[overflow = wrapping]; + v814 = arith.constant 0 : i32; + v747, v748, v749, v750, v751, v752, v753, v754, v755, v756, v757, v758 = scf.while v814, v14, v154, v152, v145, v138, v131 : i32, i32, i32, felt, felt, felt, felt, i32, felt, felt, felt, felt { + ^block85(v759: i32, v760: i32, v761: i32, v762: felt, v763: felt, v764: felt, v765: felt): + v812 = arith.constant 0 : i32; + v813 = arith.constant 32 : i32; + v157 = arith.eq v759, v813 : i1; + v158 = arith.zext v157 : u32; + v159 = hir.bitcast v158 : i32; + v161 = arith.neq v159, v812 : i1; + v738, v739 = scf.if v161 : i32, i32 { ^block84: - v660 = ub.poison i32 : i32; - scf.yield v660, v660; + v661 = ub.poison i32 : i32; + scf.yield v661, v661; } else { ^block14: - v199 = arith.constant 4 : i32; - v162 = arith.add v759, v758 : i32 #[overflow = wrapping]; - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/core::ptr::swap_nonoverlapping_bytes::swap_nonoverlapping_chunks(v162, v760, v199) - v167 = arith.constant -16 : i32; - v168 = arith.add v760, v167 : i32 #[overflow = wrapping]; - v810 = arith.constant 16 : i32; - v166 = arith.add v758, v810 : i32 #[overflow = wrapping]; - scf.yield v166, v168; + v200 = arith.constant 4 : i32; + v163 = arith.add v760, v759 : i32 #[overflow = wrapping]; + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/core::ptr::swap_nonoverlapping_bytes::swap_nonoverlapping_chunks(v163, v761, v200) + v168 = arith.constant -16 : i32; + v169 = arith.add v761, v168 : i32 #[overflow = wrapping]; + v811 = arith.constant 16 : i32; + v167 = arith.add v759, v811 : i32 #[overflow = wrapping]; + scf.yield v167, v169; }; - v806 = ub.poison felt : felt; - v743 = cf.select v160, v806, v764 : felt; v807 = ub.poison felt : felt; - v742 = cf.select v160, v807, v763 : felt; + v744 = cf.select v161, v807, v765 : felt; v808 = ub.poison felt : felt; - v741 = cf.select v160, v808, v762 : felt; - v661 = ub.poison felt : felt; - v740 = cf.select v160, v661, v761 : felt; - v809 = ub.poison i32 : i32; - v739 = cf.select v160, v809, v759 : i32; - v659 = arith.constant 1 : u32; - v649 = arith.constant 0 : u32; - v745 = cf.select v160, v649, v659 : u32; - v727 = arith.trunc v745 : i1; - scf.condition v727, v737, v739, v738, v740, v741, v742, v743, v759, v761, v762, v763, v764; + v743 = cf.select v161, v808, v764 : felt; + v809 = ub.poison felt : felt; + v742 = cf.select v161, v809, v763 : felt; + v662 = ub.poison felt : felt; + v741 = cf.select v161, v662, v762 : felt; + v810 = ub.poison i32 : i32; + v740 = cf.select v161, v810, v760 : i32; + v660 = arith.constant 1 : u32; + v650 = arith.constant 0 : u32; + v746 = cf.select v161, v650, v660 : u32; + v728 = arith.trunc v746 : i1; + scf.condition v728, v738, v740, v739, v741, v742, v743, v744, v760, v762, v763, v764, v765; } do { - ^block86(v765: i32, v766: i32, v767: i32, v768: felt, v769: felt, v770: felt, v771: felt, v772: i32, v773: felt, v774: felt, v775: felt, v776: felt): - scf.yield v765, v766, v767, v768, v769, v770, v771; + ^block86(v766: i32, v767: i32, v768: i32, v769: felt, v770: felt, v771: felt, v772: felt, v773: i32, v774: felt, v775: felt, v776: felt, v777: felt): + scf.yield v766, v767, v768, v769, v770, v771, v772; }; - v171 = arith.constant 108 : u32; - v170 = hir.bitcast v753 : u32; - v172 = arith.add v170, v171 : u32 #[overflow = checked]; - v805 = arith.constant 4 : u32; - v174 = arith.mod v172, v805 : u32; - hir.assertz v174 #[code = 250]; - v175 = hir.int_to_ptr v172 : ptr; - hir.store v175, v754; - v804 = arith.constant 104 : u32; - v177 = hir.bitcast v753 : u32; - v179 = arith.add v177, v804 : u32 #[overflow = checked]; + v172 = arith.constant 108 : u32; + v171 = hir.bitcast v754 : u32; + v173 = arith.add v171, v172 : u32 #[overflow = checked]; + v806 = arith.constant 4 : u32; + v175 = arith.mod v173, v806 : u32; + hir.assertz v175 #[code = 250]; + v176 = hir.int_to_ptr v173 : ptr; + hir.store v176, v755; + v805 = arith.constant 104 : u32; + v178 = hir.bitcast v754 : u32; + v180 = arith.add v178, v805 : u32 #[overflow = checked]; + v804 = arith.constant 4 : u32; + v182 = arith.mod v180, v804 : u32; + hir.assertz v182 #[code = 250]; + v183 = hir.int_to_ptr v180 : ptr; + hir.store v183, v756; + v186 = arith.constant 100 : u32; + v185 = hir.bitcast v754 : u32; + v187 = arith.add v185, v186 : u32 #[overflow = checked]; v803 = arith.constant 4 : u32; - v181 = arith.mod v179, v803 : u32; - hir.assertz v181 #[code = 250]; - v182 = hir.int_to_ptr v179 : ptr; - hir.store v182, v755; - v185 = arith.constant 100 : u32; - v184 = hir.bitcast v753 : u32; - v186 = arith.add v184, v185 : u32 #[overflow = checked]; - v802 = arith.constant 4 : u32; - v188 = arith.mod v186, v802 : u32; - hir.assertz v188 #[code = 250]; - v189 = hir.int_to_ptr v186 : ptr; - hir.store v189, v756; - v801 = arith.constant 96 : u32; - v191 = hir.bitcast v753 : u32; - v193 = arith.add v191, v801 : u32 #[overflow = checked]; - v800 = arith.constant 4 : u32; - v195 = arith.mod v193, v800 : u32; - hir.assertz v195 #[code = 250]; - v196 = hir.int_to_ptr v193 : ptr; - hir.store v196, v757; - v798 = arith.constant 4 : i32; - v799 = arith.constant 96 : i32; - v198 = arith.add v753, v799 : i32 #[overflow = wrapping]; - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden_stdlib_sys::intrinsics::advice::adv_insert(v198, v753, v798) - v797 = arith.constant 0 : i32; - v201 = hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/>::from(v797) : felt - v796 = arith.constant 80 : i32; - v203 = arith.add v753, v796 : i32 #[overflow = wrapping]; - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden::account::get_item(v201, v203) - v795 = arith.constant 88 : u32; - v204 = hir.bitcast v753 : u32; - v206 = arith.add v204, v795 : u32 #[overflow = checked]; - v794 = arith.constant 8 : u32; - v208 = arith.mod v206, v794 : u32; - hir.assertz v208 #[code = 250]; - v209 = hir.int_to_ptr v206 : ptr; - v210 = hir.load v209 : i64; - v793 = arith.constant 104 : u32; - v211 = hir.bitcast v753 : u32; - v213 = arith.add v211, v793 : u32 #[overflow = checked]; - v792 = arith.constant 8 : u32; - v215 = arith.mod v213, v792 : u32; - hir.assertz v215 #[code = 250]; - v216 = hir.int_to_ptr v213 : ptr; - hir.store v216, v210; - v791 = arith.constant 80 : u32; - v217 = hir.bitcast v753 : u32; - v219 = arith.add v217, v791 : u32 #[overflow = checked]; - v790 = arith.constant 8 : u32; - v221 = arith.mod v219, v790 : u32; - hir.assertz v221 #[code = 250]; - v222 = hir.int_to_ptr v219 : ptr; - v223 = hir.load v222 : i64; - v789 = arith.constant 96 : u32; - v224 = hir.bitcast v753 : u32; - v226 = arith.add v224, v789 : u32 #[overflow = checked]; - v788 = arith.constant 8 : u32; - v228 = arith.mod v226, v788 : u32; - hir.assertz v228 #[code = 250]; - v229 = hir.int_to_ptr v226 : ptr; - hir.store v229, v223; - v786 = arith.constant 96 : i32; - v233 = arith.add v753, v786 : i32 #[overflow = wrapping]; - v787 = arith.constant 64 : i32; - v231 = arith.add v753, v787 : i32 #[overflow = wrapping]; - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden_stdlib_sys::intrinsics::word::Word::reverse(v231, v233) - v785 = arith.constant 76 : u32; - v234 = hir.bitcast v753 : u32; - v236 = arith.add v234, v785 : u32 #[overflow = checked]; - v784 = arith.constant 4 : u32; - v238 = arith.mod v236, v784 : u32; - hir.assertz v238 #[code = 250]; - v239 = hir.int_to_ptr v236 : ptr; - v240 = hir.load v239 : felt; - v783 = arith.constant 72 : u32; - v241 = hir.bitcast v753 : u32; - v243 = arith.add v241, v783 : u32 #[overflow = checked]; - v782 = arith.constant 4 : u32; - v245 = arith.mod v243, v782 : u32; - hir.assertz v245 #[code = 250]; - v246 = hir.int_to_ptr v243 : ptr; - v247 = hir.load v246 : felt; - v781 = arith.constant 68 : u32; - v248 = hir.bitcast v753 : u32; - v250 = arith.add v248, v781 : u32 #[overflow = checked]; - v780 = arith.constant 4 : u32; - v252 = arith.mod v250, v780 : u32; - hir.assertz v252 #[code = 250]; - v253 = hir.int_to_ptr v250 : ptr; - v254 = hir.load v253 : felt; - v779 = arith.constant 64 : u32; - v255 = hir.bitcast v753 : u32; - v257 = arith.add v255, v779 : u32 #[overflow = checked]; - v778 = arith.constant 4 : u32; - v259 = arith.mod v257, v778 : u32; - hir.assertz v259 #[code = 250]; - v260 = hir.int_to_ptr v257 : ptr; - v261 = hir.load v260 : felt; - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/intrinsics::advice::emit_falcon_sig_to_stack(v754, v755, v756, v757, v240, v247, v254, v261) - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/std::crypto::dsa::rpo_falcon512::verify(v240, v247, v254, v261, v754, v755, v756, v757) - v777 = arith.constant 112 : i32; - v263 = arith.add v753, v777 : i32 #[overflow = wrapping]; - v264 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr - v265 = hir.bitcast v264 : ptr; - hir.store v265, v263; + v189 = arith.mod v187, v803 : u32; + hir.assertz v189 #[code = 250]; + v190 = hir.int_to_ptr v187 : ptr; + hir.store v190, v757; + v802 = arith.constant 96 : u32; + v192 = hir.bitcast v754 : u32; + v194 = arith.add v192, v802 : u32 #[overflow = checked]; + v801 = arith.constant 4 : u32; + v196 = arith.mod v194, v801 : u32; + hir.assertz v196 #[code = 250]; + v197 = hir.int_to_ptr v194 : ptr; + hir.store v197, v758; + v799 = arith.constant 4 : i32; + v800 = arith.constant 96 : i32; + v199 = arith.add v754, v800 : i32 #[overflow = wrapping]; + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden_stdlib_sys::intrinsics::advice::adv_insert(v199, v754, v799) + v798 = arith.constant 0 : i32; + v202 = hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/>::from(v798) : felt + v797 = arith.constant 80 : i32; + v204 = arith.add v754, v797 : i32 #[overflow = wrapping]; + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden::account::get_item(v202, v204) + v796 = arith.constant 88 : u32; + v205 = hir.bitcast v754 : u32; + v207 = arith.add v205, v796 : u32 #[overflow = checked]; + v795 = arith.constant 8 : u32; + v209 = arith.mod v207, v795 : u32; + hir.assertz v209 #[code = 250]; + v210 = hir.int_to_ptr v207 : ptr; + v211 = hir.load v210 : i64; + v794 = arith.constant 104 : u32; + v212 = hir.bitcast v754 : u32; + v214 = arith.add v212, v794 : u32 #[overflow = checked]; + v793 = arith.constant 8 : u32; + v216 = arith.mod v214, v793 : u32; + hir.assertz v216 #[code = 250]; + v217 = hir.int_to_ptr v214 : ptr; + hir.store v217, v211; + v792 = arith.constant 80 : u32; + v218 = hir.bitcast v754 : u32; + v220 = arith.add v218, v792 : u32 #[overflow = checked]; + v791 = arith.constant 8 : u32; + v222 = arith.mod v220, v791 : u32; + hir.assertz v222 #[code = 250]; + v223 = hir.int_to_ptr v220 : ptr; + v224 = hir.load v223 : i64; + v790 = arith.constant 96 : u32; + v225 = hir.bitcast v754 : u32; + v227 = arith.add v225, v790 : u32 #[overflow = checked]; + v789 = arith.constant 8 : u32; + v229 = arith.mod v227, v789 : u32; + hir.assertz v229 #[code = 250]; + v230 = hir.int_to_ptr v227 : ptr; + hir.store v230, v224; + v787 = arith.constant 96 : i32; + v234 = arith.add v754, v787 : i32 #[overflow = wrapping]; + v788 = arith.constant 64 : i32; + v232 = arith.add v754, v788 : i32 #[overflow = wrapping]; + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden_stdlib_sys::intrinsics::word::Word::reverse(v232, v234) + v786 = arith.constant 76 : u32; + v235 = hir.bitcast v754 : u32; + v237 = arith.add v235, v786 : u32 #[overflow = checked]; + v785 = arith.constant 4 : u32; + v239 = arith.mod v237, v785 : u32; + hir.assertz v239 #[code = 250]; + v240 = hir.int_to_ptr v237 : ptr; + v241 = hir.load v240 : felt; + v784 = arith.constant 72 : u32; + v242 = hir.bitcast v754 : u32; + v244 = arith.add v242, v784 : u32 #[overflow = checked]; + v783 = arith.constant 4 : u32; + v246 = arith.mod v244, v783 : u32; + hir.assertz v246 #[code = 250]; + v247 = hir.int_to_ptr v244 : ptr; + v248 = hir.load v247 : felt; + v782 = arith.constant 68 : u32; + v249 = hir.bitcast v754 : u32; + v251 = arith.add v249, v782 : u32 #[overflow = checked]; + v781 = arith.constant 4 : u32; + v253 = arith.mod v251, v781 : u32; + hir.assertz v253 #[code = 250]; + v254 = hir.int_to_ptr v251 : ptr; + v255 = hir.load v254 : felt; + v780 = arith.constant 64 : u32; + v256 = hir.bitcast v754 : u32; + v258 = arith.add v256, v780 : u32 #[overflow = checked]; + v779 = arith.constant 4 : u32; + v260 = arith.mod v258, v779 : u32; + hir.assertz v260 #[code = 250]; + v261 = hir.int_to_ptr v258 : ptr; + v262 = hir.load v261 : felt; + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/intrinsics::advice::emit_falcon_sig_to_stack(v755, v756, v757, v758, v241, v248, v255, v262) + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/std::crypto::dsa::rpo_falcon512::verify(v241, v248, v255, v262, v755, v756, v757, v758) + v778 = arith.constant 112 : i32; + v264 = arith.add v754, v778 : i32 #[overflow = wrapping]; + v265 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr + v266 = hir.bitcast v265 : ptr; + hir.store v266, v264; builtin.ret ; }; private builtin.function @wit_bindgen::rt::run_ctors_once() { ^block15: - v267 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/GOT.data.internal.__memory_base : ptr - v268 = hir.bitcast v267 : ptr; - v269 = hir.load v268 : i32; - v270 = arith.constant 1048584 : i32; - v271 = arith.add v269, v270 : i32 #[overflow = wrapping]; - v272 = hir.bitcast v271 : u32; - v273 = hir.int_to_ptr v272 : ptr; - v274 = hir.load v273 : u8; - v266 = arith.constant 0 : i32; - v275 = arith.zext v274 : u32; - v276 = hir.bitcast v275 : i32; - v278 = arith.neq v276, v266 : i1; - scf.if v278{ + v268 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/GOT.data.internal.__memory_base : ptr + v269 = hir.bitcast v268 : ptr; + v270 = hir.load v269 : i32; + v271 = arith.constant 1048584 : i32; + v272 = arith.add v270, v271 : i32 #[overflow = wrapping]; + v273 = hir.bitcast v272 : u32; + v274 = hir.int_to_ptr v273 : ptr; + v275 = hir.load v274 : u8; + v267 = arith.constant 0 : i32; + v276 = arith.zext v275 : u32; + v277 = hir.bitcast v276 : i32; + v279 = arith.neq v277, v267 : i1; + scf.if v279{ ^block17: scf.yield ; } else { ^block18: - v279 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/GOT.data.internal.__memory_base : ptr - v280 = hir.bitcast v279 : ptr; - v281 = hir.load v280 : i32; + v280 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/GOT.data.internal.__memory_base : ptr + v281 = hir.bitcast v280 : ptr; + v282 = hir.load v281 : i32; hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__wasm_call_ctors() - v839 = arith.constant 1 : u8; - v841 = arith.constant 1048584 : i32; - v283 = arith.add v281, v841 : i32 #[overflow = wrapping]; - v287 = hir.bitcast v283 : u32; - v288 = hir.int_to_ptr v287 : ptr; - hir.store v288, v839; + v840 = arith.constant 1 : u8; + v842 = arith.constant 1048584 : i32; + v284 = arith.add v282, v842 : i32 #[overflow = wrapping]; + v288 = hir.bitcast v284 : u32; + v289 = hir.int_to_ptr v288 : ptr; + hir.store v289, v840; scf.yield ; }; builtin.ret ; @@ -386,484 +387,484 @@ builtin.component miden:base/authentication-component@1.0.0 { private builtin.function @miden_base_sys::bindings::tx::get_block_number() -> felt { ^block19: - v290 = hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden::tx::get_block_number() : felt - builtin.ret v290; + v291 = hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden::tx::get_block_number() : felt + builtin.ret v291; }; - private builtin.function @miden_base_sys::bindings::tx::get_input_notes_commitment(v291: i32) { - ^block21(v291: i32): - v293 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr - v294 = hir.bitcast v293 : ptr; - v295 = hir.load v294 : i32; - v296 = arith.constant 32 : i32; - v297 = arith.sub v295, v296 : i32 #[overflow = wrapping]; - v298 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr - v299 = hir.bitcast v298 : ptr; - hir.store v299, v297; - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden::tx::get_input_notes_commitment(v297) - v301 = arith.constant 8 : u32; - v300 = hir.bitcast v297 : u32; - v302 = arith.add v300, v301 : u32 #[overflow = checked]; + private builtin.function @miden_base_sys::bindings::tx::get_input_notes_commitment(v292: i32) { + ^block21(v292: i32): + v294 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr + v295 = hir.bitcast v294 : ptr; + v296 = hir.load v295 : i32; + v297 = arith.constant 32 : i32; + v298 = arith.sub v296, v297 : i32 #[overflow = wrapping]; + v299 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr + v300 = hir.bitcast v299 : ptr; + hir.store v300, v298; + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden::tx::get_input_notes_commitment(v298) + v302 = arith.constant 8 : u32; + v301 = hir.bitcast v298 : u32; + v303 = arith.add v301, v302 : u32 #[overflow = checked]; + v847 = arith.constant 8 : u32; + v305 = arith.mod v303, v847 : u32; + hir.assertz v305 #[code = 250]; + v306 = hir.int_to_ptr v303 : ptr; + v307 = hir.load v306 : i64; + v309 = arith.constant 24 : u32; + v308 = hir.bitcast v298 : u32; + v310 = arith.add v308, v309 : u32 #[overflow = checked]; v846 = arith.constant 8 : u32; - v304 = arith.mod v302, v846 : u32; - hir.assertz v304 #[code = 250]; - v305 = hir.int_to_ptr v302 : ptr; - v306 = hir.load v305 : i64; - v308 = arith.constant 24 : u32; - v307 = hir.bitcast v297 : u32; - v309 = arith.add v307, v308 : u32 #[overflow = checked]; + v312 = arith.mod v310, v846 : u32; + hir.assertz v312 #[code = 250]; + v313 = hir.int_to_ptr v310 : ptr; + hir.store v313, v307; + v314 = hir.bitcast v298 : u32; v845 = arith.constant 8 : u32; - v311 = arith.mod v309, v845 : u32; - hir.assertz v311 #[code = 250]; - v312 = hir.int_to_ptr v309 : ptr; - hir.store v312, v306; - v313 = hir.bitcast v297 : u32; + v316 = arith.mod v314, v845 : u32; + hir.assertz v316 #[code = 250]; + v317 = hir.int_to_ptr v314 : ptr; + v318 = hir.load v317 : i64; + v320 = arith.constant 16 : u32; + v319 = hir.bitcast v298 : u32; + v321 = arith.add v319, v320 : u32 #[overflow = checked]; v844 = arith.constant 8 : u32; - v315 = arith.mod v313, v844 : u32; - hir.assertz v315 #[code = 250]; - v316 = hir.int_to_ptr v313 : ptr; - v317 = hir.load v316 : i64; - v319 = arith.constant 16 : u32; - v318 = hir.bitcast v297 : u32; - v320 = arith.add v318, v319 : u32 #[overflow = checked]; - v843 = arith.constant 8 : u32; - v322 = arith.mod v320, v843 : u32; - hir.assertz v322 #[code = 250]; - v323 = hir.int_to_ptr v320 : ptr; - hir.store v323, v317; - v324 = arith.constant 16 : i32; - v325 = arith.add v297, v324 : i32 #[overflow = wrapping]; - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden_stdlib_sys::intrinsics::word::Word::reverse(v291, v325) - v842 = arith.constant 32 : i32; - v327 = arith.add v297, v842 : i32 #[overflow = wrapping]; - v328 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr - v329 = hir.bitcast v328 : ptr; - hir.store v329, v327; + v323 = arith.mod v321, v844 : u32; + hir.assertz v323 #[code = 250]; + v324 = hir.int_to_ptr v321 : ptr; + hir.store v324, v318; + v325 = arith.constant 16 : i32; + v326 = arith.add v298, v325 : i32 #[overflow = wrapping]; + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden_stdlib_sys::intrinsics::word::Word::reverse(v292, v326) + v843 = arith.constant 32 : i32; + v328 = arith.add v298, v843 : i32 #[overflow = wrapping]; + v329 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr + v330 = hir.bitcast v329 : ptr; + hir.store v330, v328; builtin.ret ; }; - private builtin.function @miden_base_sys::bindings::tx::get_output_notes_commitment(v330: i32) { - ^block23(v330: i32): - v332 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr - v333 = hir.bitcast v332 : ptr; - v334 = hir.load v333 : i32; - v335 = arith.constant 32 : i32; - v336 = arith.sub v334, v335 : i32 #[overflow = wrapping]; - v337 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr - v338 = hir.bitcast v337 : ptr; - hir.store v338, v336; - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden::tx::get_output_notes_commitment(v336) - v340 = arith.constant 8 : u32; - v339 = hir.bitcast v336 : u32; - v341 = arith.add v339, v340 : u32 #[overflow = checked]; + private builtin.function @miden_base_sys::bindings::tx::get_output_notes_commitment(v331: i32) { + ^block23(v331: i32): + v333 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr + v334 = hir.bitcast v333 : ptr; + v335 = hir.load v334 : i32; + v336 = arith.constant 32 : i32; + v337 = arith.sub v335, v336 : i32 #[overflow = wrapping]; + v338 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr + v339 = hir.bitcast v338 : ptr; + hir.store v339, v337; + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden::tx::get_output_notes_commitment(v337) + v341 = arith.constant 8 : u32; + v340 = hir.bitcast v337 : u32; + v342 = arith.add v340, v341 : u32 #[overflow = checked]; + v852 = arith.constant 8 : u32; + v344 = arith.mod v342, v852 : u32; + hir.assertz v344 #[code = 250]; + v345 = hir.int_to_ptr v342 : ptr; + v346 = hir.load v345 : i64; + v348 = arith.constant 24 : u32; + v347 = hir.bitcast v337 : u32; + v349 = arith.add v347, v348 : u32 #[overflow = checked]; v851 = arith.constant 8 : u32; - v343 = arith.mod v341, v851 : u32; - hir.assertz v343 #[code = 250]; - v344 = hir.int_to_ptr v341 : ptr; - v345 = hir.load v344 : i64; - v347 = arith.constant 24 : u32; - v346 = hir.bitcast v336 : u32; - v348 = arith.add v346, v347 : u32 #[overflow = checked]; + v351 = arith.mod v349, v851 : u32; + hir.assertz v351 #[code = 250]; + v352 = hir.int_to_ptr v349 : ptr; + hir.store v352, v346; + v353 = hir.bitcast v337 : u32; v850 = arith.constant 8 : u32; - v350 = arith.mod v348, v850 : u32; - hir.assertz v350 #[code = 250]; - v351 = hir.int_to_ptr v348 : ptr; - hir.store v351, v345; - v352 = hir.bitcast v336 : u32; + v355 = arith.mod v353, v850 : u32; + hir.assertz v355 #[code = 250]; + v356 = hir.int_to_ptr v353 : ptr; + v357 = hir.load v356 : i64; + v359 = arith.constant 16 : u32; + v358 = hir.bitcast v337 : u32; + v360 = arith.add v358, v359 : u32 #[overflow = checked]; v849 = arith.constant 8 : u32; - v354 = arith.mod v352, v849 : u32; - hir.assertz v354 #[code = 250]; - v355 = hir.int_to_ptr v352 : ptr; - v356 = hir.load v355 : i64; - v358 = arith.constant 16 : u32; - v357 = hir.bitcast v336 : u32; - v359 = arith.add v357, v358 : u32 #[overflow = checked]; - v848 = arith.constant 8 : u32; - v361 = arith.mod v359, v848 : u32; - hir.assertz v361 #[code = 250]; - v362 = hir.int_to_ptr v359 : ptr; - hir.store v362, v356; - v363 = arith.constant 16 : i32; - v364 = arith.add v336, v363 : i32 #[overflow = wrapping]; - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden_stdlib_sys::intrinsics::word::Word::reverse(v330, v364) - v847 = arith.constant 32 : i32; - v366 = arith.add v336, v847 : i32 #[overflow = wrapping]; - v367 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr - v368 = hir.bitcast v367 : ptr; - hir.store v368, v366; + v362 = arith.mod v360, v849 : u32; + hir.assertz v362 #[code = 250]; + v363 = hir.int_to_ptr v360 : ptr; + hir.store v363, v357; + v364 = arith.constant 16 : i32; + v365 = arith.add v337, v364 : i32 #[overflow = wrapping]; + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden_stdlib_sys::intrinsics::word::Word::reverse(v331, v365) + v848 = arith.constant 32 : i32; + v367 = arith.add v337, v848 : i32 #[overflow = wrapping]; + v368 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr + v369 = hir.bitcast v368 : ptr; + hir.store v369, v367; builtin.ret ; }; - private builtin.function @core::ptr::swap_nonoverlapping_bytes::swap_nonoverlapping_chunks(v369: i32, v370: i32, v371: i32) { - ^block25(v369: i32, v370: i32, v371: i32): - v866, v867, v868 = scf.while v371, v369, v370 : i32, i32, i32 { - ^block28(v373: i32, v380: i32, v384: i32): - v887 = arith.constant 0 : i32; - v372 = arith.constant 0 : i32; - v375 = arith.eq v373, v372 : i1; - v376 = arith.zext v375 : u32; - v377 = hir.bitcast v376 : i32; - v379 = arith.neq v377, v887 : i1; - v881, v882, v883 = scf.if v379 : i32, i32, i32 { + private builtin.function @core::ptr::swap_nonoverlapping_bytes::swap_nonoverlapping_chunks(v370: i32, v371: i32, v372: i32) { + ^block25(v370: i32, v371: i32, v372: i32): + v867, v868, v869 = scf.while v372, v370, v371 : i32, i32, i32 { + ^block28(v374: i32, v381: i32, v385: i32): + v888 = arith.constant 0 : i32; + v373 = arith.constant 0 : i32; + v376 = arith.eq v374, v373 : i1; + v377 = arith.zext v376 : u32; + v378 = hir.bitcast v377 : i32; + v380 = arith.neq v378, v888 : i1; + v882, v883, v884 = scf.if v380 : i32, i32, i32 { ^block95: - v859 = ub.poison i32 : i32; - scf.yield v859, v859, v859; + v860 = ub.poison i32 : i32; + scf.yield v860, v860, v860; } else { ^block30: - v381 = hir.bitcast v380 : u32; - v382 = hir.int_to_ptr v381 : ptr; - v383 = hir.load v382 : i32; - v385 = hir.bitcast v384 : u32; - v386 = hir.int_to_ptr v385 : ptr; - v387 = hir.load v386 : i32; - v388 = hir.bitcast v380 : u32; - v389 = hir.int_to_ptr v388 : ptr; - hir.store v389, v387; - v390 = hir.bitcast v384 : u32; - v391 = hir.int_to_ptr v390 : ptr; - hir.store v391, v383; - v886 = arith.constant 4 : i32; - v395 = arith.add v384, v886 : i32 #[overflow = wrapping]; - v394 = arith.constant 4 : i32; - v397 = arith.add v380, v394 : i32 #[overflow = wrapping]; - v392 = arith.constant -1 : i32; - v393 = arith.add v373, v392 : i32 #[overflow = wrapping]; - scf.yield v393, v397, v395; + v382 = hir.bitcast v381 : u32; + v383 = hir.int_to_ptr v382 : ptr; + v384 = hir.load v383 : i32; + v386 = hir.bitcast v385 : u32; + v387 = hir.int_to_ptr v386 : ptr; + v388 = hir.load v387 : i32; + v389 = hir.bitcast v381 : u32; + v390 = hir.int_to_ptr v389 : ptr; + hir.store v390, v388; + v391 = hir.bitcast v385 : u32; + v392 = hir.int_to_ptr v391 : ptr; + hir.store v392, v384; + v887 = arith.constant 4 : i32; + v396 = arith.add v385, v887 : i32 #[overflow = wrapping]; + v395 = arith.constant 4 : i32; + v398 = arith.add v381, v395 : i32 #[overflow = wrapping]; + v393 = arith.constant -1 : i32; + v394 = arith.add v374, v393 : i32 #[overflow = wrapping]; + scf.yield v394, v398, v396; }; - v858 = arith.constant 1 : u32; - v852 = arith.constant 0 : u32; - v885 = cf.select v379, v852, v858 : u32; - v875 = arith.trunc v885 : i1; - scf.condition v875, v881, v882, v883; + v859 = arith.constant 1 : u32; + v853 = arith.constant 0 : u32; + v886 = cf.select v380, v853, v859 : u32; + v876 = arith.trunc v886 : i1; + scf.condition v876, v882, v883, v884; } do { - ^block94(v872: i32, v873: i32, v874: i32): - scf.yield v872, v873, v874; + ^block94(v873: i32, v874: i32, v875: i32): + scf.yield v873, v874, v875; }; builtin.ret ; }; - private builtin.function @miden_stdlib_sys::intrinsics::advice::adv_insert(v398: i32, v399: i32, v400: i32) { - ^block31(v398: i32, v399: i32, v400: i32): - v402 = arith.constant 12 : u32; - v401 = hir.bitcast v398 : u32; - v403 = arith.add v401, v402 : u32 #[overflow = checked]; - v404 = arith.constant 4 : u32; - v405 = arith.mod v403, v404 : u32; - hir.assertz v405 #[code = 250]; - v406 = hir.int_to_ptr v403 : ptr; - v407 = hir.load v406 : felt; - v409 = arith.constant 8 : u32; - v408 = hir.bitcast v398 : u32; - v410 = arith.add v408, v409 : u32 #[overflow = checked]; + private builtin.function @miden_stdlib_sys::intrinsics::advice::adv_insert(v399: i32, v400: i32, v401: i32) { + ^block31(v399: i32, v400: i32, v401: i32): + v403 = arith.constant 12 : u32; + v402 = hir.bitcast v399 : u32; + v404 = arith.add v402, v403 : u32 #[overflow = checked]; + v405 = arith.constant 4 : u32; + v406 = arith.mod v404, v405 : u32; + hir.assertz v406 #[code = 250]; + v407 = hir.int_to_ptr v404 : ptr; + v408 = hir.load v407 : felt; + v410 = arith.constant 8 : u32; + v409 = hir.bitcast v399 : u32; + v411 = arith.add v409, v410 : u32 #[overflow = checked]; + v895 = arith.constant 4 : u32; + v413 = arith.mod v411, v895 : u32; + hir.assertz v413 #[code = 250]; + v414 = hir.int_to_ptr v411 : ptr; + v415 = hir.load v414 : felt; v894 = arith.constant 4 : u32; - v412 = arith.mod v410, v894 : u32; - hir.assertz v412 #[code = 250]; - v413 = hir.int_to_ptr v410 : ptr; - v414 = hir.load v413 : felt; + v416 = hir.bitcast v399 : u32; + v418 = arith.add v416, v894 : u32 #[overflow = checked]; v893 = arith.constant 4 : u32; - v415 = hir.bitcast v398 : u32; - v417 = arith.add v415, v893 : u32 #[overflow = checked]; + v420 = arith.mod v418, v893 : u32; + hir.assertz v420 #[code = 250]; + v421 = hir.int_to_ptr v418 : ptr; + v422 = hir.load v421 : felt; + v423 = hir.bitcast v399 : u32; v892 = arith.constant 4 : u32; - v419 = arith.mod v417, v892 : u32; - hir.assertz v419 #[code = 250]; - v420 = hir.int_to_ptr v417 : ptr; - v421 = hir.load v420 : felt; - v422 = hir.bitcast v398 : u32; - v891 = arith.constant 4 : u32; - v424 = arith.mod v422, v891 : u32; - hir.assertz v424 #[code = 250]; - v425 = hir.int_to_ptr v422 : ptr; - v426 = hir.load v425 : felt; - v889 = arith.constant 2 : u32; - v428 = hir.bitcast v399 : u32; - v430 = arith.shr v428, v889 : u32; - v431 = hir.bitcast v430 : i32; + v425 = arith.mod v423, v892 : u32; + hir.assertz v425 #[code = 250]; + v426 = hir.int_to_ptr v423 : ptr; + v427 = hir.load v426 : felt; v890 = arith.constant 2 : u32; - v434 = arith.shl v400, v890 : i32; - v435 = arith.add v431, v434 : i32 #[overflow = wrapping]; - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/intrinsics::advice::adv_insert_mem(v407, v414, v421, v426, v431, v435) + v429 = hir.bitcast v400 : u32; + v431 = arith.shr v429, v890 : u32; + v432 = hir.bitcast v431 : i32; + v891 = arith.constant 2 : u32; + v435 = arith.shl v401, v891 : i32; + v436 = arith.add v432, v435 : i32 #[overflow = wrapping]; + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/intrinsics::advice::adv_insert_mem(v408, v415, v422, v427, v432, v436) builtin.ret ; }; - private builtin.function @>::from(v436: i32) -> felt { - ^block33(v436: i32): - v438 = arith.constant 255 : i32; - v439 = arith.band v436, v438 : i32; - v440 = hir.bitcast v439 : felt; - builtin.ret v440; + private builtin.function @>::from(v437: i32) -> felt { + ^block33(v437: i32): + v439 = arith.constant 255 : i32; + v440 = arith.band v437, v439 : i32; + v441 = hir.bitcast v440 : felt; + builtin.ret v441; }; - private builtin.function @miden_stdlib_sys::intrinsics::word::Word::reverse(v441: i32, v442: i32) { - ^block35(v441: i32, v442: i32): - v445 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr - v446 = hir.bitcast v445 : ptr; - v447 = hir.load v446 : i32; - v448 = arith.constant 16 : i32; - v449 = arith.sub v447, v448 : i32 #[overflow = wrapping]; - v451 = arith.constant 8 : u32; - v450 = hir.bitcast v442 : u32; - v452 = arith.add v450, v451 : u32 #[overflow = checked]; + private builtin.function @miden_stdlib_sys::intrinsics::word::Word::reverse(v442: i32, v443: i32) { + ^block35(v442: i32, v443: i32): + v446 = builtin.global_symbol @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/__stack_pointer : ptr + v447 = hir.bitcast v446 : ptr; + v448 = hir.load v447 : i32; + v449 = arith.constant 16 : i32; + v450 = arith.sub v448, v449 : i32 #[overflow = wrapping]; + v452 = arith.constant 8 : u32; + v451 = hir.bitcast v443 : u32; + v453 = arith.add v451, v452 : u32 #[overflow = checked]; + v982 = arith.constant 8 : u32; + v455 = arith.mod v453, v982 : u32; + hir.assertz v455 #[code = 250]; + v456 = hir.int_to_ptr v453 : ptr; + v457 = hir.load v456 : i64; v981 = arith.constant 8 : u32; - v454 = arith.mod v452, v981 : u32; - hir.assertz v454 #[code = 250]; - v455 = hir.int_to_ptr v452 : ptr; - v456 = hir.load v455 : i64; + v458 = hir.bitcast v450 : u32; + v460 = arith.add v458, v981 : u32 #[overflow = checked]; + v461 = arith.constant 4 : u32; + v462 = arith.mod v460, v461 : u32; + hir.assertz v462 #[code = 250]; + v463 = hir.int_to_ptr v460 : ptr; + hir.store v463, v457; + v464 = hir.bitcast v443 : u32; v980 = arith.constant 8 : u32; - v457 = hir.bitcast v449 : u32; - v459 = arith.add v457, v980 : u32 #[overflow = checked]; - v460 = arith.constant 4 : u32; - v461 = arith.mod v459, v460 : u32; - hir.assertz v461 #[code = 250]; - v462 = hir.int_to_ptr v459 : ptr; - hir.store v462, v456; - v463 = hir.bitcast v442 : u32; - v979 = arith.constant 8 : u32; - v465 = arith.mod v463, v979 : u32; - hir.assertz v465 #[code = 250]; - v466 = hir.int_to_ptr v463 : ptr; - v467 = hir.load v466 : i64; - v468 = hir.bitcast v449 : u32; - v978 = arith.constant 4 : u32; - v470 = arith.mod v468, v978 : u32; - hir.assertz v470 #[code = 250]; - v471 = hir.int_to_ptr v468 : ptr; - hir.store v471, v467; - v472 = arith.constant 12 : i32; - v473 = arith.add v449, v472 : i32 #[overflow = wrapping]; - v443 = arith.constant 0 : i32; - v949, v950, v951, v952, v953, v954 = scf.while v443, v449, v473, v441 : i32, i32, i32, i32, i32, i32 { - ^block103(v955: i32, v956: i32, v957: i32, v958: i32): - v977 = arith.constant 0 : i32; - v476 = arith.constant 8 : i32; - v477 = arith.eq v955, v476 : i1; - v478 = arith.zext v477 : u32; - v479 = hir.bitcast v478 : i32; - v481 = arith.neq v479, v977 : i1; - v943, v944 = scf.if v481 : i32, i32 { + v466 = arith.mod v464, v980 : u32; + hir.assertz v466 #[code = 250]; + v467 = hir.int_to_ptr v464 : ptr; + v468 = hir.load v467 : i64; + v469 = hir.bitcast v450 : u32; + v979 = arith.constant 4 : u32; + v471 = arith.mod v469, v979 : u32; + hir.assertz v471 #[code = 250]; + v472 = hir.int_to_ptr v469 : ptr; + hir.store v472, v468; + v473 = arith.constant 12 : i32; + v474 = arith.add v450, v473 : i32 #[overflow = wrapping]; + v444 = arith.constant 0 : i32; + v950, v951, v952, v953, v954, v955 = scf.while v444, v450, v474, v442 : i32, i32, i32, i32, i32, i32 { + ^block103(v956: i32, v957: i32, v958: i32, v959: i32): + v978 = arith.constant 0 : i32; + v477 = arith.constant 8 : i32; + v478 = arith.eq v956, v477 : i1; + v479 = arith.zext v478 : u32; + v480 = hir.bitcast v479 : i32; + v482 = arith.neq v480, v978 : i1; + v944, v945 = scf.if v482 : i32, i32 { ^block102: - v903 = ub.poison i32 : i32; - scf.yield v903, v903; + v904 = ub.poison i32 : i32; + scf.yield v904, v904; } else { ^block40: - v483 = arith.add v956, v955 : i32 #[overflow = wrapping]; - v484 = hir.bitcast v483 : u32; + v484 = arith.add v957, v956 : i32 #[overflow = wrapping]; + v485 = hir.bitcast v484 : u32; + v977 = arith.constant 4 : u32; + v487 = arith.mod v485, v977 : u32; + hir.assertz v487 #[code = 250]; + v488 = hir.int_to_ptr v485 : ptr; + v489 = hir.load v488 : felt; + v491 = hir.bitcast v958 : u32; v976 = arith.constant 4 : u32; - v486 = arith.mod v484, v976 : u32; - hir.assertz v486 #[code = 250]; - v487 = hir.int_to_ptr v484 : ptr; - v488 = hir.load v487 : felt; - v490 = hir.bitcast v957 : u32; + v493 = arith.mod v491, v976 : u32; + hir.assertz v493 #[code = 250]; + v494 = hir.int_to_ptr v491 : ptr; + v495 = hir.load v494 : i32; + v496 = hir.bitcast v484 : u32; v975 = arith.constant 4 : u32; - v492 = arith.mod v490, v975 : u32; - hir.assertz v492 #[code = 250]; - v493 = hir.int_to_ptr v490 : ptr; - v494 = hir.load v493 : i32; - v495 = hir.bitcast v483 : u32; + v498 = arith.mod v496, v975 : u32; + hir.assertz v498 #[code = 250]; + v499 = hir.int_to_ptr v496 : ptr; + hir.store v499, v495; + v500 = hir.bitcast v958 : u32; v974 = arith.constant 4 : u32; - v497 = arith.mod v495, v974 : u32; - hir.assertz v497 #[code = 250]; - v498 = hir.int_to_ptr v495 : ptr; - hir.store v498, v494; - v499 = hir.bitcast v957 : u32; - v973 = arith.constant 4 : u32; - v501 = arith.mod v499, v973 : u32; - hir.assertz v501 #[code = 250]; - v502 = hir.int_to_ptr v499 : ptr; - hir.store v502, v488; - v505 = arith.constant -4 : i32; - v506 = arith.add v957, v505 : i32 #[overflow = wrapping]; - v503 = arith.constant 4 : i32; - v504 = arith.add v955, v503 : i32 #[overflow = wrapping]; - scf.yield v504, v506; + v502 = arith.mod v500, v974 : u32; + hir.assertz v502 #[code = 250]; + v503 = hir.int_to_ptr v500 : ptr; + hir.store v503, v489; + v506 = arith.constant -4 : i32; + v507 = arith.add v958, v506 : i32 #[overflow = wrapping]; + v504 = arith.constant 4 : i32; + v505 = arith.add v956, v504 : i32 #[overflow = wrapping]; + scf.yield v505, v507; }; - v971 = ub.poison i32 : i32; - v946 = cf.select v481, v971, v958 : i32; v972 = ub.poison i32 : i32; - v945 = cf.select v481, v972, v956 : i32; - v902 = arith.constant 1 : u32; - v895 = arith.constant 0 : u32; - v948 = cf.select v481, v895, v902 : u32; - v936 = arith.trunc v948 : i1; - scf.condition v936, v943, v945, v944, v946, v956, v958; + v947 = cf.select v482, v972, v959 : i32; + v973 = ub.poison i32 : i32; + v946 = cf.select v482, v973, v957 : i32; + v903 = arith.constant 1 : u32; + v896 = arith.constant 0 : u32; + v949 = cf.select v482, v896, v903 : u32; + v937 = arith.trunc v949 : i1; + scf.condition v937, v944, v946, v945, v947, v957, v959; } do { - ^block104(v959: i32, v960: i32, v961: i32, v962: i32, v963: i32, v964: i32): - scf.yield v959, v960, v961, v962; + ^block104(v960: i32, v961: i32, v962: i32, v963: i32, v964: i32, v965: i32): + scf.yield v960, v961, v962, v963; }; - v970 = arith.constant 8 : u32; - v508 = hir.bitcast v953 : u32; - v510 = arith.add v508, v970 : u32 #[overflow = checked]; - v969 = arith.constant 4 : u32; - v512 = arith.mod v510, v969 : u32; - hir.assertz v512 #[code = 250]; - v513 = hir.int_to_ptr v510 : ptr; - v514 = hir.load v513 : i64; + v971 = arith.constant 8 : u32; + v509 = hir.bitcast v954 : u32; + v511 = arith.add v509, v971 : u32 #[overflow = checked]; + v970 = arith.constant 4 : u32; + v513 = arith.mod v511, v970 : u32; + hir.assertz v513 #[code = 250]; + v514 = hir.int_to_ptr v511 : ptr; + v515 = hir.load v514 : i64; + v969 = arith.constant 8 : u32; + v516 = hir.bitcast v955 : u32; + v518 = arith.add v516, v969 : u32 #[overflow = checked]; v968 = arith.constant 8 : u32; - v515 = hir.bitcast v954 : u32; - v517 = arith.add v515, v968 : u32 #[overflow = checked]; - v967 = arith.constant 8 : u32; - v519 = arith.mod v517, v967 : u32; - hir.assertz v519 #[code = 250]; - v520 = hir.int_to_ptr v517 : ptr; - hir.store v520, v514; - v521 = hir.bitcast v953 : u32; - v966 = arith.constant 4 : u32; - v523 = arith.mod v521, v966 : u32; - hir.assertz v523 #[code = 250]; - v524 = hir.int_to_ptr v521 : ptr; - v525 = hir.load v524 : i64; - v526 = hir.bitcast v954 : u32; - v965 = arith.constant 8 : u32; - v528 = arith.mod v526, v965 : u32; - hir.assertz v528 #[code = 250]; - v529 = hir.int_to_ptr v526 : ptr; - hir.store v529, v525; + v520 = arith.mod v518, v968 : u32; + hir.assertz v520 #[code = 250]; + v521 = hir.int_to_ptr v518 : ptr; + hir.store v521, v515; + v522 = hir.bitcast v954 : u32; + v967 = arith.constant 4 : u32; + v524 = arith.mod v522, v967 : u32; + hir.assertz v524 #[code = 250]; + v525 = hir.int_to_ptr v522 : ptr; + v526 = hir.load v525 : i64; + v527 = hir.bitcast v955 : u32; + v966 = arith.constant 8 : u32; + v529 = arith.mod v527, v966 : u32; + hir.assertz v529 #[code = 250]; + v530 = hir.int_to_ptr v527 : ptr; + hir.store v530, v526; builtin.ret ; }; - private builtin.function @intrinsics::felt::from_u32(v530: i32) -> felt { - ^block41(v530: i32): - v531 = hir.bitcast v530 : felt; - builtin.ret v531; + private builtin.function @intrinsics::felt::from_u32(v531: i32) -> felt { + ^block41(v531: i32): + v532 = hir.bitcast v531 : felt; + builtin.ret v532; }; - private builtin.function @intrinsics::felt::assert_eq(v533: felt, v534: felt) { - ^block43(v533: felt, v534: felt): - hir.assert_eq v533, v534; + private builtin.function @intrinsics::felt::assert_eq(v534: felt, v535: felt) { + ^block43(v534: felt, v535: felt): + hir.assert_eq v534, v535; builtin.ret ; }; - private builtin.function @intrinsics::advice::emit_falcon_sig_to_stack(v535: felt, v536: felt, v537: felt, v538: felt, v539: felt, v540: felt, v541: felt, v542: felt) { - ^block45(v535: felt, v536: felt, v537: felt, v538: felt, v539: felt, v540: felt, v541: felt, v542: felt): - hir.exec @intrinsics/advice/emit_falcon_sig_to_stack(v535, v536, v537, v538, v539, v540, v541, v542) + private builtin.function @intrinsics::advice::emit_falcon_sig_to_stack(v536: felt, v537: felt, v538: felt, v539: felt, v540: felt, v541: felt, v542: felt, v543: felt) { + ^block45(v536: felt, v537: felt, v538: felt, v539: felt, v540: felt, v541: felt, v542: felt, v543: felt): + hir.exec @intrinsics/advice/emit_falcon_sig_to_stack(v536, v537, v538, v539, v540, v541, v542, v543) builtin.ret ; }; - private builtin.function @intrinsics::advice::adv_insert_mem(v543: felt, v544: felt, v545: felt, v546: felt, v547: i32, v548: i32) { - ^block49(v543: felt, v544: felt, v545: felt, v546: felt, v547: i32, v548: i32): - hir.exec @intrinsics/advice/adv_insert_mem(v543, v544, v545, v546, v547, v548) + private builtin.function @intrinsics::advice::adv_insert_mem(v544: felt, v545: felt, v546: felt, v547: felt, v548: i32, v549: i32) { + ^block49(v544: felt, v545: felt, v546: felt, v547: felt, v548: i32, v549: i32): + hir.exec @intrinsics/advice/adv_insert_mem(v544, v545, v546, v547, v548, v549) builtin.ret ; }; - private builtin.function @std::crypto::hashes::rpo::hash_memory(v549: i32, v550: i32, v551: i32) { - ^block51(v549: i32, v550: i32, v551: i32): - v552, v553, v554, v555 = hir.exec @std/crypto/hashes/rpo/hash_memory(v549, v550) : felt, felt, felt, felt - v556 = hir.bitcast v551 : u32; - v557 = hir.int_to_ptr v556 : ptr; - hir.store v557, v552; - v558 = arith.constant 4 : u32; - v559 = arith.add v556, v558 : u32 #[overflow = checked]; - v560 = hir.int_to_ptr v559 : ptr; - hir.store v560, v553; - v561 = arith.constant 8 : u32; - v562 = arith.add v556, v561 : u32 #[overflow = checked]; - v563 = hir.int_to_ptr v562 : ptr; - hir.store v563, v554; - v564 = arith.constant 12 : u32; - v565 = arith.add v556, v564 : u32 #[overflow = checked]; - v566 = hir.int_to_ptr v565 : ptr; - hir.store v566, v555; + private builtin.function @std::crypto::hashes::rpo::hash_memory_words(v550: i32, v551: i32, v552: i32) { + ^block51(v550: i32, v551: i32, v552: i32): + v553, v554, v555, v556 = hir.exec @std/crypto/hashes/rpo/hash_memory_words(v550, v551) : felt, felt, felt, felt + v557 = hir.bitcast v552 : u32; + v558 = hir.int_to_ptr v557 : ptr; + hir.store v558, v553; + v559 = arith.constant 4 : u32; + v560 = arith.add v557, v559 : u32 #[overflow = checked]; + v561 = hir.int_to_ptr v560 : ptr; + hir.store v561, v554; + v562 = arith.constant 8 : u32; + v563 = arith.add v557, v562 : u32 #[overflow = checked]; + v564 = hir.int_to_ptr v563 : ptr; + hir.store v564, v555; + v565 = arith.constant 12 : u32; + v566 = arith.add v557, v565 : u32 #[overflow = checked]; + v567 = hir.int_to_ptr v566 : ptr; + hir.store v567, v556; builtin.ret ; }; - private builtin.function @std::crypto::dsa::rpo_falcon512::verify(v567: felt, v568: felt, v569: felt, v570: felt, v571: felt, v572: felt, v573: felt, v574: felt) { - ^block57(v567: felt, v568: felt, v569: felt, v570: felt, v571: felt, v572: felt, v573: felt, v574: felt): - hir.exec @std/crypto/dsa/rpo_falcon512/verify(v567, v568, v569, v570, v571, v572, v573, v574) + private builtin.function @std::crypto::dsa::rpo_falcon512::verify(v568: felt, v569: felt, v570: felt, v571: felt, v572: felt, v573: felt, v574: felt, v575: felt) { + ^block57(v568: felt, v569: felt, v570: felt, v571: felt, v572: felt, v573: felt, v574: felt, v575: felt): + hir.exec @std/crypto/dsa/rpo_falcon512/verify(v568, v569, v570, v571, v572, v573, v574, v575) builtin.ret ; }; - private builtin.function @miden::account::compute_delta_commitment(v575: i32) { - ^block61(v575: i32): - v576, v577, v578, v579 = hir.exec @miden/account/compute_delta_commitment() : felt, felt, felt, felt - v580 = hir.bitcast v575 : u32; - v581 = hir.int_to_ptr v580 : ptr; - hir.store v581, v576; - v582 = arith.constant 4 : u32; - v583 = arith.add v580, v582 : u32 #[overflow = checked]; - v584 = hir.int_to_ptr v583 : ptr; - hir.store v584, v577; - v585 = arith.constant 8 : u32; - v586 = arith.add v580, v585 : u32 #[overflow = checked]; - v587 = hir.int_to_ptr v586 : ptr; - hir.store v587, v578; - v588 = arith.constant 12 : u32; - v589 = arith.add v580, v588 : u32 #[overflow = checked]; - v590 = hir.int_to_ptr v589 : ptr; - hir.store v590, v579; + private builtin.function @miden::account::compute_delta_commitment(v576: i32) { + ^block61(v576: i32): + v577, v578, v579, v580 = hir.exec @miden/account/compute_delta_commitment() : felt, felt, felt, felt + v581 = hir.bitcast v576 : u32; + v582 = hir.int_to_ptr v581 : ptr; + hir.store v582, v577; + v583 = arith.constant 4 : u32; + v584 = arith.add v581, v583 : u32 #[overflow = checked]; + v585 = hir.int_to_ptr v584 : ptr; + hir.store v585, v578; + v586 = arith.constant 8 : u32; + v587 = arith.add v581, v586 : u32 #[overflow = checked]; + v588 = hir.int_to_ptr v587 : ptr; + hir.store v588, v579; + v589 = arith.constant 12 : u32; + v590 = arith.add v581, v589 : u32 #[overflow = checked]; + v591 = hir.int_to_ptr v590 : ptr; + hir.store v591, v580; builtin.ret ; }; - private builtin.function @miden::account::get_item(v591: felt, v592: i32) { - ^block65(v591: felt, v592: i32): - v593, v594, v595, v596 = hir.exec @miden/account/get_item(v591) : felt, felt, felt, felt - v597 = hir.bitcast v592 : u32; - v598 = hir.int_to_ptr v597 : ptr; - hir.store v598, v593; - v599 = arith.constant 4 : u32; - v600 = arith.add v597, v599 : u32 #[overflow = checked]; - v601 = hir.int_to_ptr v600 : ptr; - hir.store v601, v594; - v602 = arith.constant 8 : u32; - v603 = arith.add v597, v602 : u32 #[overflow = checked]; - v604 = hir.int_to_ptr v603 : ptr; - hir.store v604, v595; - v605 = arith.constant 12 : u32; - v606 = arith.add v597, v605 : u32 #[overflow = checked]; - v607 = hir.int_to_ptr v606 : ptr; - hir.store v607, v596; + private builtin.function @miden::account::get_item(v592: felt, v593: i32) { + ^block65(v592: felt, v593: i32): + v594, v595, v596, v597 = hir.exec @miden/account/get_item(v592) : felt, felt, felt, felt + v598 = hir.bitcast v593 : u32; + v599 = hir.int_to_ptr v598 : ptr; + hir.store v599, v594; + v600 = arith.constant 4 : u32; + v601 = arith.add v598, v600 : u32 #[overflow = checked]; + v602 = hir.int_to_ptr v601 : ptr; + hir.store v602, v595; + v603 = arith.constant 8 : u32; + v604 = arith.add v598, v603 : u32 #[overflow = checked]; + v605 = hir.int_to_ptr v604 : ptr; + hir.store v605, v596; + v606 = arith.constant 12 : u32; + v607 = arith.add v598, v606 : u32 #[overflow = checked]; + v608 = hir.int_to_ptr v607 : ptr; + hir.store v608, v597; builtin.ret ; }; private builtin.function @miden::account::incr_nonce() -> felt { ^block67: - v608 = hir.exec @miden/account/incr_nonce() : felt - builtin.ret v608; + v609 = hir.exec @miden/account/incr_nonce() : felt + builtin.ret v609; }; private builtin.function @miden::tx::get_block_number() -> felt { ^block69: - v610 = hir.exec @miden/tx/get_block_number() : felt - builtin.ret v610; + v611 = hir.exec @miden/tx/get_block_number() : felt + builtin.ret v611; }; - private builtin.function @miden::tx::get_input_notes_commitment(v612: i32) { - ^block72(v612: i32): - v613, v614, v615, v616 = hir.exec @miden/tx/get_input_notes_commitment() : felt, felt, felt, felt - v617 = hir.bitcast v612 : u32; - v618 = hir.int_to_ptr v617 : ptr; - hir.store v618, v613; - v619 = arith.constant 4 : u32; - v620 = arith.add v617, v619 : u32 #[overflow = checked]; - v621 = hir.int_to_ptr v620 : ptr; - hir.store v621, v614; - v622 = arith.constant 8 : u32; - v623 = arith.add v617, v622 : u32 #[overflow = checked]; - v624 = hir.int_to_ptr v623 : ptr; - hir.store v624, v615; - v625 = arith.constant 12 : u32; - v626 = arith.add v617, v625 : u32 #[overflow = checked]; - v627 = hir.int_to_ptr v626 : ptr; - hir.store v627, v616; + private builtin.function @miden::tx::get_input_notes_commitment(v613: i32) { + ^block72(v613: i32): + v614, v615, v616, v617 = hir.exec @miden/tx/get_input_notes_commitment() : felt, felt, felt, felt + v618 = hir.bitcast v613 : u32; + v619 = hir.int_to_ptr v618 : ptr; + hir.store v619, v614; + v620 = arith.constant 4 : u32; + v621 = arith.add v618, v620 : u32 #[overflow = checked]; + v622 = hir.int_to_ptr v621 : ptr; + hir.store v622, v615; + v623 = arith.constant 8 : u32; + v624 = arith.add v618, v623 : u32 #[overflow = checked]; + v625 = hir.int_to_ptr v624 : ptr; + hir.store v625, v616; + v626 = arith.constant 12 : u32; + v627 = arith.add v618, v626 : u32 #[overflow = checked]; + v628 = hir.int_to_ptr v627 : ptr; + hir.store v628, v617; builtin.ret ; }; - private builtin.function @miden::tx::get_output_notes_commitment(v628: i32) { - ^block74(v628: i32): - v629, v630, v631, v632 = hir.exec @miden/tx/get_output_notes_commitment() : felt, felt, felt, felt - v633 = hir.bitcast v628 : u32; - v634 = hir.int_to_ptr v633 : ptr; - hir.store v634, v629; - v635 = arith.constant 4 : u32; - v636 = arith.add v633, v635 : u32 #[overflow = checked]; - v637 = hir.int_to_ptr v636 : ptr; - hir.store v637, v630; - v638 = arith.constant 8 : u32; - v639 = arith.add v633, v638 : u32 #[overflow = checked]; - v640 = hir.int_to_ptr v639 : ptr; - hir.store v640, v631; - v641 = arith.constant 12 : u32; - v642 = arith.add v633, v641 : u32 #[overflow = checked]; - v643 = hir.int_to_ptr v642 : ptr; - hir.store v643, v632; + private builtin.function @miden::tx::get_output_notes_commitment(v629: i32) { + ^block74(v629: i32): + v630, v631, v632, v633 = hir.exec @miden/tx/get_output_notes_commitment() : felt, felt, felt, felt + v634 = hir.bitcast v629 : u32; + v635 = hir.int_to_ptr v634 : ptr; + hir.store v635, v630; + v636 = arith.constant 4 : u32; + v637 = arith.add v634, v636 : u32 #[overflow = checked]; + v638 = hir.int_to_ptr v637 : ptr; + hir.store v638, v631; + v639 = arith.constant 8 : u32; + v640 = arith.add v634, v639 : u32 #[overflow = checked]; + v641 = hir.int_to_ptr v640 : ptr; + hir.store v641, v632; + v642 = arith.constant 12 : u32; + v643 = arith.add v634, v642 : u32 #[overflow = checked]; + v644 = hir.int_to_ptr v643 : ptr; + hir.store v644, v633; builtin.ret ; }; @@ -878,9 +879,9 @@ builtin.component miden:base/authentication-component@1.0.0 { builtin.segment @1048576 = 0x0000000100000001; }; - public builtin.function @auth__procedure(v644: felt, v645: felt, v646: felt, v647: felt) { - ^block76(v644: felt, v645: felt, v646: felt, v647: felt): - hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden:base/authentication-component@1.0.0#auth-procedure(v644, v645, v646, v647) + public builtin.function @auth__procedure(v645: felt, v646: felt, v647: felt, v648: felt) { + ^block76(v645: felt, v646: felt, v647: felt, v648: felt): + hir.exec @miden:base/authentication-component@1.0.0/auth_component_rpo_falcon512/miden:base/authentication-component@1.0.0#auth-procedure(v645, v646, v647, v648) builtin.ret ; }; }; \ No newline at end of file diff --git a/tests/integration/expected/examples/auth_component_rpo_falcon512.masm b/tests/integration/expected/examples/auth_component_rpo_falcon512.masm index 98abdaa52..d505249fa 100644 --- a/tests/integration/expected/examples/auth_component_rpo_falcon512.masm +++ b/tests/integration/expected/examples/auth_component_rpo_falcon512.masm @@ -284,17 +284,20 @@ proc.miden:base/authentication-component@1.0.0#auth-procedure exec.::miden:base/authentication-component@1.0.0::auth_component_rpo_falcon512::intrinsics::felt::assert_eq trace.252 nop - push.80 - dup.1 - u32wrapping_add - push.16 push.2 - dup.3 + dup.1 swap.1 u32shr + push.80 + dup.2 + u32wrapping_add + push.16 + dup.2 + u32wrapping_add + movup.2 trace.240 nop - exec.::miden:base/authentication-component@1.0.0::auth_component_rpo_falcon512::std::crypto::hashes::rpo::hash_memory + exec.::miden:base/authentication-component@1.0.0::auth_component_rpo_falcon512::std::crypto::hashes::rpo::hash_memory_words trace.252 nop push.88 @@ -1605,10 +1608,10 @@ proc.intrinsics::advice::adv_insert_mem nop end -proc.std::crypto::hashes::rpo::hash_memory +proc.std::crypto::hashes::rpo::hash_memory_words trace.240 nop - exec.::std::crypto::hashes::rpo::hash_memory + exec.::std::crypto::hashes::rpo::hash_memory_words trace.252 nop movup.4 diff --git a/tests/integration/expected/examples/auth_component_rpo_falcon512.wat b/tests/integration/expected/examples/auth_component_rpo_falcon512.wat index 64fad53a5..d7a9e4b38 100644 --- a/tests/integration/expected/examples/auth_component_rpo_falcon512.wat +++ b/tests/integration/expected/examples/auth_component_rpo_falcon512.wat @@ -95,11 +95,14 @@ local.get 4 i32.const 2 i32.shr_u + local.tee 10 + local.get 10 i32.const 16 + i32.add local.get 4 i32.const 80 i32.add - call $std::crypto::hashes::rpo::hash_memory + call $std::crypto::hashes::rpo::hash_memory_words local.get 4 local.get 4 i64.load offset=88 @@ -428,7 +431,7 @@ (func $intrinsics::advice::adv_insert_mem (;14;) (type 9) (param f32 f32 f32 f32 i32 i32) unreachable ) - (func $std::crypto::hashes::rpo::hash_memory (;15;) (type 4) (param i32 i32 i32) + (func $std::crypto::hashes::rpo::hash_memory_words (;15;) (type 4) (param i32 i32 i32) unreachable ) (func $std::crypto::dsa::rpo_falcon512::verify (;16;) (type 8) (param f32 f32 f32 f32 f32 f32 f32 f32) diff --git a/tests/integration/expected/hash_words.hir b/tests/integration/expected/hash_words.hir index 2c102461a..a7364e0d4 100644 --- a/tests/integration/expected/hash_words.hir +++ b/tests/integration/expected/hash_words.hir @@ -13,395 +13,396 @@ builtin.component root_ns:root@1.0.0 { v12 = arith.constant 4 : u32; v11 = hir.bitcast v0 : u32; v13 = arith.add v11, v12 : u32 #[overflow = checked]; - v310 = arith.constant 4 : u32; - v15 = arith.mod v13, v310 : u32; + v311 = arith.constant 4 : u32; + v15 = arith.mod v13, v311 : u32; hir.assertz v15 #[code = 250]; v16 = hir.int_to_ptr v13 : ptr; v17 = hir.load v16 : i32; v19 = arith.constant 8 : u32; v18 = hir.bitcast v0 : u32; v20 = arith.add v18, v19 : u32 #[overflow = checked]; - v309 = arith.constant 4 : u32; - v22 = arith.mod v20, v309 : u32; + v310 = arith.constant 4 : u32; + v22 = arith.mod v20, v310 : u32; hir.assertz v22 #[code = 250]; v23 = hir.int_to_ptr v20 : ptr; v24 = hir.load v23 : i32; v2 = arith.constant 0 : i32; v26 = hir.exec @root_ns:root@1.0.0/hash_words/intrinsics::felt::from_u32(v2) : felt - v308 = arith.constant 0 : i32; - v28 = hir.exec @root_ns:root@1.0.0/hash_words/intrinsics::felt::from_u32(v308) : felt + v309 = arith.constant 0 : i32; + v28 = hir.exec @root_ns:root@1.0.0/hash_words/intrinsics::felt::from_u32(v309) : felt hir.exec @root_ns:root@1.0.0/hash_words/intrinsics::felt::assert_eq(v26, v28) - v37 = arith.constant 16 : i32; - v38 = arith.add v8, v37 : i32 #[overflow = wrapping]; - v307 = arith.constant 2 : u32; - v36 = arith.shl v24, v307 : i32; - v299 = arith.constant 2 : u32; + v300 = arith.constant 2 : u32; v30 = hir.bitcast v17 : u32; - v32 = arith.shr v30, v299 : u32; + v32 = arith.shr v30, v300 : u32; v33 = hir.bitcast v32 : i32; - hir.exec @root_ns:root@1.0.0/hash_words/std::crypto::hashes::rpo::hash_memory(v33, v36, v38) - v40 = arith.constant 24 : u32; - v39 = hir.bitcast v8 : u32; - v41 = arith.add v39, v40 : u32 #[overflow = checked]; + v38 = arith.constant 16 : i32; + v39 = arith.add v8, v38 : i32 #[overflow = wrapping]; + v308 = arith.constant 2 : u32; + v36 = arith.shl v24, v308 : i32; + v37 = arith.add v33, v36 : i32 #[overflow = wrapping]; + hir.exec @root_ns:root@1.0.0/hash_words/std::crypto::hashes::rpo::hash_memory_words(v33, v37, v39) + v41 = arith.constant 24 : u32; + v40 = hir.bitcast v8 : u32; + v42 = arith.add v40, v41 : u32 #[overflow = checked]; + v307 = arith.constant 8 : u32; + v44 = arith.mod v42, v307 : u32; + hir.assertz v44 #[code = 250]; + v45 = hir.int_to_ptr v42 : ptr; + v46 = hir.load v45 : i64; + v48 = arith.constant 40 : u32; + v47 = hir.bitcast v8 : u32; + v49 = arith.add v47, v48 : u32 #[overflow = checked]; v306 = arith.constant 8 : u32; - v43 = arith.mod v41, v306 : u32; - hir.assertz v43 #[code = 250]; - v44 = hir.int_to_ptr v41 : ptr; - v45 = hir.load v44 : i64; - v47 = arith.constant 40 : u32; - v46 = hir.bitcast v8 : u32; - v48 = arith.add v46, v47 : u32 #[overflow = checked]; + v51 = arith.mod v49, v306 : u32; + hir.assertz v51 #[code = 250]; + v52 = hir.int_to_ptr v49 : ptr; + hir.store v52, v46; + v54 = arith.constant 16 : u32; + v53 = hir.bitcast v8 : u32; + v55 = arith.add v53, v54 : u32 #[overflow = checked]; v305 = arith.constant 8 : u32; - v50 = arith.mod v48, v305 : u32; - hir.assertz v50 #[code = 250]; - v51 = hir.int_to_ptr v48 : ptr; - hir.store v51, v45; - v53 = arith.constant 16 : u32; - v52 = hir.bitcast v8 : u32; - v54 = arith.add v52, v53 : u32 #[overflow = checked]; + v57 = arith.mod v55, v305 : u32; + hir.assertz v57 #[code = 250]; + v58 = hir.int_to_ptr v55 : ptr; + v59 = hir.load v58 : i64; + v61 = arith.constant 32 : u32; + v60 = hir.bitcast v8 : u32; + v62 = arith.add v60, v61 : u32 #[overflow = checked]; v304 = arith.constant 8 : u32; - v56 = arith.mod v54, v304 : u32; - hir.assertz v56 #[code = 250]; - v57 = hir.int_to_ptr v54 : ptr; - v58 = hir.load v57 : i64; - v60 = arith.constant 32 : u32; - v59 = hir.bitcast v8 : u32; - v61 = arith.add v59, v60 : u32 #[overflow = checked]; - v303 = arith.constant 8 : u32; - v63 = arith.mod v61, v303 : u32; - hir.assertz v63 #[code = 250]; - v64 = hir.int_to_ptr v61 : ptr; - hir.store v64, v58; - v65 = arith.constant 32 : i32; - v66 = arith.add v8, v65 : i32 #[overflow = wrapping]; - hir.exec @root_ns:root@1.0.0/hash_words/miden_stdlib_sys::intrinsics::word::Word::reverse(v8, v66) - v67 = hir.bitcast v8 : u32; - v302 = arith.constant 4 : u32; - v69 = arith.mod v67, v302 : u32; - hir.assertz v69 #[code = 250]; - v70 = hir.int_to_ptr v67 : ptr; - v71 = hir.load v70 : felt; - v301 = arith.constant 16 : i32; - hir.exec @root_ns:root@1.0.0/hash_words/alloc::raw_vec::RawVecInner::deallocate(v0, v301, v301) - v300 = arith.constant 48 : i32; - v75 = arith.add v8, v300 : i32 #[overflow = wrapping]; - v76 = builtin.global_symbol @root_ns:root@1.0.0/hash_words/__stack_pointer : ptr - v77 = hir.bitcast v76 : ptr; - hir.store v77, v75; - builtin.ret v71; + v64 = arith.mod v62, v304 : u32; + hir.assertz v64 #[code = 250]; + v65 = hir.int_to_ptr v62 : ptr; + hir.store v65, v59; + v66 = arith.constant 32 : i32; + v67 = arith.add v8, v66 : i32 #[overflow = wrapping]; + hir.exec @root_ns:root@1.0.0/hash_words/miden_stdlib_sys::intrinsics::word::Word::reverse(v8, v67) + v68 = hir.bitcast v8 : u32; + v303 = arith.constant 4 : u32; + v70 = arith.mod v68, v303 : u32; + hir.assertz v70 #[code = 250]; + v71 = hir.int_to_ptr v68 : ptr; + v72 = hir.load v71 : felt; + v302 = arith.constant 16 : i32; + hir.exec @root_ns:root@1.0.0/hash_words/alloc::raw_vec::RawVecInner::deallocate(v0, v302, v302) + v301 = arith.constant 48 : i32; + v76 = arith.add v8, v301 : i32 #[overflow = wrapping]; + v77 = builtin.global_symbol @root_ns:root@1.0.0/hash_words/__stack_pointer : ptr + v78 = hir.bitcast v77 : ptr; + hir.store v78, v76; + builtin.ret v72; }; - private builtin.function @__rustc::__rust_dealloc(v78: i32, v79: i32, v80: i32) { - ^block6(v78: i32, v79: i32, v80: i32): + private builtin.function @__rustc::__rust_dealloc(v79: i32, v80: i32, v81: i32) { + ^block6(v79: i32, v80: i32, v81: i32): builtin.ret ; }; - private builtin.function @miden_stdlib_sys::intrinsics::word::Word::reverse(v81: i32, v82: i32) { - ^block8(v81: i32, v82: i32): - v85 = builtin.global_symbol @root_ns:root@1.0.0/hash_words/__stack_pointer : ptr - v86 = hir.bitcast v85 : ptr; - v87 = hir.load v86 : i32; - v88 = arith.constant 16 : i32; - v89 = arith.sub v87, v88 : i32 #[overflow = wrapping]; - v91 = arith.constant 8 : u32; - v90 = hir.bitcast v82 : u32; - v92 = arith.add v90, v91 : u32 #[overflow = checked]; + private builtin.function @miden_stdlib_sys::intrinsics::word::Word::reverse(v82: i32, v83: i32) { + ^block8(v82: i32, v83: i32): + v86 = builtin.global_symbol @root_ns:root@1.0.0/hash_words/__stack_pointer : ptr + v87 = hir.bitcast v86 : ptr; + v88 = hir.load v87 : i32; + v89 = arith.constant 16 : i32; + v90 = arith.sub v88, v89 : i32 #[overflow = wrapping]; + v92 = arith.constant 8 : u32; + v91 = hir.bitcast v83 : u32; + v93 = arith.add v91, v92 : u32 #[overflow = checked]; + v398 = arith.constant 8 : u32; + v95 = arith.mod v93, v398 : u32; + hir.assertz v95 #[code = 250]; + v96 = hir.int_to_ptr v93 : ptr; + v97 = hir.load v96 : i64; v397 = arith.constant 8 : u32; - v94 = arith.mod v92, v397 : u32; - hir.assertz v94 #[code = 250]; - v95 = hir.int_to_ptr v92 : ptr; - v96 = hir.load v95 : i64; + v98 = hir.bitcast v90 : u32; + v100 = arith.add v98, v397 : u32 #[overflow = checked]; + v101 = arith.constant 4 : u32; + v102 = arith.mod v100, v101 : u32; + hir.assertz v102 #[code = 250]; + v103 = hir.int_to_ptr v100 : ptr; + hir.store v103, v97; + v104 = hir.bitcast v83 : u32; v396 = arith.constant 8 : u32; - v97 = hir.bitcast v89 : u32; - v99 = arith.add v97, v396 : u32 #[overflow = checked]; - v100 = arith.constant 4 : u32; - v101 = arith.mod v99, v100 : u32; - hir.assertz v101 #[code = 250]; - v102 = hir.int_to_ptr v99 : ptr; - hir.store v102, v96; - v103 = hir.bitcast v82 : u32; - v395 = arith.constant 8 : u32; - v105 = arith.mod v103, v395 : u32; - hir.assertz v105 #[code = 250]; - v106 = hir.int_to_ptr v103 : ptr; - v107 = hir.load v106 : i64; - v108 = hir.bitcast v89 : u32; - v394 = arith.constant 4 : u32; - v110 = arith.mod v108, v394 : u32; - hir.assertz v110 #[code = 250]; - v111 = hir.int_to_ptr v108 : ptr; - hir.store v111, v107; - v112 = arith.constant 12 : i32; - v113 = arith.add v89, v112 : i32 #[overflow = wrapping]; - v83 = arith.constant 0 : i32; - v365, v366, v367, v368, v369, v370 = scf.while v83, v89, v113, v81 : i32, i32, i32, i32, i32, i32 { - ^block44(v371: i32, v372: i32, v373: i32, v374: i32): - v393 = arith.constant 0 : i32; - v116 = arith.constant 8 : i32; - v117 = arith.eq v371, v116 : i1; - v118 = arith.zext v117 : u32; - v119 = hir.bitcast v118 : i32; - v121 = arith.neq v119, v393 : i1; - v359, v360 = scf.if v121 : i32, i32 { + v106 = arith.mod v104, v396 : u32; + hir.assertz v106 #[code = 250]; + v107 = hir.int_to_ptr v104 : ptr; + v108 = hir.load v107 : i64; + v109 = hir.bitcast v90 : u32; + v395 = arith.constant 4 : u32; + v111 = arith.mod v109, v395 : u32; + hir.assertz v111 #[code = 250]; + v112 = hir.int_to_ptr v109 : ptr; + hir.store v112, v108; + v113 = arith.constant 12 : i32; + v114 = arith.add v90, v113 : i32 #[overflow = wrapping]; + v84 = arith.constant 0 : i32; + v366, v367, v368, v369, v370, v371 = scf.while v84, v90, v114, v82 : i32, i32, i32, i32, i32, i32 { + ^block44(v372: i32, v373: i32, v374: i32, v375: i32): + v394 = arith.constant 0 : i32; + v117 = arith.constant 8 : i32; + v118 = arith.eq v372, v117 : i1; + v119 = arith.zext v118 : u32; + v120 = hir.bitcast v119 : i32; + v122 = arith.neq v120, v394 : i1; + v360, v361 = scf.if v122 : i32, i32 { ^block43: - v319 = ub.poison i32 : i32; - scf.yield v319, v319; + v320 = ub.poison i32 : i32; + scf.yield v320, v320; } else { ^block13: - v123 = arith.add v372, v371 : i32 #[overflow = wrapping]; - v124 = hir.bitcast v123 : u32; + v124 = arith.add v373, v372 : i32 #[overflow = wrapping]; + v125 = hir.bitcast v124 : u32; + v393 = arith.constant 4 : u32; + v127 = arith.mod v125, v393 : u32; + hir.assertz v127 #[code = 250]; + v128 = hir.int_to_ptr v125 : ptr; + v129 = hir.load v128 : felt; + v131 = hir.bitcast v374 : u32; v392 = arith.constant 4 : u32; - v126 = arith.mod v124, v392 : u32; - hir.assertz v126 #[code = 250]; - v127 = hir.int_to_ptr v124 : ptr; - v128 = hir.load v127 : felt; - v130 = hir.bitcast v373 : u32; + v133 = arith.mod v131, v392 : u32; + hir.assertz v133 #[code = 250]; + v134 = hir.int_to_ptr v131 : ptr; + v135 = hir.load v134 : i32; + v136 = hir.bitcast v124 : u32; v391 = arith.constant 4 : u32; - v132 = arith.mod v130, v391 : u32; - hir.assertz v132 #[code = 250]; - v133 = hir.int_to_ptr v130 : ptr; - v134 = hir.load v133 : i32; - v135 = hir.bitcast v123 : u32; + v138 = arith.mod v136, v391 : u32; + hir.assertz v138 #[code = 250]; + v139 = hir.int_to_ptr v136 : ptr; + hir.store v139, v135; + v140 = hir.bitcast v374 : u32; v390 = arith.constant 4 : u32; - v137 = arith.mod v135, v390 : u32; - hir.assertz v137 #[code = 250]; - v138 = hir.int_to_ptr v135 : ptr; - hir.store v138, v134; - v139 = hir.bitcast v373 : u32; - v389 = arith.constant 4 : u32; - v141 = arith.mod v139, v389 : u32; - hir.assertz v141 #[code = 250]; - v142 = hir.int_to_ptr v139 : ptr; - hir.store v142, v128; - v145 = arith.constant -4 : i32; - v146 = arith.add v373, v145 : i32 #[overflow = wrapping]; - v143 = arith.constant 4 : i32; - v144 = arith.add v371, v143 : i32 #[overflow = wrapping]; - scf.yield v144, v146; + v142 = arith.mod v140, v390 : u32; + hir.assertz v142 #[code = 250]; + v143 = hir.int_to_ptr v140 : ptr; + hir.store v143, v129; + v146 = arith.constant -4 : i32; + v147 = arith.add v374, v146 : i32 #[overflow = wrapping]; + v144 = arith.constant 4 : i32; + v145 = arith.add v372, v144 : i32 #[overflow = wrapping]; + scf.yield v145, v147; }; - v387 = ub.poison i32 : i32; - v362 = cf.select v121, v387, v374 : i32; v388 = ub.poison i32 : i32; - v361 = cf.select v121, v388, v372 : i32; - v318 = arith.constant 1 : u32; - v311 = arith.constant 0 : u32; - v364 = cf.select v121, v311, v318 : u32; - v352 = arith.trunc v364 : i1; - scf.condition v352, v359, v361, v360, v362, v372, v374; + v363 = cf.select v122, v388, v375 : i32; + v389 = ub.poison i32 : i32; + v362 = cf.select v122, v389, v373 : i32; + v319 = arith.constant 1 : u32; + v312 = arith.constant 0 : u32; + v365 = cf.select v122, v312, v319 : u32; + v353 = arith.trunc v365 : i1; + scf.condition v353, v360, v362, v361, v363, v373, v375; } do { - ^block45(v375: i32, v376: i32, v377: i32, v378: i32, v379: i32, v380: i32): - scf.yield v375, v376, v377, v378; + ^block45(v376: i32, v377: i32, v378: i32, v379: i32, v380: i32, v381: i32): + scf.yield v376, v377, v378, v379; }; - v386 = arith.constant 8 : u32; - v148 = hir.bitcast v369 : u32; - v150 = arith.add v148, v386 : u32 #[overflow = checked]; - v385 = arith.constant 4 : u32; - v152 = arith.mod v150, v385 : u32; - hir.assertz v152 #[code = 250]; - v153 = hir.int_to_ptr v150 : ptr; - v154 = hir.load v153 : i64; + v387 = arith.constant 8 : u32; + v149 = hir.bitcast v370 : u32; + v151 = arith.add v149, v387 : u32 #[overflow = checked]; + v386 = arith.constant 4 : u32; + v153 = arith.mod v151, v386 : u32; + hir.assertz v153 #[code = 250]; + v154 = hir.int_to_ptr v151 : ptr; + v155 = hir.load v154 : i64; + v385 = arith.constant 8 : u32; + v156 = hir.bitcast v371 : u32; + v158 = arith.add v156, v385 : u32 #[overflow = checked]; v384 = arith.constant 8 : u32; - v155 = hir.bitcast v370 : u32; - v157 = arith.add v155, v384 : u32 #[overflow = checked]; - v383 = arith.constant 8 : u32; - v159 = arith.mod v157, v383 : u32; - hir.assertz v159 #[code = 250]; - v160 = hir.int_to_ptr v157 : ptr; - hir.store v160, v154; - v161 = hir.bitcast v369 : u32; - v382 = arith.constant 4 : u32; - v163 = arith.mod v161, v382 : u32; - hir.assertz v163 #[code = 250]; - v164 = hir.int_to_ptr v161 : ptr; - v165 = hir.load v164 : i64; - v166 = hir.bitcast v370 : u32; - v381 = arith.constant 8 : u32; - v168 = arith.mod v166, v381 : u32; - hir.assertz v168 #[code = 250]; - v169 = hir.int_to_ptr v166 : ptr; - hir.store v169, v165; + v160 = arith.mod v158, v384 : u32; + hir.assertz v160 #[code = 250]; + v161 = hir.int_to_ptr v158 : ptr; + hir.store v161, v155; + v162 = hir.bitcast v370 : u32; + v383 = arith.constant 4 : u32; + v164 = arith.mod v162, v383 : u32; + hir.assertz v164 #[code = 250]; + v165 = hir.int_to_ptr v162 : ptr; + v166 = hir.load v165 : i64; + v167 = hir.bitcast v371 : u32; + v382 = arith.constant 8 : u32; + v169 = arith.mod v167, v382 : u32; + hir.assertz v169 #[code = 250]; + v170 = hir.int_to_ptr v167 : ptr; + hir.store v170, v166; builtin.ret ; }; - private builtin.function @intrinsics::felt::from_u32(v170: i32) -> felt { - ^block14(v170: i32): - v171 = hir.bitcast v170 : felt; - builtin.ret v171; + private builtin.function @intrinsics::felt::from_u32(v171: i32) -> felt { + ^block14(v171: i32): + v172 = hir.bitcast v171 : felt; + builtin.ret v172; }; - private builtin.function @intrinsics::felt::assert_eq(v173: felt, v174: felt) { - ^block16(v173: felt, v174: felt): - hir.assert_eq v173, v174; + private builtin.function @intrinsics::felt::assert_eq(v174: felt, v175: felt) { + ^block16(v174: felt, v175: felt): + hir.assert_eq v174, v175; builtin.ret ; }; - private builtin.function @std::crypto::hashes::rpo::hash_memory(v175: i32, v176: i32, v177: i32) { - ^block18(v175: i32, v176: i32, v177: i32): - v178, v179, v180, v181 = hir.exec @std/crypto/hashes/rpo/hash_memory(v175, v176) : felt, felt, felt, felt - v182 = hir.bitcast v177 : u32; - v183 = hir.int_to_ptr v182 : ptr; - hir.store v183, v178; - v184 = arith.constant 4 : u32; - v185 = arith.add v182, v184 : u32 #[overflow = checked]; - v186 = hir.int_to_ptr v185 : ptr; - hir.store v186, v179; - v187 = arith.constant 8 : u32; - v188 = arith.add v182, v187 : u32 #[overflow = checked]; - v189 = hir.int_to_ptr v188 : ptr; - hir.store v189, v180; - v190 = arith.constant 12 : u32; - v191 = arith.add v182, v190 : u32 #[overflow = checked]; - v192 = hir.int_to_ptr v191 : ptr; - hir.store v192, v181; + private builtin.function @std::crypto::hashes::rpo::hash_memory_words(v176: i32, v177: i32, v178: i32) { + ^block18(v176: i32, v177: i32, v178: i32): + v179, v180, v181, v182 = hir.exec @std/crypto/hashes/rpo/hash_memory_words(v176, v177) : felt, felt, felt, felt + v183 = hir.bitcast v178 : u32; + v184 = hir.int_to_ptr v183 : ptr; + hir.store v184, v179; + v185 = arith.constant 4 : u32; + v186 = arith.add v183, v185 : u32 #[overflow = checked]; + v187 = hir.int_to_ptr v186 : ptr; + hir.store v187, v180; + v188 = arith.constant 8 : u32; + v189 = arith.add v183, v188 : u32 #[overflow = checked]; + v190 = hir.int_to_ptr v189 : ptr; + hir.store v190, v181; + v191 = arith.constant 12 : u32; + v192 = arith.add v183, v191 : u32 #[overflow = checked]; + v193 = hir.int_to_ptr v192 : ptr; + hir.store v193, v182; builtin.ret ; }; - private builtin.function @alloc::raw_vec::RawVecInner::deallocate(v193: i32, v194: i32, v195: i32) { - ^block24(v193: i32, v194: i32, v195: i32): - v197 = builtin.global_symbol @root_ns:root@1.0.0/hash_words/__stack_pointer : ptr - v198 = hir.bitcast v197 : ptr; - v199 = hir.load v198 : i32; - v200 = arith.constant 16 : i32; - v201 = arith.sub v199, v200 : i32 #[overflow = wrapping]; - v202 = builtin.global_symbol @root_ns:root@1.0.0/hash_words/__stack_pointer : ptr - v203 = hir.bitcast v202 : ptr; - hir.store v203, v201; - v204 = arith.constant 4 : i32; - v205 = arith.add v201, v204 : i32 #[overflow = wrapping]; - hir.exec @root_ns:root@1.0.0/hash_words/alloc::raw_vec::RawVecInner::current_memory(v205, v193, v194, v195) - v207 = arith.constant 8 : u32; - v206 = hir.bitcast v201 : u32; - v208 = arith.add v206, v207 : u32 #[overflow = checked]; - v209 = arith.constant 4 : u32; - v210 = arith.mod v208, v209 : u32; - hir.assertz v210 #[code = 250]; - v211 = hir.int_to_ptr v208 : ptr; - v212 = hir.load v211 : i32; - v404 = arith.constant 0 : i32; - v196 = arith.constant 0 : i32; - v214 = arith.eq v212, v196 : i1; - v215 = arith.zext v214 : u32; - v216 = hir.bitcast v215 : i32; - v218 = arith.neq v216, v404 : i1; - scf.if v218{ + private builtin.function @alloc::raw_vec::RawVecInner::deallocate(v194: i32, v195: i32, v196: i32) { + ^block24(v194: i32, v195: i32, v196: i32): + v198 = builtin.global_symbol @root_ns:root@1.0.0/hash_words/__stack_pointer : ptr + v199 = hir.bitcast v198 : ptr; + v200 = hir.load v199 : i32; + v201 = arith.constant 16 : i32; + v202 = arith.sub v200, v201 : i32 #[overflow = wrapping]; + v203 = builtin.global_symbol @root_ns:root@1.0.0/hash_words/__stack_pointer : ptr + v204 = hir.bitcast v203 : ptr; + hir.store v204, v202; + v205 = arith.constant 4 : i32; + v206 = arith.add v202, v205 : i32 #[overflow = wrapping]; + hir.exec @root_ns:root@1.0.0/hash_words/alloc::raw_vec::RawVecInner::current_memory(v206, v194, v195, v196) + v208 = arith.constant 8 : u32; + v207 = hir.bitcast v202 : u32; + v209 = arith.add v207, v208 : u32 #[overflow = checked]; + v210 = arith.constant 4 : u32; + v211 = arith.mod v209, v210 : u32; + hir.assertz v211 #[code = 250]; + v212 = hir.int_to_ptr v209 : ptr; + v213 = hir.load v212 : i32; + v405 = arith.constant 0 : i32; + v197 = arith.constant 0 : i32; + v215 = arith.eq v213, v197 : i1; + v216 = arith.zext v215 : u32; + v217 = hir.bitcast v216 : i32; + v219 = arith.neq v217, v405 : i1; + scf.if v219{ ^block46: scf.yield ; } else { ^block27: + v404 = arith.constant 4 : u32; + v220 = hir.bitcast v202 : u32; + v222 = arith.add v220, v404 : u32 #[overflow = checked]; v403 = arith.constant 4 : u32; - v219 = hir.bitcast v201 : u32; - v221 = arith.add v219, v403 : u32 #[overflow = checked]; + v224 = arith.mod v222, v403 : u32; + hir.assertz v224 #[code = 250]; + v225 = hir.int_to_ptr v222 : ptr; + v226 = hir.load v225 : i32; + v228 = arith.constant 12 : u32; + v227 = hir.bitcast v202 : u32; + v229 = arith.add v227, v228 : u32 #[overflow = checked]; v402 = arith.constant 4 : u32; - v223 = arith.mod v221, v402 : u32; - hir.assertz v223 #[code = 250]; - v224 = hir.int_to_ptr v221 : ptr; - v225 = hir.load v224 : i32; - v227 = arith.constant 12 : u32; - v226 = hir.bitcast v201 : u32; - v228 = arith.add v226, v227 : u32 #[overflow = checked]; - v401 = arith.constant 4 : u32; - v230 = arith.mod v228, v401 : u32; - hir.assertz v230 #[code = 250]; - v231 = hir.int_to_ptr v228 : ptr; - v232 = hir.load v231 : i32; - hir.exec @root_ns:root@1.0.0/hash_words/::deallocate(v225, v212, v232) + v231 = arith.mod v229, v402 : u32; + hir.assertz v231 #[code = 250]; + v232 = hir.int_to_ptr v229 : ptr; + v233 = hir.load v232 : i32; + hir.exec @root_ns:root@1.0.0/hash_words/::deallocate(v226, v213, v233) scf.yield ; }; - v400 = arith.constant 16 : i32; - v235 = arith.add v201, v400 : i32 #[overflow = wrapping]; - v236 = builtin.global_symbol @root_ns:root@1.0.0/hash_words/__stack_pointer : ptr - v237 = hir.bitcast v236 : ptr; - hir.store v237, v235; + v401 = arith.constant 16 : i32; + v236 = arith.add v202, v401 : i32 #[overflow = wrapping]; + v237 = builtin.global_symbol @root_ns:root@1.0.0/hash_words/__stack_pointer : ptr + v238 = hir.bitcast v237 : ptr; + hir.store v238, v236; builtin.ret ; }; - private builtin.function @alloc::raw_vec::RawVecInner::current_memory(v238: i32, v239: i32, v240: i32, v241: i32) { - ^block28(v238: i32, v239: i32, v240: i32, v241: i32): - v430 = arith.constant 0 : i32; - v242 = arith.constant 0 : i32; - v246 = arith.eq v241, v242 : i1; - v247 = arith.zext v246 : u32; - v248 = hir.bitcast v247 : i32; - v250 = arith.neq v248, v430 : i1; - v417, v418 = scf.if v250 : i32, i32 { + private builtin.function @alloc::raw_vec::RawVecInner::current_memory(v239: i32, v240: i32, v241: i32, v242: i32) { + ^block28(v239: i32, v240: i32, v241: i32, v242: i32): + v431 = arith.constant 0 : i32; + v243 = arith.constant 0 : i32; + v247 = arith.eq v242, v243 : i1; + v248 = arith.zext v247 : u32; + v249 = hir.bitcast v248 : i32; + v251 = arith.neq v249, v431 : i1; + v418, v419 = scf.if v251 : i32, i32 { ^block49: - v429 = arith.constant 0 : i32; - v244 = arith.constant 4 : i32; - scf.yield v244, v429; + v430 = arith.constant 0 : i32; + v245 = arith.constant 4 : i32; + scf.yield v245, v430; } else { ^block31: - v251 = hir.bitcast v239 : u32; - v286 = arith.constant 4 : u32; - v253 = arith.mod v251, v286 : u32; - hir.assertz v253 #[code = 250]; - v254 = hir.int_to_ptr v251 : ptr; - v255 = hir.load v254 : i32; - v427 = arith.constant 0 : i32; + v252 = hir.bitcast v240 : u32; + v287 = arith.constant 4 : u32; + v254 = arith.mod v252, v287 : u32; + hir.assertz v254 #[code = 250]; + v255 = hir.int_to_ptr v252 : ptr; + v256 = hir.load v255 : i32; v428 = arith.constant 0 : i32; - v257 = arith.eq v255, v428 : i1; - v258 = arith.zext v257 : u32; - v259 = hir.bitcast v258 : i32; - v261 = arith.neq v259, v427 : i1; - v415 = scf.if v261 : i32 { + v429 = arith.constant 0 : i32; + v258 = arith.eq v256, v429 : i1; + v259 = arith.zext v258 : u32; + v260 = hir.bitcast v259 : i32; + v262 = arith.neq v260, v428 : i1; + v416 = scf.if v262 : i32 { ^block48: - v426 = arith.constant 0 : i32; - scf.yield v426; + v427 = arith.constant 0 : i32; + scf.yield v427; } else { ^block32: + v426 = arith.constant 4 : u32; + v263 = hir.bitcast v239 : u32; + v265 = arith.add v263, v426 : u32 #[overflow = checked]; v425 = arith.constant 4 : u32; - v262 = hir.bitcast v238 : u32; - v264 = arith.add v262, v425 : u32 #[overflow = checked]; + v267 = arith.mod v265, v425 : u32; + hir.assertz v267 #[code = 250]; + v268 = hir.int_to_ptr v265 : ptr; + hir.store v268, v241; v424 = arith.constant 4 : u32; - v266 = arith.mod v264, v424 : u32; - hir.assertz v266 #[code = 250]; - v267 = hir.int_to_ptr v264 : ptr; - hir.store v267, v240; + v269 = hir.bitcast v240 : u32; + v271 = arith.add v269, v424 : u32 #[overflow = checked]; v423 = arith.constant 4 : u32; - v268 = hir.bitcast v239 : u32; - v270 = arith.add v268, v423 : u32 #[overflow = checked]; + v273 = arith.mod v271, v423 : u32; + hir.assertz v273 #[code = 250]; + v274 = hir.int_to_ptr v271 : ptr; + v275 = hir.load v274 : i32; + v276 = hir.bitcast v239 : u32; v422 = arith.constant 4 : u32; - v272 = arith.mod v270, v422 : u32; - hir.assertz v272 #[code = 250]; - v273 = hir.int_to_ptr v270 : ptr; - v274 = hir.load v273 : i32; - v275 = hir.bitcast v238 : u32; - v421 = arith.constant 4 : u32; - v277 = arith.mod v275, v421 : u32; - hir.assertz v277 #[code = 250]; - v278 = hir.int_to_ptr v275 : ptr; - hir.store v278, v274; - v279 = arith.mul v255, v241 : i32 #[overflow = wrapping]; - scf.yield v279; + v278 = arith.mod v276, v422 : u32; + hir.assertz v278 #[code = 250]; + v279 = hir.int_to_ptr v276 : ptr; + hir.store v279, v275; + v280 = arith.mul v256, v242 : i32 #[overflow = wrapping]; + scf.yield v280; }; - v280 = arith.constant 8 : i32; - v420 = arith.constant 4 : i32; - v416 = cf.select v261, v420, v280 : i32; - scf.yield v416, v415; + v281 = arith.constant 8 : i32; + v421 = arith.constant 4 : i32; + v417 = cf.select v262, v421, v281 : i32; + scf.yield v417, v416; }; - v283 = arith.add v238, v417 : i32 #[overflow = wrapping]; - v285 = hir.bitcast v283 : u32; - v419 = arith.constant 4 : u32; - v287 = arith.mod v285, v419 : u32; - hir.assertz v287 #[code = 250]; - v288 = hir.int_to_ptr v285 : ptr; - hir.store v288, v418; + v284 = arith.add v239, v418 : i32 #[overflow = wrapping]; + v286 = hir.bitcast v284 : u32; + v420 = arith.constant 4 : u32; + v288 = arith.mod v286, v420 : u32; + hir.assertz v288 #[code = 250]; + v289 = hir.int_to_ptr v286 : ptr; + hir.store v289, v419; builtin.ret ; }; - private builtin.function @::deallocate(v289: i32, v290: i32, v291: i32) { - ^block33(v289: i32, v290: i32, v291: i32): - v432 = arith.constant 0 : i32; - v292 = arith.constant 0 : i32; - v293 = arith.eq v291, v292 : i1; - v294 = arith.zext v293 : u32; - v295 = hir.bitcast v294 : i32; - v297 = arith.neq v295, v432 : i1; - scf.if v297{ + private builtin.function @::deallocate(v290: i32, v291: i32, v292: i32) { + ^block33(v290: i32, v291: i32, v292: i32): + v433 = arith.constant 0 : i32; + v293 = arith.constant 0 : i32; + v294 = arith.eq v292, v293 : i1; + v295 = arith.zext v294 : u32; + v296 = hir.bitcast v295 : i32; + v298 = arith.neq v296, v433 : i1; + scf.if v298{ ^block35: scf.yield ; } else { ^block36: - hir.exec @root_ns:root@1.0.0/hash_words/__rustc::__rust_dealloc(v289, v291, v290) + hir.exec @root_ns:root@1.0.0/hash_words/__rustc::__rust_dealloc(v290, v292, v291) scf.yield ; }; builtin.ret ; diff --git a/tests/integration/expected/hash_words.masm b/tests/integration/expected/hash_words.masm index 532c262f9..45cd58bcc 100644 --- a/tests/integration/expected/hash_words.masm +++ b/tests/integration/expected/hash_words.masm @@ -85,20 +85,23 @@ export.entrypoint exec.::root_ns:root@1.0.0::hash_words::intrinsics::felt::assert_eq trace.252 nop - push.16 - dup.3 - u32wrapping_add push.2 movup.2 swap.1 - u32shl + u32shr + push.16 + dup.3 + u32wrapping_add push.2 movup.3 swap.1 - u32shr + u32shl + dup.2 + u32wrapping_add + movup.2 trace.240 nop - exec.::root_ns:root@1.0.0::hash_words::std::crypto::hashes::rpo::hash_memory + exec.::root_ns:root@1.0.0::hash_words::std::crypto::hashes::rpo::hash_memory_words trace.252 nop push.24 @@ -488,10 +491,10 @@ proc.intrinsics::felt::assert_eq assert_eq end -proc.std::crypto::hashes::rpo::hash_memory +proc.std::crypto::hashes::rpo::hash_memory_words trace.240 nop - exec.::std::crypto::hashes::rpo::hash_memory + exec.::std::crypto::hashes::rpo::hash_memory_words trace.252 nop movup.4 diff --git a/tests/integration/expected/hash_words.wat b/tests/integration/expected/hash_words.wat index 815c251c7..f4b411bf3 100644 --- a/tests/integration/expected/hash_words.wat +++ b/tests/integration/expected/hash_words.wat @@ -30,13 +30,16 @@ local.get 2 i32.const 2 i32.shr_u + local.tee 2 + local.get 2 local.get 3 i32.const 2 i32.shl + i32.add local.get 1 i32.const 16 i32.add - call $std::crypto::hashes::rpo::hash_memory + call $std::crypto::hashes::rpo::hash_memory_words local.get 1 local.get 1 i64.load offset=24 @@ -128,7 +131,7 @@ (func $intrinsics::felt::assert_eq (;4;) (type 3) (param f32 f32) unreachable ) - (func $std::crypto::hashes::rpo::hash_memory (;5;) (type 1) (param i32 i32 i32) + (func $std::crypto::hashes::rpo::hash_memory_words (;5;) (type 1) (param i32 i32 i32) unreachable ) (func $alloc::raw_vec::RawVecInner::deallocate (;6;) (type 1) (param i32 i32 i32) From 2e907780105c1694974a23ca1d71e68e2b0d0571 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 28 Oct 2025 14:45:38 +0200 Subject: [PATCH 2/2] refactor: route `hash_elements` to call `hash_memory_words` when the input length is a multiple of 4 --- sdk/stdlib-sys/src/stdlib/crypto/hashes.rs | 14 +- tests/integration/expected/hash_elements.hir | 738 +++++++++--------- tests/integration/expected/hash_elements.masm | 131 +++- tests/integration/expected/hash_elements.wat | 51 +- 4 files changed, 542 insertions(+), 392 deletions(-) diff --git a/sdk/stdlib-sys/src/stdlib/crypto/hashes.rs b/sdk/stdlib-sys/src/stdlib/crypto/hashes.rs index 2b7d3017f..40c94578b 100644 --- a/sdk/stdlib-sys/src/stdlib/crypto/hashes.rs +++ b/sdk/stdlib-sys/src/stdlib/crypto/hashes.rs @@ -208,13 +208,17 @@ pub fn sha256_hash_2to1(input: [u8; 64]) -> [u8; 32] { /// Computes the hash of a sequence of field elements using the Rescue Prime Optimized (RPO) /// hash function. /// -/// This maps to the `std::crypto::rpo::hash_memory` procedure in the Miden stdlib. +/// This maps to the `std::crypto::rpo::hash_memory` procedure in the Miden stdlib and to the +/// `std::crypto::hashes::rpo::hash_memory_words` word-optimized variant when the input length is a +/// multiple of 4. /// /// # Arguments /// * `elements` - A Vec of field elements to be hashed #[inline] pub fn hash_elements(elements: Vec) -> Digest { let rust_ptr = elements.as_ptr().addr() as u32; + let element_count = elements.len(); + let num_elements = element_count as u32; unsafe { let mut ret_area = core::mem::MaybeUninit::::uninit(); @@ -223,7 +227,13 @@ pub fn hash_elements(elements: Vec) -> Digest { // Since our BumpAlloc produces word-aligned allocations the pointer should be word-aligned assert_eq(Felt::from_u32(miden_ptr % 4), felt!(0)); - extern_hash_memory(miden_ptr, elements.len() as u32, result_ptr); + if element_count.is_multiple_of(4) { + let start_addr = miden_ptr; + let end_addr = start_addr + num_elements; + extern_hash_memory_words(start_addr, end_addr, result_ptr); + } else { + extern_hash_memory(miden_ptr, num_elements, result_ptr); + } Digest::from_word(ret_area.assume_init().reverse()) } diff --git a/tests/integration/expected/hash_elements.hir b/tests/integration/expected/hash_elements.hir index 4f09ca927..d9bb0af50 100644 --- a/tests/integration/expected/hash_elements.hir +++ b/tests/integration/expected/hash_elements.hir @@ -10,397 +10,437 @@ builtin.component root_ns:root@1.0.0 { v9 = builtin.global_symbol @root_ns:root@1.0.0/hash_elements/__stack_pointer : ptr v10 = hir.bitcast v9 : ptr; hir.store v10, v8; - v12 = arith.constant 4 : u32; + v12 = arith.constant 8 : u32; v11 = hir.bitcast v0 : u32; v13 = arith.add v11, v12 : u32 #[overflow = checked]; - v304 = arith.constant 4 : u32; - v15 = arith.mod v13, v304 : u32; + v14 = arith.constant 4 : u32; + v15 = arith.mod v13, v14 : u32; hir.assertz v15 #[code = 250]; v16 = hir.int_to_ptr v13 : ptr; v17 = hir.load v16 : i32; - v296 = arith.constant 2 : u32; - v19 = hir.bitcast v17 : u32; - v21 = arith.shr v19, v296 : u32; - v22 = hir.bitcast v21 : i32; - v23 = arith.constant 3 : i32; - v24 = arith.band v22, v23 : i32; - v25 = hir.exec @root_ns:root@1.0.0/hash_elements/intrinsics::felt::from_u32(v24) : felt + v343 = arith.constant 4 : u32; + v18 = hir.bitcast v0 : u32; + v20 = arith.add v18, v343 : u32 #[overflow = checked]; + v342 = arith.constant 4 : u32; + v22 = arith.mod v20, v342 : u32; + hir.assertz v22 #[code = 250]; + v23 = hir.int_to_ptr v20 : ptr; + v24 = hir.load v23 : i32; + v327 = arith.constant 2 : u32; + v26 = hir.bitcast v24 : u32; + v28 = arith.shr v26, v327 : u32; + v29 = hir.bitcast v28 : i32; + v30 = arith.constant 3 : i32; + v31 = arith.band v29, v30 : i32; + v32 = hir.exec @root_ns:root@1.0.0/hash_elements/intrinsics::felt::from_u32(v31) : felt v2 = arith.constant 0 : i32; - v27 = hir.exec @root_ns:root@1.0.0/hash_elements/intrinsics::felt::from_u32(v2) : felt - hir.exec @root_ns:root@1.0.0/hash_elements/intrinsics::felt::assert_eq(v25, v27) - v29 = arith.constant 8 : u32; - v28 = hir.bitcast v0 : u32; - v30 = arith.add v28, v29 : u32 #[overflow = checked]; - v303 = arith.constant 4 : u32; - v32 = arith.mod v30, v303 : u32; - hir.assertz v32 #[code = 250]; - v33 = hir.int_to_ptr v30 : ptr; - v34 = hir.load v33 : i32; - v35 = arith.constant 16 : i32; - v36 = arith.add v8, v35 : i32 #[overflow = wrapping]; - hir.exec @root_ns:root@1.0.0/hash_elements/std::crypto::hashes::rpo::hash_memory(v22, v34, v36) - v38 = arith.constant 24 : u32; - v37 = hir.bitcast v8 : u32; - v39 = arith.add v37, v38 : u32 #[overflow = checked]; - v302 = arith.constant 8 : u32; - v41 = arith.mod v39, v302 : u32; - hir.assertz v41 #[code = 250]; - v42 = hir.int_to_ptr v39 : ptr; - v43 = hir.load v42 : i64; - v45 = arith.constant 40 : u32; - v44 = hir.bitcast v8 : u32; - v46 = arith.add v44, v45 : u32 #[overflow = checked]; - v301 = arith.constant 8 : u32; - v48 = arith.mod v46, v301 : u32; - hir.assertz v48 #[code = 250]; - v49 = hir.int_to_ptr v46 : ptr; - hir.store v49, v43; - v51 = arith.constant 16 : u32; - v50 = hir.bitcast v8 : u32; - v52 = arith.add v50, v51 : u32 #[overflow = checked]; - v300 = arith.constant 8 : u32; - v54 = arith.mod v52, v300 : u32; - hir.assertz v54 #[code = 250]; - v55 = hir.int_to_ptr v52 : ptr; - v56 = hir.load v55 : i64; - v58 = arith.constant 32 : u32; - v57 = hir.bitcast v8 : u32; - v59 = arith.add v57, v58 : u32 #[overflow = checked]; - v299 = arith.constant 8 : u32; - v61 = arith.mod v59, v299 : u32; - hir.assertz v61 #[code = 250]; - v62 = hir.int_to_ptr v59 : ptr; - hir.store v62, v56; - v63 = arith.constant 32 : i32; - v64 = arith.add v8, v63 : i32 #[overflow = wrapping]; - hir.exec @root_ns:root@1.0.0/hash_elements/miden_stdlib_sys::intrinsics::word::Word::reverse(v8, v64) - v65 = arith.constant 4 : i32; - hir.exec @root_ns:root@1.0.0/hash_elements/alloc::raw_vec::RawVecInner::deallocate(v0, v65, v65) - v67 = hir.bitcast v8 : u32; - v298 = arith.constant 4 : u32; - v69 = arith.mod v67, v298 : u32; - hir.assertz v69 #[code = 250]; - v70 = hir.int_to_ptr v67 : ptr; - v71 = hir.load v70 : felt; - v297 = arith.constant 48 : i32; - v73 = arith.add v8, v297 : i32 #[overflow = wrapping]; - v74 = builtin.global_symbol @root_ns:root@1.0.0/hash_elements/__stack_pointer : ptr - v75 = hir.bitcast v74 : ptr; - hir.store v75, v73; - builtin.ret v71; + v34 = hir.exec @root_ns:root@1.0.0/hash_elements/intrinsics::felt::from_u32(v2) : felt + hir.exec @root_ns:root@1.0.0/hash_elements/intrinsics::felt::assert_eq(v32, v34) + v339 = arith.constant 0 : i32; + v340 = arith.constant 0 : i32; + v341 = arith.constant 3 : i32; + v36 = arith.band v17, v341 : i32; + v38 = arith.eq v36, v340 : i1; + v39 = arith.zext v38 : u32; + v40 = hir.bitcast v39 : i32; + v42 = arith.neq v40, v339 : i1; + scf.if v42{ + ^block7: + v46 = arith.constant 16 : i32; + v47 = arith.add v8, v46 : i32 #[overflow = wrapping]; + v45 = arith.add v29, v17 : i32 #[overflow = wrapping]; + hir.exec @root_ns:root@1.0.0/hash_elements/std::crypto::hashes::rpo::hash_memory_words(v29, v45, v47) + scf.yield ; + } else { + ^block8: + v338 = arith.constant 16 : i32; + v44 = arith.add v8, v338 : i32 #[overflow = wrapping]; + hir.exec @root_ns:root@1.0.0/hash_elements/std::crypto::hashes::rpo::hash_memory(v29, v17, v44) + scf.yield ; + }; + v50 = arith.constant 24 : u32; + v49 = hir.bitcast v8 : u32; + v51 = arith.add v49, v50 : u32 #[overflow = checked]; + v337 = arith.constant 8 : u32; + v53 = arith.mod v51, v337 : u32; + hir.assertz v53 #[code = 250]; + v54 = hir.int_to_ptr v51 : ptr; + v55 = hir.load v54 : i64; + v57 = arith.constant 40 : u32; + v56 = hir.bitcast v8 : u32; + v58 = arith.add v56, v57 : u32 #[overflow = checked]; + v336 = arith.constant 8 : u32; + v60 = arith.mod v58, v336 : u32; + hir.assertz v60 #[code = 250]; + v61 = hir.int_to_ptr v58 : ptr; + hir.store v61, v55; + v63 = arith.constant 16 : u32; + v62 = hir.bitcast v8 : u32; + v64 = arith.add v62, v63 : u32 #[overflow = checked]; + v335 = arith.constant 8 : u32; + v66 = arith.mod v64, v335 : u32; + hir.assertz v66 #[code = 250]; + v67 = hir.int_to_ptr v64 : ptr; + v68 = hir.load v67 : i64; + v70 = arith.constant 32 : u32; + v69 = hir.bitcast v8 : u32; + v71 = arith.add v69, v70 : u32 #[overflow = checked]; + v334 = arith.constant 8 : u32; + v73 = arith.mod v71, v334 : u32; + hir.assertz v73 #[code = 250]; + v74 = hir.int_to_ptr v71 : ptr; + hir.store v74, v68; + v75 = arith.constant 32 : i32; + v76 = arith.add v8, v75 : i32 #[overflow = wrapping]; + hir.exec @root_ns:root@1.0.0/hash_elements/miden_stdlib_sys::intrinsics::word::Word::reverse(v8, v76) + v78 = arith.constant 4 : i32; + hir.exec @root_ns:root@1.0.0/hash_elements/alloc::raw_vec::RawVecInner::deallocate(v0, v78, v78) + v80 = hir.bitcast v8 : u32; + v333 = arith.constant 4 : u32; + v82 = arith.mod v80, v333 : u32; + hir.assertz v82 #[code = 250]; + v83 = hir.int_to_ptr v80 : ptr; + v84 = hir.load v83 : felt; + v332 = arith.constant 48 : i32; + v86 = arith.add v8, v332 : i32 #[overflow = wrapping]; + v87 = builtin.global_symbol @root_ns:root@1.0.0/hash_elements/__stack_pointer : ptr + v88 = hir.bitcast v87 : ptr; + hir.store v88, v86; + builtin.ret v84; }; - private builtin.function @__rustc::__rust_dealloc(v76: i32, v77: i32, v78: i32) { - ^block6(v76: i32, v77: i32, v78: i32): + private builtin.function @__rustc::__rust_dealloc(v89: i32, v90: i32, v91: i32) { + ^block9(v89: i32, v90: i32, v91: i32): builtin.ret ; }; - private builtin.function @miden_stdlib_sys::intrinsics::word::Word::reverse(v79: i32, v80: i32) { - ^block8(v79: i32, v80: i32): - v83 = builtin.global_symbol @root_ns:root@1.0.0/hash_elements/__stack_pointer : ptr - v84 = hir.bitcast v83 : ptr; - v85 = hir.load v84 : i32; - v86 = arith.constant 16 : i32; - v87 = arith.sub v85, v86 : i32 #[overflow = wrapping]; - v89 = arith.constant 8 : u32; - v88 = hir.bitcast v80 : u32; - v90 = arith.add v88, v89 : u32 #[overflow = checked]; - v391 = arith.constant 8 : u32; - v92 = arith.mod v90, v391 : u32; - hir.assertz v92 #[code = 250]; - v93 = hir.int_to_ptr v90 : ptr; - v94 = hir.load v93 : i64; - v390 = arith.constant 8 : u32; - v95 = hir.bitcast v87 : u32; - v97 = arith.add v95, v390 : u32 #[overflow = checked]; - v98 = arith.constant 4 : u32; - v99 = arith.mod v97, v98 : u32; - hir.assertz v99 #[code = 250]; - v100 = hir.int_to_ptr v97 : ptr; - hir.store v100, v94; - v101 = hir.bitcast v80 : u32; - v389 = arith.constant 8 : u32; - v103 = arith.mod v101, v389 : u32; - hir.assertz v103 #[code = 250]; - v104 = hir.int_to_ptr v101 : ptr; - v105 = hir.load v104 : i64; - v106 = hir.bitcast v87 : u32; - v388 = arith.constant 4 : u32; - v108 = arith.mod v106, v388 : u32; - hir.assertz v108 #[code = 250]; - v109 = hir.int_to_ptr v106 : ptr; - hir.store v109, v105; - v110 = arith.constant 12 : i32; - v111 = arith.add v87, v110 : i32 #[overflow = wrapping]; - v81 = arith.constant 0 : i32; - v359, v360, v361, v362, v363, v364 = scf.while v81, v87, v111, v79 : i32, i32, i32, i32, i32, i32 { - ^block44(v365: i32, v366: i32, v367: i32, v368: i32): - v387 = arith.constant 0 : i32; - v114 = arith.constant 8 : i32; - v115 = arith.eq v365, v114 : i1; - v116 = arith.zext v115 : u32; - v117 = hir.bitcast v116 : i32; - v119 = arith.neq v117, v387 : i1; - v353, v354 = scf.if v119 : i32, i32 { - ^block43: - v313 = ub.poison i32 : i32; - scf.yield v313, v313; + private builtin.function @miden_stdlib_sys::intrinsics::word::Word::reverse(v92: i32, v93: i32) { + ^block11(v92: i32, v93: i32): + v96 = builtin.global_symbol @root_ns:root@1.0.0/hash_elements/__stack_pointer : ptr + v97 = hir.bitcast v96 : ptr; + v98 = hir.load v97 : i32; + v99 = arith.constant 16 : i32; + v100 = arith.sub v98, v99 : i32 #[overflow = wrapping]; + v102 = arith.constant 8 : u32; + v101 = hir.bitcast v93 : u32; + v103 = arith.add v101, v102 : u32 #[overflow = checked]; + v430 = arith.constant 8 : u32; + v105 = arith.mod v103, v430 : u32; + hir.assertz v105 #[code = 250]; + v106 = hir.int_to_ptr v103 : ptr; + v107 = hir.load v106 : i64; + v429 = arith.constant 8 : u32; + v108 = hir.bitcast v100 : u32; + v110 = arith.add v108, v429 : u32 #[overflow = checked]; + v111 = arith.constant 4 : u32; + v112 = arith.mod v110, v111 : u32; + hir.assertz v112 #[code = 250]; + v113 = hir.int_to_ptr v110 : ptr; + hir.store v113, v107; + v114 = hir.bitcast v93 : u32; + v428 = arith.constant 8 : u32; + v116 = arith.mod v114, v428 : u32; + hir.assertz v116 #[code = 250]; + v117 = hir.int_to_ptr v114 : ptr; + v118 = hir.load v117 : i64; + v119 = hir.bitcast v100 : u32; + v427 = arith.constant 4 : u32; + v121 = arith.mod v119, v427 : u32; + hir.assertz v121 #[code = 250]; + v122 = hir.int_to_ptr v119 : ptr; + hir.store v122, v118; + v123 = arith.constant 12 : i32; + v124 = arith.add v100, v123 : i32 #[overflow = wrapping]; + v94 = arith.constant 0 : i32; + v398, v399, v400, v401, v402, v403 = scf.while v94, v100, v124, v92 : i32, i32, i32, i32, i32, i32 { + ^block50(v404: i32, v405: i32, v406: i32, v407: i32): + v426 = arith.constant 0 : i32; + v127 = arith.constant 8 : i32; + v128 = arith.eq v404, v127 : i1; + v129 = arith.zext v128 : u32; + v130 = hir.bitcast v129 : i32; + v132 = arith.neq v130, v426 : i1; + v392, v393 = scf.if v132 : i32, i32 { + ^block49: + v352 = ub.poison i32 : i32; + scf.yield v352, v352; } else { - ^block13: - v121 = arith.add v366, v365 : i32 #[overflow = wrapping]; - v122 = hir.bitcast v121 : u32; - v386 = arith.constant 4 : u32; - v124 = arith.mod v122, v386 : u32; - hir.assertz v124 #[code = 250]; - v125 = hir.int_to_ptr v122 : ptr; - v126 = hir.load v125 : felt; - v128 = hir.bitcast v367 : u32; - v385 = arith.constant 4 : u32; - v130 = arith.mod v128, v385 : u32; - hir.assertz v130 #[code = 250]; - v131 = hir.int_to_ptr v128 : ptr; - v132 = hir.load v131 : i32; - v133 = hir.bitcast v121 : u32; - v384 = arith.constant 4 : u32; - v135 = arith.mod v133, v384 : u32; - hir.assertz v135 #[code = 250]; - v136 = hir.int_to_ptr v133 : ptr; - hir.store v136, v132; - v137 = hir.bitcast v367 : u32; - v383 = arith.constant 4 : u32; - v139 = arith.mod v137, v383 : u32; - hir.assertz v139 #[code = 250]; - v140 = hir.int_to_ptr v137 : ptr; - hir.store v140, v126; - v143 = arith.constant -4 : i32; - v144 = arith.add v367, v143 : i32 #[overflow = wrapping]; - v141 = arith.constant 4 : i32; - v142 = arith.add v365, v141 : i32 #[overflow = wrapping]; - scf.yield v142, v144; + ^block16: + v134 = arith.add v405, v404 : i32 #[overflow = wrapping]; + v135 = hir.bitcast v134 : u32; + v425 = arith.constant 4 : u32; + v137 = arith.mod v135, v425 : u32; + hir.assertz v137 #[code = 250]; + v138 = hir.int_to_ptr v135 : ptr; + v139 = hir.load v138 : felt; + v141 = hir.bitcast v406 : u32; + v424 = arith.constant 4 : u32; + v143 = arith.mod v141, v424 : u32; + hir.assertz v143 #[code = 250]; + v144 = hir.int_to_ptr v141 : ptr; + v145 = hir.load v144 : i32; + v146 = hir.bitcast v134 : u32; + v423 = arith.constant 4 : u32; + v148 = arith.mod v146, v423 : u32; + hir.assertz v148 #[code = 250]; + v149 = hir.int_to_ptr v146 : ptr; + hir.store v149, v145; + v150 = hir.bitcast v406 : u32; + v422 = arith.constant 4 : u32; + v152 = arith.mod v150, v422 : u32; + hir.assertz v152 #[code = 250]; + v153 = hir.int_to_ptr v150 : ptr; + hir.store v153, v139; + v156 = arith.constant -4 : i32; + v157 = arith.add v406, v156 : i32 #[overflow = wrapping]; + v154 = arith.constant 4 : i32; + v155 = arith.add v404, v154 : i32 #[overflow = wrapping]; + scf.yield v155, v157; }; - v381 = ub.poison i32 : i32; - v356 = cf.select v119, v381, v368 : i32; - v382 = ub.poison i32 : i32; - v355 = cf.select v119, v382, v366 : i32; - v312 = arith.constant 1 : u32; - v305 = arith.constant 0 : u32; - v358 = cf.select v119, v305, v312 : u32; - v346 = arith.trunc v358 : i1; - scf.condition v346, v353, v355, v354, v356, v366, v368; + v420 = ub.poison i32 : i32; + v395 = cf.select v132, v420, v407 : i32; + v421 = ub.poison i32 : i32; + v394 = cf.select v132, v421, v405 : i32; + v351 = arith.constant 1 : u32; + v344 = arith.constant 0 : u32; + v397 = cf.select v132, v344, v351 : u32; + v385 = arith.trunc v397 : i1; + scf.condition v385, v392, v394, v393, v395, v405, v407; } do { - ^block45(v369: i32, v370: i32, v371: i32, v372: i32, v373: i32, v374: i32): - scf.yield v369, v370, v371, v372; + ^block51(v408: i32, v409: i32, v410: i32, v411: i32, v412: i32, v413: i32): + scf.yield v408, v409, v410, v411; }; - v380 = arith.constant 8 : u32; - v146 = hir.bitcast v363 : u32; - v148 = arith.add v146, v380 : u32 #[overflow = checked]; - v379 = arith.constant 4 : u32; - v150 = arith.mod v148, v379 : u32; - hir.assertz v150 #[code = 250]; - v151 = hir.int_to_ptr v148 : ptr; - v152 = hir.load v151 : i64; - v378 = arith.constant 8 : u32; - v153 = hir.bitcast v364 : u32; - v155 = arith.add v153, v378 : u32 #[overflow = checked]; - v377 = arith.constant 8 : u32; - v157 = arith.mod v155, v377 : u32; - hir.assertz v157 #[code = 250]; - v158 = hir.int_to_ptr v155 : ptr; - hir.store v158, v152; - v159 = hir.bitcast v363 : u32; - v376 = arith.constant 4 : u32; - v161 = arith.mod v159, v376 : u32; - hir.assertz v161 #[code = 250]; - v162 = hir.int_to_ptr v159 : ptr; - v163 = hir.load v162 : i64; - v164 = hir.bitcast v364 : u32; - v375 = arith.constant 8 : u32; - v166 = arith.mod v164, v375 : u32; - hir.assertz v166 #[code = 250]; - v167 = hir.int_to_ptr v164 : ptr; - hir.store v167, v163; + v419 = arith.constant 8 : u32; + v159 = hir.bitcast v402 : u32; + v161 = arith.add v159, v419 : u32 #[overflow = checked]; + v418 = arith.constant 4 : u32; + v163 = arith.mod v161, v418 : u32; + hir.assertz v163 #[code = 250]; + v164 = hir.int_to_ptr v161 : ptr; + v165 = hir.load v164 : i64; + v417 = arith.constant 8 : u32; + v166 = hir.bitcast v403 : u32; + v168 = arith.add v166, v417 : u32 #[overflow = checked]; + v416 = arith.constant 8 : u32; + v170 = arith.mod v168, v416 : u32; + hir.assertz v170 #[code = 250]; + v171 = hir.int_to_ptr v168 : ptr; + hir.store v171, v165; + v172 = hir.bitcast v402 : u32; + v415 = arith.constant 4 : u32; + v174 = arith.mod v172, v415 : u32; + hir.assertz v174 #[code = 250]; + v175 = hir.int_to_ptr v172 : ptr; + v176 = hir.load v175 : i64; + v177 = hir.bitcast v403 : u32; + v414 = arith.constant 8 : u32; + v179 = arith.mod v177, v414 : u32; + hir.assertz v179 #[code = 250]; + v180 = hir.int_to_ptr v177 : ptr; + hir.store v180, v176; builtin.ret ; }; - private builtin.function @intrinsics::felt::from_u32(v168: i32) -> felt { - ^block14(v168: i32): - v169 = hir.bitcast v168 : felt; - builtin.ret v169; + private builtin.function @intrinsics::felt::from_u32(v181: i32) -> felt { + ^block17(v181: i32): + v182 = hir.bitcast v181 : felt; + builtin.ret v182; }; - private builtin.function @intrinsics::felt::assert_eq(v171: felt, v172: felt) { - ^block16(v171: felt, v172: felt): - hir.assert_eq v171, v172; + private builtin.function @intrinsics::felt::assert_eq(v184: felt, v185: felt) { + ^block19(v184: felt, v185: felt): + hir.assert_eq v184, v185; builtin.ret ; }; - private builtin.function @std::crypto::hashes::rpo::hash_memory(v173: i32, v174: i32, v175: i32) { - ^block18(v173: i32, v174: i32, v175: i32): - v176, v177, v178, v179 = hir.exec @std/crypto/hashes/rpo/hash_memory(v173, v174) : felt, felt, felt, felt - v180 = hir.bitcast v175 : u32; - v181 = hir.int_to_ptr v180 : ptr; - hir.store v181, v176; - v182 = arith.constant 4 : u32; - v183 = arith.add v180, v182 : u32 #[overflow = checked]; - v184 = hir.int_to_ptr v183 : ptr; - hir.store v184, v177; - v185 = arith.constant 8 : u32; - v186 = arith.add v180, v185 : u32 #[overflow = checked]; - v187 = hir.int_to_ptr v186 : ptr; - hir.store v187, v178; - v188 = arith.constant 12 : u32; - v189 = arith.add v180, v188 : u32 #[overflow = checked]; - v190 = hir.int_to_ptr v189 : ptr; - hir.store v190, v179; + private builtin.function @std::crypto::hashes::rpo::hash_memory(v186: i32, v187: i32, v188: i32) { + ^block21(v186: i32, v187: i32, v188: i32): + v189, v190, v191, v192 = hir.exec @std/crypto/hashes/rpo/hash_memory(v186, v187) : felt, felt, felt, felt + v193 = hir.bitcast v188 : u32; + v194 = hir.int_to_ptr v193 : ptr; + hir.store v194, v189; + v195 = arith.constant 4 : u32; + v196 = arith.add v193, v195 : u32 #[overflow = checked]; + v197 = hir.int_to_ptr v196 : ptr; + hir.store v197, v190; + v198 = arith.constant 8 : u32; + v199 = arith.add v193, v198 : u32 #[overflow = checked]; + v200 = hir.int_to_ptr v199 : ptr; + hir.store v200, v191; + v201 = arith.constant 12 : u32; + v202 = arith.add v193, v201 : u32 #[overflow = checked]; + v203 = hir.int_to_ptr v202 : ptr; + hir.store v203, v192; builtin.ret ; }; - private builtin.function @alloc::raw_vec::RawVecInner::deallocate(v191: i32, v192: i32, v193: i32) { - ^block24(v191: i32, v192: i32, v193: i32): - v195 = builtin.global_symbol @root_ns:root@1.0.0/hash_elements/__stack_pointer : ptr - v196 = hir.bitcast v195 : ptr; - v197 = hir.load v196 : i32; - v198 = arith.constant 16 : i32; - v199 = arith.sub v197, v198 : i32 #[overflow = wrapping]; - v200 = builtin.global_symbol @root_ns:root@1.0.0/hash_elements/__stack_pointer : ptr - v201 = hir.bitcast v200 : ptr; - hir.store v201, v199; - v202 = arith.constant 4 : i32; - v203 = arith.add v199, v202 : i32 #[overflow = wrapping]; - hir.exec @root_ns:root@1.0.0/hash_elements/alloc::raw_vec::RawVecInner::current_memory(v203, v191, v192, v193) - v205 = arith.constant 8 : u32; - v204 = hir.bitcast v199 : u32; - v206 = arith.add v204, v205 : u32 #[overflow = checked]; - v207 = arith.constant 4 : u32; - v208 = arith.mod v206, v207 : u32; - hir.assertz v208 #[code = 250]; - v209 = hir.int_to_ptr v206 : ptr; - v210 = hir.load v209 : i32; - v398 = arith.constant 0 : i32; - v194 = arith.constant 0 : i32; - v212 = arith.eq v210, v194 : i1; - v213 = arith.zext v212 : u32; - v214 = hir.bitcast v213 : i32; - v216 = arith.neq v214, v398 : i1; - scf.if v216{ - ^block46: + private builtin.function @std::crypto::hashes::rpo::hash_memory_words(v204: i32, v205: i32, v206: i32) { + ^block27(v204: i32, v205: i32, v206: i32): + v207, v208, v209, v210 = hir.exec @std/crypto/hashes/rpo/hash_memory_words(v204, v205) : felt, felt, felt, felt + v211 = hir.bitcast v206 : u32; + v212 = hir.int_to_ptr v211 : ptr; + hir.store v212, v207; + v213 = arith.constant 4 : u32; + v214 = arith.add v211, v213 : u32 #[overflow = checked]; + v215 = hir.int_to_ptr v214 : ptr; + hir.store v215, v208; + v216 = arith.constant 8 : u32; + v217 = arith.add v211, v216 : u32 #[overflow = checked]; + v218 = hir.int_to_ptr v217 : ptr; + hir.store v218, v209; + v219 = arith.constant 12 : u32; + v220 = arith.add v211, v219 : u32 #[overflow = checked]; + v221 = hir.int_to_ptr v220 : ptr; + hir.store v221, v210; + builtin.ret ; + }; + + private builtin.function @alloc::raw_vec::RawVecInner::deallocate(v222: i32, v223: i32, v224: i32) { + ^block29(v222: i32, v223: i32, v224: i32): + v226 = builtin.global_symbol @root_ns:root@1.0.0/hash_elements/__stack_pointer : ptr + v227 = hir.bitcast v226 : ptr; + v228 = hir.load v227 : i32; + v229 = arith.constant 16 : i32; + v230 = arith.sub v228, v229 : i32 #[overflow = wrapping]; + v231 = builtin.global_symbol @root_ns:root@1.0.0/hash_elements/__stack_pointer : ptr + v232 = hir.bitcast v231 : ptr; + hir.store v232, v230; + v233 = arith.constant 4 : i32; + v234 = arith.add v230, v233 : i32 #[overflow = wrapping]; + hir.exec @root_ns:root@1.0.0/hash_elements/alloc::raw_vec::RawVecInner::current_memory(v234, v222, v223, v224) + v236 = arith.constant 8 : u32; + v235 = hir.bitcast v230 : u32; + v237 = arith.add v235, v236 : u32 #[overflow = checked]; + v238 = arith.constant 4 : u32; + v239 = arith.mod v237, v238 : u32; + hir.assertz v239 #[code = 250]; + v240 = hir.int_to_ptr v237 : ptr; + v241 = hir.load v240 : i32; + v437 = arith.constant 0 : i32; + v225 = arith.constant 0 : i32; + v243 = arith.eq v241, v225 : i1; + v244 = arith.zext v243 : u32; + v245 = hir.bitcast v244 : i32; + v247 = arith.neq v245, v437 : i1; + scf.if v247{ + ^block52: scf.yield ; } else { - ^block27: - v397 = arith.constant 4 : u32; - v217 = hir.bitcast v199 : u32; - v219 = arith.add v217, v397 : u32 #[overflow = checked]; - v396 = arith.constant 4 : u32; - v221 = arith.mod v219, v396 : u32; - hir.assertz v221 #[code = 250]; - v222 = hir.int_to_ptr v219 : ptr; - v223 = hir.load v222 : i32; - v225 = arith.constant 12 : u32; - v224 = hir.bitcast v199 : u32; - v226 = arith.add v224, v225 : u32 #[overflow = checked]; - v395 = arith.constant 4 : u32; - v228 = arith.mod v226, v395 : u32; - hir.assertz v228 #[code = 250]; - v229 = hir.int_to_ptr v226 : ptr; - v230 = hir.load v229 : i32; - hir.exec @root_ns:root@1.0.0/hash_elements/::deallocate(v223, v210, v230) + ^block32: + v436 = arith.constant 4 : u32; + v248 = hir.bitcast v230 : u32; + v250 = arith.add v248, v436 : u32 #[overflow = checked]; + v435 = arith.constant 4 : u32; + v252 = arith.mod v250, v435 : u32; + hir.assertz v252 #[code = 250]; + v253 = hir.int_to_ptr v250 : ptr; + v254 = hir.load v253 : i32; + v256 = arith.constant 12 : u32; + v255 = hir.bitcast v230 : u32; + v257 = arith.add v255, v256 : u32 #[overflow = checked]; + v434 = arith.constant 4 : u32; + v259 = arith.mod v257, v434 : u32; + hir.assertz v259 #[code = 250]; + v260 = hir.int_to_ptr v257 : ptr; + v261 = hir.load v260 : i32; + hir.exec @root_ns:root@1.0.0/hash_elements/::deallocate(v254, v241, v261) scf.yield ; }; - v394 = arith.constant 16 : i32; - v233 = arith.add v199, v394 : i32 #[overflow = wrapping]; - v234 = builtin.global_symbol @root_ns:root@1.0.0/hash_elements/__stack_pointer : ptr - v235 = hir.bitcast v234 : ptr; - hir.store v235, v233; + v433 = arith.constant 16 : i32; + v264 = arith.add v230, v433 : i32 #[overflow = wrapping]; + v265 = builtin.global_symbol @root_ns:root@1.0.0/hash_elements/__stack_pointer : ptr + v266 = hir.bitcast v265 : ptr; + hir.store v266, v264; builtin.ret ; }; - private builtin.function @alloc::raw_vec::RawVecInner::current_memory(v236: i32, v237: i32, v238: i32, v239: i32) { - ^block28(v236: i32, v237: i32, v238: i32, v239: i32): - v424 = arith.constant 0 : i32; - v240 = arith.constant 0 : i32; - v244 = arith.eq v239, v240 : i1; - v245 = arith.zext v244 : u32; - v246 = hir.bitcast v245 : i32; - v248 = arith.neq v246, v424 : i1; - v411, v412 = scf.if v248 : i32, i32 { - ^block49: - v423 = arith.constant 0 : i32; - v242 = arith.constant 4 : i32; - scf.yield v242, v423; + private builtin.function @alloc::raw_vec::RawVecInner::current_memory(v267: i32, v268: i32, v269: i32, v270: i32) { + ^block33(v267: i32, v268: i32, v269: i32, v270: i32): + v463 = arith.constant 0 : i32; + v271 = arith.constant 0 : i32; + v275 = arith.eq v270, v271 : i1; + v276 = arith.zext v275 : u32; + v277 = hir.bitcast v276 : i32; + v279 = arith.neq v277, v463 : i1; + v450, v451 = scf.if v279 : i32, i32 { + ^block55: + v462 = arith.constant 0 : i32; + v273 = arith.constant 4 : i32; + scf.yield v273, v462; } else { - ^block31: - v249 = hir.bitcast v237 : u32; - v284 = arith.constant 4 : u32; - v251 = arith.mod v249, v284 : u32; - hir.assertz v251 #[code = 250]; - v252 = hir.int_to_ptr v249 : ptr; - v253 = hir.load v252 : i32; - v421 = arith.constant 0 : i32; - v422 = arith.constant 0 : i32; - v255 = arith.eq v253, v422 : i1; - v256 = arith.zext v255 : u32; - v257 = hir.bitcast v256 : i32; - v259 = arith.neq v257, v421 : i1; - v409 = scf.if v259 : i32 { - ^block48: - v420 = arith.constant 0 : i32; - scf.yield v420; + ^block36: + v280 = hir.bitcast v268 : u32; + v315 = arith.constant 4 : u32; + v282 = arith.mod v280, v315 : u32; + hir.assertz v282 #[code = 250]; + v283 = hir.int_to_ptr v280 : ptr; + v284 = hir.load v283 : i32; + v460 = arith.constant 0 : i32; + v461 = arith.constant 0 : i32; + v286 = arith.eq v284, v461 : i1; + v287 = arith.zext v286 : u32; + v288 = hir.bitcast v287 : i32; + v290 = arith.neq v288, v460 : i1; + v448 = scf.if v290 : i32 { + ^block54: + v459 = arith.constant 0 : i32; + scf.yield v459; } else { - ^block32: - v419 = arith.constant 4 : u32; - v260 = hir.bitcast v236 : u32; - v262 = arith.add v260, v419 : u32 #[overflow = checked]; - v418 = arith.constant 4 : u32; - v264 = arith.mod v262, v418 : u32; - hir.assertz v264 #[code = 250]; - v265 = hir.int_to_ptr v262 : ptr; - hir.store v265, v238; - v417 = arith.constant 4 : u32; - v266 = hir.bitcast v237 : u32; - v268 = arith.add v266, v417 : u32 #[overflow = checked]; - v416 = arith.constant 4 : u32; - v270 = arith.mod v268, v416 : u32; - hir.assertz v270 #[code = 250]; - v271 = hir.int_to_ptr v268 : ptr; - v272 = hir.load v271 : i32; - v273 = hir.bitcast v236 : u32; - v415 = arith.constant 4 : u32; - v275 = arith.mod v273, v415 : u32; - hir.assertz v275 #[code = 250]; - v276 = hir.int_to_ptr v273 : ptr; - hir.store v276, v272; - v277 = arith.mul v253, v239 : i32 #[overflow = wrapping]; - scf.yield v277; + ^block37: + v458 = arith.constant 4 : u32; + v291 = hir.bitcast v267 : u32; + v293 = arith.add v291, v458 : u32 #[overflow = checked]; + v457 = arith.constant 4 : u32; + v295 = arith.mod v293, v457 : u32; + hir.assertz v295 #[code = 250]; + v296 = hir.int_to_ptr v293 : ptr; + hir.store v296, v269; + v456 = arith.constant 4 : u32; + v297 = hir.bitcast v268 : u32; + v299 = arith.add v297, v456 : u32 #[overflow = checked]; + v455 = arith.constant 4 : u32; + v301 = arith.mod v299, v455 : u32; + hir.assertz v301 #[code = 250]; + v302 = hir.int_to_ptr v299 : ptr; + v303 = hir.load v302 : i32; + v304 = hir.bitcast v267 : u32; + v454 = arith.constant 4 : u32; + v306 = arith.mod v304, v454 : u32; + hir.assertz v306 #[code = 250]; + v307 = hir.int_to_ptr v304 : ptr; + hir.store v307, v303; + v308 = arith.mul v284, v270 : i32 #[overflow = wrapping]; + scf.yield v308; }; - v278 = arith.constant 8 : i32; - v414 = arith.constant 4 : i32; - v410 = cf.select v259, v414, v278 : i32; - scf.yield v410, v409; + v309 = arith.constant 8 : i32; + v453 = arith.constant 4 : i32; + v449 = cf.select v290, v453, v309 : i32; + scf.yield v449, v448; }; - v281 = arith.add v236, v411 : i32 #[overflow = wrapping]; - v283 = hir.bitcast v281 : u32; - v413 = arith.constant 4 : u32; - v285 = arith.mod v283, v413 : u32; - hir.assertz v285 #[code = 250]; - v286 = hir.int_to_ptr v283 : ptr; - hir.store v286, v412; + v312 = arith.add v267, v450 : i32 #[overflow = wrapping]; + v314 = hir.bitcast v312 : u32; + v452 = arith.constant 4 : u32; + v316 = arith.mod v314, v452 : u32; + hir.assertz v316 #[code = 250]; + v317 = hir.int_to_ptr v314 : ptr; + hir.store v317, v451; builtin.ret ; }; - private builtin.function @::deallocate(v287: i32, v288: i32, v289: i32) { - ^block33(v287: i32, v288: i32, v289: i32): - v426 = arith.constant 0 : i32; - v290 = arith.constant 0 : i32; - v291 = arith.eq v289, v290 : i1; - v292 = arith.zext v291 : u32; - v293 = hir.bitcast v292 : i32; - v295 = arith.neq v293, v426 : i1; - scf.if v295{ - ^block35: + private builtin.function @::deallocate(v318: i32, v319: i32, v320: i32) { + ^block38(v318: i32, v319: i32, v320: i32): + v465 = arith.constant 0 : i32; + v321 = arith.constant 0 : i32; + v322 = arith.eq v320, v321 : i1; + v323 = arith.zext v322 : u32; + v324 = hir.bitcast v323 : i32; + v326 = arith.neq v324, v465 : i1; + scf.if v326{ + ^block40: scf.yield ; } else { - ^block36: - hir.exec @root_ns:root@1.0.0/hash_elements/__rustc::__rust_dealloc(v287, v289, v288) + ^block41: + hir.exec @root_ns:root@1.0.0/hash_elements/__rustc::__rust_dealloc(v318, v320, v319) scf.yield ; }; builtin.ret ; diff --git a/tests/integration/expected/hash_elements.masm b/tests/integration/expected/hash_elements.masm index 376850f37..cc7deffdf 100644 --- a/tests/integration/expected/hash_elements.masm +++ b/tests/integration/expected/hash_elements.masm @@ -33,7 +33,7 @@ export.entrypoint exec.::intrinsics::mem::store_sw trace.252 nop - push.4 + push.8 dup.2 add u32assert @@ -50,6 +50,23 @@ export.entrypoint exec.::intrinsics::mem::load_sw trace.252 nop + push.4 + dup.3 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz + u32divmod.4 + swap.1 + trace.240 + nop + exec.::intrinsics::mem::load_sw + trace.252 + nop push.2 swap.1 swap.1 @@ -74,32 +91,37 @@ export.entrypoint exec.::root_ns:root@1.0.0::hash_elements::intrinsics::felt::assert_eq trace.252 nop - push.8 - dup.3 - add - u32assert - push.4 - dup.1 - swap.1 - u32mod - u32assert - assertz - u32divmod.4 - swap.1 - trace.240 - nop - exec.::intrinsics::mem::load_sw - trace.252 - nop - push.16 - dup.3 - u32wrapping_add - swap.2 - trace.240 - nop - exec.::root_ns:root@1.0.0::hash_elements::std::crypto::hashes::rpo::hash_memory - trace.252 - nop + push.0 + push.0 + push.3 + dup.4 + u32and + eq + neq + if.true + push.16 + dup.3 + u32wrapping_add + movup.2 + dup.2 + u32wrapping_add + movup.2 + trace.240 + nop + exec.::root_ns:root@1.0.0::hash_elements::std::crypto::hashes::rpo::hash_memory_words + trace.252 + nop + else + push.16 + dup.3 + u32wrapping_add + movdn.2 + trace.240 + nop + exec.::root_ns:root@1.0.0::hash_elements::std::crypto::hashes::rpo::hash_memory + trace.252 + nop + end push.24 dup.1 add @@ -543,6 +565,61 @@ proc.std::crypto::hashes::rpo::hash_memory nop end +proc.std::crypto::hashes::rpo::hash_memory_words + trace.240 + nop + exec.::std::crypto::hashes::rpo::hash_memory_words + trace.252 + nop + movup.4 + dup.0 + movup.2 + swap.1 + u32divmod.4 + swap.1 + trace.240 + nop + exec.::intrinsics::mem::store_felt + trace.252 + nop + push.4 + dup.1 + add + u32assert + movup.2 + swap.1 + u32divmod.4 + swap.1 + trace.240 + nop + exec.::intrinsics::mem::store_felt + trace.252 + nop + push.8 + dup.1 + add + u32assert + movup.2 + swap.1 + u32divmod.4 + swap.1 + trace.240 + nop + exec.::intrinsics::mem::store_felt + trace.252 + nop + push.12 + add + u32assert + u32divmod.4 + swap.1 + trace.240 + nop + exec.::intrinsics::mem::store_felt + trace.252 + nop +end + proc.alloc::raw_vec::RawVecInner::deallocate push.1114112 u32divmod.4 diff --git a/tests/integration/expected/hash_elements.wat b/tests/integration/expected/hash_elements.wat index 55b5dd67e..6b6a876ce 100644 --- a/tests/integration/expected/hash_elements.wat +++ b/tests/integration/expected/hash_elements.wat @@ -10,30 +10,50 @@ (export "memory" (memory 0)) (export "entrypoint" (func $entrypoint)) (func $entrypoint (;0;) (type 0) (param i32) (result f32) - (local i32 i32 f32) + (local i32 i32 i32 f32) global.get $__stack_pointer i32.const 48 i32.sub local.tee 1 global.set $__stack_pointer local.get 0 + i32.load offset=8 + local.set 2 + local.get 0 i32.load offset=4 i32.const 2 i32.shr_u - local.tee 2 + local.tee 3 i32.const 3 i32.and call $intrinsics::felt::from_u32 i32.const 0 call $intrinsics::felt::from_u32 call $intrinsics::felt::assert_eq - local.get 2 - local.get 0 - i32.load offset=8 - local.get 1 - i32.const 16 - i32.add - call $std::crypto::hashes::rpo::hash_memory + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.const 3 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 2 + local.get 1 + i32.const 16 + i32.add + call $std::crypto::hashes::rpo::hash_memory + br 1 (;@1;) + end + local.get 3 + local.get 3 + local.get 2 + i32.add + local.get 1 + i32.const 16 + i32.add + call $std::crypto::hashes::rpo::hash_memory_words + end local.get 1 local.get 1 i64.load offset=24 @@ -53,12 +73,12 @@ call $alloc::raw_vec::RawVecInner::deallocate local.get 1 f32.load - local.set 3 + local.set 4 local.get 1 i32.const 48 i32.add global.set $__stack_pointer - local.get 3 + local.get 4 ) (func $__rustc::__rust_dealloc (;1;) (type 1) (param i32 i32 i32)) (func $miden_stdlib_sys::intrinsics::word::Word::reverse (;2;) (type 2) (param i32 i32) @@ -128,7 +148,10 @@ (func $std::crypto::hashes::rpo::hash_memory (;5;) (type 1) (param i32 i32 i32) unreachable ) - (func $alloc::raw_vec::RawVecInner::deallocate (;6;) (type 1) (param i32 i32 i32) + (func $std::crypto::hashes::rpo::hash_memory_words (;6;) (type 1) (param i32 i32 i32) + unreachable + ) + (func $alloc::raw_vec::RawVecInner::deallocate (;7;) (type 1) (param i32 i32 i32) (local i32) global.get $__stack_pointer i32.const 16 @@ -160,7 +183,7 @@ i32.add global.set $__stack_pointer ) - (func $alloc::raw_vec::RawVecInner::current_memory (;7;) (type 4) (param i32 i32 i32 i32) + (func $alloc::raw_vec::RawVecInner::current_memory (;8;) (type 4) (param i32 i32 i32 i32) (local i32 i32 i32) i32.const 0 local.set 4 @@ -195,7 +218,7 @@ local.get 4 i32.store ) - (func $::deallocate (;8;) (type 1) (param i32 i32 i32) + (func $::deallocate (;9;) (type 1) (param i32 i32 i32) block ;; label = @1 local.get 2 i32.eqz