strkey

package
v0.0.0-...-4b7be03 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package strkey is an implementation of StrKey, the address scheme for the AiBlocksNetwork.

Index

Constants

View Source
const (
	//VersionByteAccountID is the version byte used for encoded aiblocks addresses
	VersionByteAccountID VersionByte = 6 << 3 // Base32-encodes to 'G...'

	//VersionByteSeed is the version byte used for encoded aiblocks seed
	VersionByteSeed = 18 << 3 // Base32-encodes to 'S...'

	//VersionByteHashTx is the version byte used for encoded aiblocks hashTx
	//signer keys.
	VersionByteHashTx = 19 << 3 // Base32-encodes to 'T...'

	//VersionByteHashX is the version byte used for encoded aiblocks hashX
	//signer keys.
	VersionByteHashX = 23 << 3 // Base32-encodes to 'X...'
)

Variables

View Source
var ErrInvalidVersionByte = errors.New("invalid version byte")

ErrInvalidVersionByte is returned when the version byte from a provided strkey-encoded string is not one of the valid values.

Functions

func Decode

func Decode(expected VersionByte, src string) ([]byte, error)

Decode decodes the provided StrKey into a raw value, checking the checksum and ensuring the expected VersionByte (the version parameter) is the value actually encoded into the provided src string.

func Encode

func Encode(version VersionByte, src []byte) (string, error)

Encode encodes the provided data to a StrKey, using the provided version byte.

func IsValidEd25519PublicKey

func IsValidEd25519PublicKey(i interface{}) bool

IsValidEd25519PublicKey validates a aiblocks public key

func IsValidEd25519SecretSeed

func IsValidEd25519SecretSeed(i interface{}) bool

IsValidEd25519SecretSeed validates a aiblocks secret key

func MustDecode

func MustDecode(expected VersionByte, src string) []byte

MustDecode is like Decode, but panics on error

func MustEncode

func MustEncode(version VersionByte, src []byte) string

MustEncode is like Encode, but panics on error

Types

type VersionByte

type VersionByte byte

VersionByte represents one of the possible prefix values for a StrKey base string--the string the when encoded using base32 yields a final StrKey.

func DecodeAny

func DecodeAny(src string) (VersionByte, []byte, error)

DecodeAny decodes the provided StrKey into a raw value, checking the checksum and if the version byte is one of allowed values.

func Version

func Version(src string) (VersionByte, error)

Version extracts and returns the version byte from the provided source string.

Jump to

Keyboard shortcuts

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