truncate 32 byte output hash to {BLAKE3_HASH_LENGTH} hash output and pad with zeros
(scr: Script)
| 19 | |
| 20 | /// truncate 32 byte output hash to {BLAKE3_HASH_LENGTH} hash output and pad with zeros |
| 21 | fn wrap_scr(scr: Script) -> Script { |
| 22 | script! { |
| 23 | { scr } |
| 24 | for _ in 0..(32*2-BLAKE3_HASH_LENGTH*2)/2 { OP_2DROP } |
| 25 | for _ in 0..BLAKE3_HASH_LENGTH*2 { OP_TOALTSTACK } |
| 26 | for _ in 0..(32*2-BLAKE3_HASH_LENGTH*2) { 0 } |
| 27 | for _ in 0..BLAKE3_HASH_LENGTH*2 { OP_FROMALTSTACK } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | // create Script instance from stack-tracker and pad output with zeros to appropriate hash size |
| 32 | pub(crate) fn hash_n_bytes<const N: usize>() -> Script { |