Documentation
¶
Overview ¶
Package blake256 implements BLAKE-256 and BLAKE-224 hash functions (SHA-3 candidate).
Index ¶
- Constants
- Variables
- func CheckDecode(input string) ([]byte, [2]byte, error)
- func DecodeAddressV0(addr string, params AddressParamsV0) error
- func GenerateAssetId(assetKey string) crypto.Hash
- func New() hash.Hash
- func New224() hash.Hash
- func New224Salt(salt []byte) hash.Hash
- func NewSalt(salt []byte) hash.Hash
- func Sum224(data []byte) (sum224 [Size224]byte)
- func Sum256(data []byte) [Size]byte
- func VerifyAddress(address string) error
- func VerifyAssetKey(assetKey string) error
- func VerifyTransactionHash(hash string) error
- type AddressParamsV0
- type Error
- type ErrorKind
Constants ¶
const ( // ErrUnsupportedAddress indicates that an address successfully decoded, but // is not a supported/recognized type. ErrUnsupportedAddress = ErrorKind("ErrUnsupportedAddress") // ErrUnsupportedScriptVersion indicates that an address type does not // support a given script version. ErrUnsupportedScriptVersion = ErrorKind("ErrUnsupportedScriptVersion") // ErrMalformedAddress indicates an address failed to decode. ErrMalformedAddress = ErrorKind("ErrMalformedAddress") // ErrMalformedAddressData indicates an address successfully decoded and is // a recognized type, but the encoded data is not the expected length. ErrMalformedAddressData = ErrorKind("ErrMalformedAddressData") // ErrBadAddressChecksum indicates an address failed to decode due to an // invalid checksum. ErrBadAddressChecksum = ErrorKind("ErrBadAddressChecksum") // ErrInvalidPubKey indicates that a serialized public key failed to // parse. ErrInvalidPubKey = ErrorKind("ErrInvalidPubKey") // ErrInvalidPubKeyFormat indicates that a serialized public key parsed // successfully, but is not one of the allowed formats. ErrInvalidPubKeyFormat = ErrorKind("ErrInvalidPubKeyFormat") // ErrInvalidHashLen indicates that either a public key hash or a script // hash is not an allowed length. ErrInvalidHashLen = ErrorKind("ErrInvalidHashLen") )
These constants are used to identify a specific ErrorKind.
const BlockSize = 64
BlockSize is the block size of the hash algorithm in bytes.
const Size = 32
Size is the size of BLAKE-256 hash in bytes.
const Size224 = 28
Size224 is the size of BLAKE-224 hash in bytes.
Variables ¶
var ( DecredChainBase string DecredChainId crypto.Hash )
var ErrChecksum = errors.New("checksum error")
ErrChecksum indicates that the checksum of a check-encoded string does not verify against the checksum.
var ErrInvalidFormat = errors.New("invalid format: version and/or checksum bytes missing")
ErrInvalidFormat indicates that the check-encoded string has an invalid format.
Functions ¶
func CheckDecode ¶ added in v0.13.6
CheckDecode decodes a string that was encoded with CheckEncode and verifies the checksum.
func DecodeAddressV0 ¶ added in v0.13.6
func DecodeAddressV0(addr string, params AddressParamsV0) error
DecodeAddressV0 decodes the string encoding of an address and returns the relevant Address if it is a valid encoding for a known version 0 address type and is for the network identified by the provided parameters.
func GenerateAssetId ¶
func New224Salt ¶ added in v0.13.6
New224Salt is like New224 but initializes salt with the given 16-byte slice.
func NewSalt ¶ added in v0.13.6
NewSalt is like New but initializes salt with the given 16-byte slice.
func VerifyAddress ¶
func VerifyAssetKey ¶
func VerifyTransactionHash ¶
Types ¶
type AddressParamsV0 ¶ added in v0.13.6
type AddressParamsV0 interface { // AddrIDPubKeyV0 returns the magic prefix bytes for version 0 pay-to-pubkey // addresses. AddrIDPubKeyV0() [2]byte // AddrIDPubKeyHashECDSAV0 returns the magic prefix bytes for version 0 // pay-to-pubkey-hash addresses where the underlying pubkey is secp256k1 and // the signature algorithm is ECDSA. AddrIDPubKeyHashECDSAV0() [2]byte // AddrIDPubKeyHashEd25519V0 returns the magic prefix bytes for version 0 // pay-to-pubkey-hash addresses where the underlying pubkey and signature // algorithm are Ed25519. AddrIDPubKeyHashEd25519V0() [2]byte // AddrIDPubKeyHashSchnorrV0 returns the magic prefix bytes for version 0 // pay-to-pubkey-hash addresses where the underlying pubkey is secp256k1 and // the signature algorithm is Schnorr. AddrIDPubKeyHashSchnorrV0() [2]byte // AddrIDScriptHashV0 returns the magic prefix bytes for version 0 // pay-to-script-hash addresses. AddrIDScriptHashV0() [2]byte }
AddressParamsV0 defines an interface that is used to provide the parameters required when encoding and decoding addresses for version 0 scripts. These values are typically well-defined and unique per network.
type Error ¶ added in v0.13.6
Error identifies an address-related error.
It has full support for errors.Is and errors.As, so the caller can ascertain the specific reason for the error by checking the underlying error.