sigil-bitcoin-primitives
sigil bitcoin primitives
(sigil bitcoin primitives) — Bitcoin hash combinators Pure Sigil library providing HASH160, HASH256, and BIP-340 tagged hashes. ```scheme (import (sigil bitcoin primitives)) (hash160 #u8(0 1 2 3)) ; => 20-byte bytevector (hash256 #u8(0 1 2 3)) ; => 32-byte bytevector (tagged-hash "MyTag" #u8(0 1 2 3)) ; => 32-byte bytevector ```
hash160
procedureCompute HASH160 = RIPEMD160(SHA256(data)). Returns a 20-byte bytevector. Used for P2PKH and P2SH address derivation. ```scheme (hash160 "hello") (hash160 #u8(0 1 2 3)) ```
hash256
procedureCompute HASH256 = SHA256(SHA256(data)). Returns a 32-byte bytevector. Used for transaction IDs (txid) and block hashes. ```scheme (hash256 "hello") (hash256 #u8(0 1 2 3)) ```
bip0340/challenge
variableBIP340 tagged-hash tag for Schnorr challenge hashes.
bip0340/aux
variableBIP340 tagged-hash tag for auxiliary randomness.
bip0340/nonce
variableBIP340 tagged-hash tag for nonce derivation.
taproot/elements
variableBIP341 tagged-hash tag for Taproot tweak data.
tagged-hash
procedureCompute a BIP-340 tagged hash. tagged_hash(tag, x) = SHA256(SHA256(tag) || SHA256(tag) || x) `tag` is a UTF-8 string (e.g. "BIP0340/challenge"). `x` is a bytevector. Returns a 32-byte bytevector. ```scheme (tagged-hash "MyApp/v1" #u8(0 1 2 3)) ```