Documentation
¶
Overview ¶
Package hashing provides core hashing utilities providing generic hash, HMAC, and KMAC operations with support for length-prefixed encoding.
See README.md for details.
Index ¶
- func Hash[H hash.Hash](hashFunc func() H, xs ...[]byte) ([]byte, error)
- func HashChain[H hash.Hash](hashFunc func() H, xs ...[]byte) ([]byte, error)
- func HashFuncTypeErase[H hash.Hash](hashFunc func() H) func() hash.Hash
- func HashIndexLengthPrefixed[H hash.Hash](hashFunc func() H, xs ...[]byte) ([]byte, error)
- func Hmac[H hash.Hash](key []byte, hashFunc func() H, xs ...[]byte) ([]byte, error)
- func HmacIndexLengthPrefixed[H hash.Hash](key []byte, hashFunc func() H, xs ...[]byte) ([]byte, error)
- func Kmac(key, customizationString []byte, tagSize int, ...) ([]byte, error)
- func KmacIndexLengthPrefixed(key, customizationString []byte, tagSize int, ...) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Hash ¶
Hash iteratively writes all the inputs to the given hash function and returns the result.
func HashChain ¶
HashChain computes an iterated hash where each input is hashed together with the previous output. It starts with a zero-initialised buffer and iteratively computes H(previous || input) for each input.
func HashFuncTypeErase ¶
HashFuncTypeErase converts a generic hash constructor to a non-generic one returning hash.Hash. This is useful when interfacing with APIs that require func() hash.Hash, such as crypto/hmac.
func HashIndexLengthPrefixed ¶
HashIndexLengthPrefixed hashes the inputs after encoding each with its index and length prefix. This encoding ensures that different input sequences produce distinct hash inputs.
func Hmac ¶
Hmac iteratively writes all the inputs to an hmac (defined by the hash function and the key) and returns the result.
func HmacIndexLengthPrefixed ¶
func HmacIndexLengthPrefixed[H hash.Hash](key []byte, hashFunc func() H, xs ...[]byte) ([]byte, error)
HmacIndexLengthPrefixed computes an HMAC over the inputs after encoding each with its index and length prefix.
func Kmac ¶
func Kmac(key, customizationString []byte, tagSize int, h func(key []byte, tagSize int, customizationString []byte) (*kmac.Kmac, error), xs ...[]byte) ([]byte, error)
Kmac computes a KMAC (Keccak Message Authentication Code) over the inputs using a cSHAKE function. The key must be at least half the output size to meet the security level requirements.
func KmacIndexLengthPrefixed ¶
func KmacIndexLengthPrefixed(key, customizationString []byte, tagSize int, h func(key []byte, tagSize int, customizationString []byte) (*kmac.Kmac, error), xs ...[]byte) ([]byte, error)
KmacIndexLengthPrefixed computes a KMAC over the inputs after encoding each with its index and length prefix.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bip340 provides bIP-340 tagged hash implementation for Schnorr signatures.
|
Package bip340 provides bIP-340 tagged hash implementation for Schnorr signatures. |
|
Package kmac provides kMAC (Keccak Message Authentication Code) implementation per NIST SP 800-185.
|
Package kmac provides kMAC (Keccak Message Authentication Code) implementation per NIST SP 800-185. |
|
Package poseidon provides poseidon hash function over the Pallas base field, designed for efficient use in zero-knowledge proof systems.
|
Package poseidon provides poseidon hash function over the Pallas base field, designed for efficient use in zero-knowledge proof systems. |