account

package
v0.0.0-...-eb21b60 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PrivateKeyCurve = elliptic.P256()

PrivateKeyCurve is the elliptic curve in use for private key creation.

Functions

func NewAddressTree

func NewAddressTree() *btree.BTree

Types

type Account

type Account interface {
	PublicKeyBytes() []byte
	Address() []byte
	Verify(data, signature []byte) bool
}

Account is a generic interface to an account that can send and receive funding.

type AddressTreeItem

type AddressTreeItem struct {
	Address []byte
	Account Account
	Funds   uint64
}

func (AddressTreeItem) Less

func (item AddressTreeItem) Less(than btree.Item) bool

type Private

type Private struct {
	// contains filtered or unexported fields
}

Private is a private account. A private account can verify and sign transactions.

func NewPrivate

func NewPrivate() *Private

NewPrivate generates a new private-public key pair bound to an account.

func NewPrivateFromBytes

func NewPrivateFromBytes(key []byte) *Private

NewPrivateFromBytes restores the private key from a slice of bytes.

func (*Private) Address

func (a *Private) Address() []byte

Address returns the hashed public-key address.

func (*Private) Bytes

func (a *Private) Bytes() []byte

Bytes generates a byte-representation of the private key.

func (*Private) PublicKeyBytes

func (a *Private) PublicKeyBytes() []byte

PublicKeyBytes retrieves the private keys public pair in a binary format.

func (*Private) Sign

func (a *Private) Sign(hash []byte) []byte

Sign generates a signature for the given hash.

func (*Private) String

func (a *Private) String() string

String generates a human-readable address for this private key.

func (*Private) Verify

func (a *Private) Verify(hash, signature []byte) bool

Verify checks the validity of the signature on the hash.

type Public

type Public struct {
	// contains filtered or unexported fields
}

Public is a public account. Public accounts can only verify transactions.

func NewPublic

func NewPublic(key []byte) *Public

NewPublic instantiates a new public account (key) from the given byte slice.

func (*Public) Address

func (a *Public) Address() []byte

Address gets the accounts verifiable address.

func (*Public) PublicKeyBytes

func (a *Public) PublicKeyBytes() []byte

PublicKeyBytes retrieves the public key in a binary format.

func (*Public) String

func (a *Public) String() string

String generates a human-readable address.

func (*Public) Verify

func (a *Public) Verify(hash, signature []byte) bool

Verify checks the validity of the signature on the given hash.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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