bitcoin-hs-0.0.1: Partial implementation of the Bitcoin protocol (as of 2013)

Safe HaskellNone
LanguageHaskell98

Bitcoin.Protocol.Hash

Synopsis

Documentation

data Hash160 Source #

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)

Constructors

Hash160 !Word64 !Word64 !Word32 

data Hash256 Source #

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).

Constructors

Hash256 !Word64 !Word64 !Word64 !Word64 

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.