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

Function wrap_scr

bitvm/src/chunk/wrap_hasher.rs:21–29  ·  view source on GitHub ↗

truncate 32 byte output hash to {BLAKE3_HASH_LENGTH} hash output and pad with zeros

(scr: Script)

Source from the content-addressed store, hash-verified

19
20/// truncate 32 byte output hash to {BLAKE3_HASH_LENGTH} hash output and pad with zeros
21fn 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
32pub(crate) fn hash_n_bytes<const N: usize>() -> Script {

Callers 1

hash_n_bytesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected