MCPcopy Create free account
hub / github.com/BitVM/BitVM / blake3_compute_script_with_limb

Function blake3_compute_script_with_limb

bitvm/src/hash/blake3.rs:349–359  ·  view source on GitHub ↗

Returns a script that computes the BLAKE3 hash of the message on the stack. The script processes compact message blocks and only unpacks them when needed, resulting in higher stack efficiency and support for larger messages. ## Parameters - `msg_len`: Length of the message. (excluding the padding, number of bytes) - `limb_len`: Limb length (number of bits per element) that the input in the stac

(message_len: usize, limb_len: u8)

Source from the content-addressed store, hash-verified

347/// - Temporarily uses the alternate stack for intermediate results and hash computation tables.
348/// - Final result is left on the main stack as a BLAKE3 hash value. (in nibbles)
349pub fn blake3_compute_script_with_limb(message_len: usize, limb_len: u8) -> Script {
350 assert!(
351 message_len <= 1024,
352 "This BLAKE3 implementation doesn't support messages longer than 1024 bytes"
353 );
354 let mut stack = StackTracker::new();
355 let use_full_tables = true;
356 let message_len = message_len as u32; // safety: message_len <= 1024 << u32::MAX
357 blake3(&mut stack, message_len, true, use_full_tables, limb_len);
358 stack.get_script()
359}
360
361/// Uses [`blake3_compute_script_with_limb`].with limb length 29, see the documentation of it for more details
362pub fn blake3_compute_script(message_len: usize) -> Script {

Calls 2

blake3Function · 0.85
get_scriptMethod · 0.80