crypto

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

View Source
const (
	SignatureTypeTreasury byte = 0
	SignatureTypeBLS      byte = 1
)
View Source
const (
	AddressSize = 21
)

Variables

View Source
var (
	// Human Readable Part (HRP) for address
	AddressHRP = "pc"
	// Human Readable Part (HRP) for public key
	PublicKeyHRP = "public"
	// Human Readable Part (HRP) for private key
	PrivateKeyHRP = "secret"
	// Human Readable Part (HRP) for extended public key
	XPublicKeyHRP = "xpublic"
	// Human Readable Part (HRP) for extended private key
	XPrivateKeyHRP = "xsecret"
)
View Source
var TreasuryAddress = Address{0}

Functions

This section is empty.

Types

type Address

type Address [AddressSize]byte

func AddressFromString

func AddressFromString(text string) (Address, error)

AddressFromString decodes the string encoding of an address and returns the Address if text is a valid encoding for a known address type.

func (Address) Bytes

func (addr Address) Bytes() []byte

Bytes returns the 21 bytes of the address data.

func (Address) EqualsTo

func (addr Address) EqualsTo(right Address) bool

func (Address) Fingerprint

func (addr Address) Fingerprint() string

Fingerprint returns a short string for the address useful for logger.

func (*Address) SanityCheck

func (addr *Address) SanityCheck() error

func (Address) String

func (addr Address) String() string

String returns a human-readable string for the address.

type PrivateKey

type PrivateKey interface {
	Bytes() []byte
	String() string
	Sign(msg []byte) Signature
	PublicKey() PublicKey
	EqualsTo(right PrivateKey) bool
}

type PublicKey

type PublicKey interface {
	Bytes() []byte
	String() string
	MarshalCBOR() ([]byte, error)
	UnmarshalCBOR([]byte) error
	Encode(io.Writer) error
	Decode(io.Reader) error
	Address() Address
	Verify(msg []byte, sig Signature) error
	VerifyAddress(addr Address) error
	EqualsTo(right PublicKey) bool
}

type SignableMsg

type SignableMsg interface {
	SignBytes() []byte
	SetSignature(sig Signature)
	SetPublicKey(pub PublicKey)
}

type Signature

type Signature interface {
	Bytes() []byte
	String() string
	MarshalCBOR() ([]byte, error)
	UnmarshalCBOR([]byte) error
	Encode(io.Writer) error
	Decode(io.Reader) error
	EqualsTo(right Signature) bool
}

type Signer

type Signer interface {
	Address() Address
	PublicKey() PublicKey
	SignData(data []byte) Signature
	SignMsg(msg SignableMsg)
}

func NewSigner

func NewSigner(pv PrivateKey) Signer

Directories

Path Synopsis
bls

Jump to

Keyboard shortcuts

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