Safe Haskell | None |
---|---|
Language | Haskell98 |
- data Hash160 = Hash160 !Word64 !Word64 !Word32
- data Hash256 = Hash256 !Word64 !Word64 !Word64 !Word64
- partitionList20 :: [Word8] -> ([Word8], [Word8], [Word8])
- partitionList32 :: [Word8] -> ([Word8], [Word8], [Word8], [Word8])
- debugDoHash256 :: OctetStream a => a -> Hash256
- doHash256 :: OctetStream a => a -> Hash256
- doHash160 :: OctetStream a => a -> Hash160
- zeroHash160 :: Hash160
- zeroHash256 :: Hash256
- hash256FromTextBE :: String -> Hash256
- hash160FromTextBE :: String -> Hash160
Documentation
Hash160(x) = RipEmd160(SHA256(x))
Note: the Show and Ord instances treat them as big-endian integers!
It seems that the most compact representation is unpacked machine words
(ForeignPtr
has too much overhead even with mallocPlainForeignPtr
).
In memory representation: Hash160 w1 w2 w3
means that the w1 represent the
first 8 bytes, in little-endian representation, then w2 the second 8 bytes,
finally w3 the last 4 bytes. This way, the big-endian comparison can be
done fast (first compare w3
, if equal compare w2
, if that is also equal compare w1
)
Hash256(x) = SHA256(SHA256(x))
Note: the Show and Ord instances treat them as big-endian integers!
It seems that the most compact representation is unpacked machine words
(ForeignPtr
has too much overhead even with mallocPlainForeignPtr
).
debugDoHash256 :: OctetStream a => a -> Hash256 Source #
doHash256 :: OctetStream a => a -> Hash256 Source #
SHA256(SHA256(x))
doHash160 :: OctetStream a => a -> Hash160 Source #
RIPEMD160(SHA256(x))
zeroHash160 :: Hash160 Source #
The zero ripemd hash (not really used for anything)
zeroHash256 :: Hash256 Source #
Generation (or "coinbase") transactions have hash set to zero
hash256FromTextBE :: String -> Hash256 Source #
Creates a 256 bit hash from a big-endian hex string (may fail with exception). This is here primarily for convenience.
hash160FromTextBE :: String -> Hash160 Source #
Creates a 160 bit hash from a big-endian hex string (may fail with exception). This is here primarily for convenience.