Returns a script that pushes the given message onto the stack for BLAKE3. The script transforms the message into the correct format and pushes the result onto the stack. ## Panics This function panics if the message is longer than 1024 bytes, since our BLAKE3 implementation doesn't support longer messages.
(message_bytes: &[u8], limb_len: u8)
| 247 | /// This function panics if the message is longer than 1024 bytes, |
| 248 | /// since our BLAKE3 implementation doesn't support longer messages. |
| 249 | pub fn blake3_push_message_script_with_limb(message_bytes: &[u8], limb_len: u8) -> Script { |
| 250 | assert!( |
| 251 | message_bytes.len() <= 1024, |
| 252 | "This BLAKE3 implementation doesn't support messages longer than 1024 bytes" |
| 253 | ); |
| 254 | let chunks = chunk_message(message_bytes); |
| 255 | |
| 256 | script! { |
| 257 | for chunk in chunks.into_iter().rev() { |
| 258 | for (i, byte) in chunk.into_iter().enumerate() { |
| 259 | { |
| 260 | byte |
| 261 | } |
| 262 | if i == 31 || i == 63 { |
| 263 | { |
| 264 | U256::transform_limbsize(8, limb_len as u32) |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | /// Number of elements in total of all tables |
| 273 | const SUM_OF_FULL_TABLES: usize = 384; |
no test coverage detected