addresscodec

package
v0.0.0-...-9abe75c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 7 Imported by: 0

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

View Source
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
)
View Source
const (
	Undefined CryptoAlgorithm = iota
	ED25519                   = ED25519Prefix
	SECP256K1                 = FamilySeedPrefix
)

Variables

View Source
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

func Base58CheckDecode(input string) (result []byte, err error)

CheckDecode decodes a string that was encoded with CheckEncode and verifies the checksum.

func Base58CheckEncode

func Base58CheckEncode(input []byte, prefix ...byte) string

CheckEncode prepends a version byte, appends a four byte checksum and returns a base58 encoding of the byte slice.

func Decode

func Decode(b58string string, typePrefix []byte) ([]byte, error)

Returns the byte slice decoding of the base58-encoded string and prefix.

func DecodeAccountPublicKey

func DecodeAccountPublicKey(key string) ([]byte, error)

Returns the decoded account public key encoding as a byte slice from a base58 string.

func DecodeBase58

func DecodeBase58(b string) []byte

Decodes a modified base58 string to a byte slice.

func DecodeClassicAddressToAccountID

func DecodeClassicAddressToAccountID(cAddress string) (typePrefix, accountID []byte, err error)

Returns the decoded 'accountID' byte slice of the classic address.

func DecodeNodePublicKey

func DecodeNodePublicKey(key string) ([]byte, error)

Returns the decoded node public key encoding as a byte slice from a base58 string.

func Encode

func Encode(b []byte, typePrefix []byte, expectedLength int) string

Returns the base58 encoding of byte slice, with the given type prefix, whilst ensuring that the byte slice is the expected length.

func EncodeAccountPublicKey

func EncodeAccountPublicKey(b []byte) (string, error)

Returns the account public key encoding of the byte slice as a base58 string.

func EncodeBase58

func EncodeBase58(b []byte) string

Encodes a byte slice to a base58 string encoded with the XRP alphabet.

func EncodeClassicAddressFromPublicKeyHex

func EncodeClassicAddressFromPublicKeyHex(pubkeyhex string) (string, error)

Returns the classic address from public key hex string.

func EncodeNodePublicKey

func EncodeNodePublicKey(b []byte) (string, error)

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 IsValidClassicAddress(cAddress string) bool

func Sha256RipeMD160

func Sha256RipeMD160(b []byte) []byte

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

type EncodeLengthError struct {
	Instance string
	Input    int
	Expected int
}

func (*EncodeLengthError) Error

func (e *EncodeLengthError) Error() string

type InvalidClassicAddressError

type InvalidClassicAddressError struct {
	Input string
}

func (*InvalidClassicAddressError) Error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL