Documentation ¶
Overview ¶
Package bhash exposes commonly used utility functions for hashing data in Bitcoin.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoubleSha256 ¶
DoubleSha256 returns the double-SHA256 hash of the given data.
func NewTaggedHasher ¶
NewTaggedHasher returns a function which generates a hash whose preimage is prepended twice with the hash of the given tag string.
tagged_hash(tag, ...chunks) = sha256(sha256(tag) || sha256(tag) || chunks...)
Types ¶
type MultiHasher ¶
type MultiHasher struct {
// contains filtered or unexported fields
}
MultiHasher is a chain of cryptographic hashes, one feeding into the next from first to last. Think of it as an io.MultiWriter but for hash functions.
func NewMultiHasher ¶
func NewMultiHasher(hashes ...hash.Hash) *MultiHasher
NewMultiHasher returns a pointer to a new MultiHasher, which will use the given hashes provided to hash data.
func (*MultiHasher) BlockSize ¶
func (mh *MultiHasher) BlockSize() int
BlockSize returns the block size of the first hash in the chain.
func (*MultiHasher) Reset ¶
func (mh *MultiHasher) Reset()
Reset resets the MultiHasher to its initial state.
func (*MultiHasher) Size ¶
func (mh *MultiHasher) Size() int
Size returns the output size of the last hash in the chain.
func (*MultiHasher) Sum ¶
func (mh *MultiHasher) Sum(b []byte) []byte
Sum computes the final hash by piping output from each hash to the next in the chain, returning the result of appending the final hash to b. If b is nil, it simply returns the finalized hash.