Calculates the maximum number of altstack elements one can have using the [`blake3_compute_script`] function with the following formula: ```text n (number of blocks) = ⌈msg_len / 64⌉ limb_count (number of limbs in a block) = ⌈256 / limb_len⌉ * 2 m (message's consumption of stack during BLAKE3) = (n - 1) * limb_count Since BLAKE3 requires an empty stack and we've calculated the usage for the messag
(message_len: usize, limb_len: u8)
| 288 | /// MAX_NUMBEROF_ALTSTACK_ELEMENTS = 1000 (max stack limit) - m - 644 (Maximum number of elements used during BLAKE3) |
| 289 | /// ``` |
| 290 | pub fn maximum_number_of_altstack_elements_using_blake3(message_len: usize, limb_len: u8) -> i32 { |
| 291 | let n = message_len.div_ceil(64); |
| 292 | let limb_count = 256usize.div_ceil(limb_len as usize) * 2; |
| 293 | let m = (n - 1) * limb_count; |
| 294 | 1000_i32 - MAX_BLAKE3_ELEMENT_COUNT as i32 - m as i32 |
| 295 | } |
| 296 | |
| 297 | /// Returns a script that computes the BLAKE3 hash of the message on the stack. |
| 298 | /// |
no outgoing calls