Documentation ¶
Overview ¶
Copyright (c) 2017-2018 The qitmeer developers
Copyright (c) 2017-2018 The qitmeer developers ¶
Copyright (c) 2017-2018 The qitmeer developers ¶
Copyright (c) 2017-2018 The qitmeer developers
Index ¶
- Constants
- Variables
- func CalcHash(buf []byte, hasher h.Hash) []byte
- func Decode(dst *Hash, src string) error
- func DoubleHashB(b []byte) []byte
- func DoubleHashB_pool(b []byte) []byte
- func Hash160(buf []byte) []byte
- func Hash512B(b []byte) []byte
- func HashB(b []byte) []byte
- func HashB_pool(b []byte) []byte
- type Hash
- func DoubleHashH(b []byte) Hash
- func DoubleHashH_pool(b []byte) Hash
- func HashCryptoNight(b []byte) Hash
- func HashH(b []byte) Hash
- func HashH_pool(b []byte) Hash
- func HashMeerXKeccakV1(input []byte) Hash
- func HashQitmeerKeccak256(b []byte) Hash
- func HashX16rv3(b []byte) Hash
- func HashX8r16(b []byte) Hash
- func MustBytesToDecodeHash(b []byte) Hash
- func MustBytesToHash(b []byte) Hash
- func MustHexToDecodedHash(i string) Hash
- func MustHexToHash(i string) Hash
- func NewHash(newHash []byte) (*Hash, error)
- func NewHashFromStr(hash string) (*Hash, error)
- type Hash256
- type Hash512
- type HashType
- type Hasher
Constants ¶
const HashSize = 32
const MaxHashStringSize = HashSize * 2
MaxHashStringSize is the maximum length of a Hash hash string.
Variables ¶
var ErrHashStrSize = fmt.Errorf("max hash string length is %v bytes", MaxHashStringSize)
ErrHashStrSize describes an error that indicates the caller specified a hash string that has too many characters.
var ZeroHash = Hash([32]byte{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
})
Functions ¶
func Decode ¶
Decode decodes the byte-reversed hexadecimal string encoding of a Hash to a destination.
func DoubleHashB ¶
DoubleHashB calculates hash(hash(b)) and returns the resulting bytes.
func DoubleHashB_pool ¶
Types ¶
type Hash ¶
func DoubleHashH ¶
DoubleHashH calculates hash(hash(b)) and returns the resulting bytes as a Hash.
func DoubleHashH_pool ¶
func HashCryptoNight ¶ added in v0.10.1
CryptoNight calculates hash(b) and returns the resulting bytes as a Hash.
func HashH_pool ¶
func HashMeerXKeccakV1 ¶ added in v0.10.1
Meer X Keccak V1 calculates hash(b) and returns the resulting bytes as a Hash. 2 round of NewLegacyKeccak512 1 round of NewQitmeerKeccak256
func HashQitmeerKeccak256 ¶ added in v0.10.1
Qitmeer Keccak256 calculates hash(b) and returns the resulting bytes as a Hash.
func HashX16rv3 ¶ added in v0.10.1
HashX16rv3 calculates hash(b) and returns the resulting bytes as a Hash.
func HashX8r16 ¶ added in v0.10.1
HashX8r16 calculates hash(b) and returns the resulting bytes as a Hash.
func MustBytesToDecodeHash ¶
convert []byte to a byte-reversed hash, Must means it panics for invalid input.
func MustBytesToHash ¶
convert []byte to a hash, Must means it panics for invalid input.
func MustHexToDecodedHash ¶
convert hex string to a byte-reversed hash, Must means it panics for invalid input.
func MustHexToHash ¶
convert hex string to a hash. Must means it panics for invalid input.
func NewHash ¶
NewHash returns a new Hash from a byte slice. An error is returned if the number of bytes passed in is not HashSize.
func NewHashFromStr ¶
NewHashFromStr creates a Hash from a hash string. The string should be the hexadecimal string of a byte-reversed hash, but any missing characters result in zero padding at the end of the Hash.
func (*Hash) CloneBytes ¶
CloneBytes returns a copy of the bytes which represent the hash as a byte slice.
NOTE: It is generally cheaper to just slice the hash directly thereby reusing the same bytes rather than calling this method.
func (*Hash) SetBytes ¶
SetBytes sets the bytes which represent the hash. An error is returned if the number of bytes passed in is not HashSize.
func (*Hash) UnmarshalText ¶
UnmarshalText decodes the hash from hex. The 0x prefix is optional. TODO clean-up the byte-reverse hash
type HashType ¶
type HashType byte
TODO refactoring hasher consider to integrated https://github.com/multiformats/go-multihash