Documentation
¶
Overview ¶
Huge thanks to the btcsuite developers for creating this code, which we adapted for our use in compliance with the Copyfree Initiative. btcsuite base58 repo: https://github.com/btcsuite/btcd/tree/master/btcutil/base58
AUTOGENERATED by gen_alphabet.go; do not edit.
Index ¶
- Constants
- Variables
- func Base58CheckDecode(input string) (result []byte, err error)
- func Base58CheckEncode(input []byte, prefix ...byte) string
- func Decode(b58string string, typePrefix []byte) ([]byte, error)
- func DecodeAccountPublicKey(key string) ([]byte, error)
- func DecodeBase58(b string) []byte
- func DecodeClassicAddressToAccountID(cAddress string) (typePrefix, accountID []byte, err error)
- func DecodeNodePublicKey(key string) ([]byte, error)
- func Encode(b []byte, typePrefix []byte, expectedLength int) string
- func EncodeAccountPublicKey(b []byte) (string, error)
- func EncodeBase58(b []byte) string
- func EncodeClassicAddressFromPublicKeyHex(pubkeyhex string) (types.Address, error)
- func EncodeNodePublicKey(b []byte) (string, error)
- func EncodeSeed(entropy []byte, encodingType CryptoAlgorithm) (string, error)
- func IsValidClassicAddress(cAddress string) bool
- func Sha256RipeMD160(b []byte) []byte
- type CryptoAlgorithm
- type EncodeLengthError
- type InvalidClassicAddressError
Constants ¶
const ( // Lengths in bytes AccountAddressLength = 20 AccountPublicKeyLength = 33 FamilySeedLength = 16 NodePublicKeyLength = 33 // Account/classic address prefix - value is 0 AccountAddressPrefix = 0x00 // Account public key prefix - value is 35 AccountPublicKeyPrefix = 0x23 // Family seed prefix - value is 33 FamilySeedPrefix = 0x21 // Node/validation public key prefix - value is 28 NodePublicKeyPrefix = 0x1C // ED25519 prefix - value is 237 ED25519Prefix = 0xED )
const ( Undefined CryptoAlgorithm = iota ED25519 = ED25519Prefix SECP256K1 = FamilySeedPrefix )
Variables ¶
var ( ErrChecksum = errors.New("checksum error") ErrInvalidFormat = errors.New("invalid format: version and/or checksum bytes missing") )
ErrChecksum indicates that the checksum of a check-encoded string does not verify against the checksum. ErrInvalidFormat indicates that the check-encoded string has an invalid format.
Functions ¶
func Base58CheckDecode ¶
CheckDecode decodes a string that was encoded with CheckEncode and verifies the checksum.
func Base58CheckEncode ¶
CheckEncode prepends a version byte, appends a four byte checksum and returns a base58 encoding of the byte slice.
func DecodeAccountPublicKey ¶
Returns the decoded account public key encoding as a byte slice from a base58 string.
func DecodeBase58 ¶
Decodes a modified base58 string to a byte slice.
func DecodeClassicAddressToAccountID ¶
Returns the decoded 'accountID' byte slice of the classic address.
func DecodeNodePublicKey ¶
Returns the decoded node public key encoding as a byte slice from a base58 string.
func Encode ¶
Returns the base58 encoding of byte slice, with the given type prefix, whilst ensuring that the byte slice is the expected length.
func EncodeAccountPublicKey ¶
Returns the account public key encoding of the byte slice as a base58 string.
func EncodeBase58 ¶
Encodes a byte slice to a base58 string encoded with the XRP alphabet.
func EncodeClassicAddressFromPublicKeyHex ¶
Returns the classic address from public key hex string.
func EncodeNodePublicKey ¶
Returns the node public key encoding of the byte slice as a base58 string.
func EncodeSeed ¶
func EncodeSeed(entropy []byte, encodingType CryptoAlgorithm) (string, error)
Returns a base58 encoding of a seed.
func IsValidClassicAddress ¶
func Sha256RipeMD160 ¶
Returns byte slice of a double hashed given byte slice. The given byte slice is SHA256 hashed, then the result is RIPEMD160 hashed.
Types ¶
type CryptoAlgorithm ¶
type CryptoAlgorithm uint8
func DecodeSeed ¶
func DecodeSeed(seed string) ([]byte, CryptoAlgorithm, error)
Returns decoded seed and its algorithm.
func (CryptoAlgorithm) String ¶
func (c CryptoAlgorithm) String() string
type EncodeLengthError ¶
func (*EncodeLengthError) Error ¶
func (e *EncodeLengthError) Error() string
type InvalidClassicAddressError ¶
type InvalidClassicAddressError struct {
Input string
}
func (*InvalidClassicAddressError) Error ¶
func (e *InvalidClassicAddressError) Error() string