account

package
v0.0.0-...-c187892 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2016 License: GPL-2.0, GPL-3.0, GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrivKeyTypeEd25519 = byte(0x01)
)

Types of PrivKey implementations

View Source
const (
	PubKeyTypeEd25519 = byte(0x01)
)

Types of PubKey implementations

View Source
const (
	SignatureTypeEd25519 = byte(0x01)
)

Types of Signature implementations

Variables

View Source
var AccountCodec = wire.Codec{
	Encode: AccountEncoder,
	Decode: AccountDecoder,
}

Functions

func AccountDecoder

func AccountDecoder(r io.Reader, n *int64, err *error) interface{}

func AccountEncoder

func AccountEncoder(o interface{}, w io.Writer, n *int64, err *error)

func GenPrivKeyBytesFromSecret

func GenPrivKeyBytesFromSecret(secret string) []byte

Generates 32 priv key bytes from secret

func HashSignBytes

func HashSignBytes(chainID string, o Signable) []byte

HashSignBytes is a convenience method for getting the hash of the bytes of a signable

func SignBytes

func SignBytes(chainID string, o Signable) []byte

SignBytes is a convenience method for getting the bytes to sign of a Signable.

Types

type Account

type Account struct {
	Address     []byte `json:"address"`
	PubKey      PubKey `json:"pub_key"`
	Sequence    int    `json:"sequence"`
	Balance     int64  `json:"balance"`
	Code        []byte `json:"code"`         // VM code
	StorageRoot []byte `json:"storage_root"` // VM storage merkle root.

	Permissions ptypes.AccountPermissions `json:"permissions"`
}

Account resides in the application state, and is mutated by transactions on the blockchain. Serialized by wire.[read|write]Reflect

func (*Account) Copy

func (acc *Account) Copy() *Account

func (*Account) String

func (acc *Account) String() string

type PrivAccount

type PrivAccount struct {
	Address []byte  `json:"address"`
	PubKey  PubKey  `json:"pub_key"`
	PrivKey PrivKey `json:"priv_key"`
}

func GenPrivAccount

func GenPrivAccount() *PrivAccount

Generates a new account with private key.

func GenPrivAccountFromPrivKeyBytes

func GenPrivAccountFromPrivKeyBytes(privKeyBytes []byte) *PrivAccount

func GenPrivAccountFromSecret

func GenPrivAccountFromSecret(secret string) *PrivAccount

Generates a new account with private key from SHA256 hash of a secret

func (*PrivAccount) Generate

func (pA *PrivAccount) Generate(index int) *PrivAccount

func (*PrivAccount) Sign

func (pA *PrivAccount) Sign(chainID string, o Signable) Signature

func (*PrivAccount) String

func (pA *PrivAccount) String() string

type PrivKey

type PrivKey interface {
	Sign(msg []byte) Signature
	PubKey() PubKey
}

PrivKey is part of PrivAccount and state.PrivValidator.

type PrivKeyEd25519

type PrivKeyEd25519 [64]byte

Implements PrivKey

func GenPrivKeyEd25519

func GenPrivKeyEd25519() PrivKeyEd25519

func (PrivKeyEd25519) Generate

func (key PrivKeyEd25519) Generate(index int) PrivKeyEd25519

Deterministically generates new priv-key bytes from key.

func (PrivKeyEd25519) PubKey

func (privKey PrivKeyEd25519) PubKey() PubKey

func (PrivKeyEd25519) Sign

func (key PrivKeyEd25519) Sign(msg []byte) Signature

func (PrivKeyEd25519) String

func (privKey PrivKeyEd25519) String() string

func (PrivKeyEd25519) ToCurve25519

func (privKey PrivKeyEd25519) ToCurve25519() *[32]byte

type PubKey

type PubKey interface {
	Address() []byte
	VerifyBytes(msg []byte, sig Signature) bool
}

PubKey is part of Account and Validator.

type PubKeyEd25519

type PubKeyEd25519 [32]byte

Implements PubKey

func (PubKeyEd25519) Address

func (pubKey PubKeyEd25519) Address() []byte

TODO: Slicing the array gives us length prefixing but loses the type byte. Revisit if we add more pubkey types. For now, we artificially append the type byte in front to give us backwards compatibility for when the pubkey wasn't fixed length array

func (PubKeyEd25519) Equals

func (pubKey PubKeyEd25519) Equals(other PubKey) bool

func (PubKeyEd25519) KeyString

func (pubKey PubKeyEd25519) KeyString() string

Must return the full bytes in hex. Used for map keying, etc.

func (PubKeyEd25519) String

func (pubKey PubKeyEd25519) String() string

func (PubKeyEd25519) ToCurve25519

func (pubKey PubKeyEd25519) ToCurve25519() *[32]byte

For use with golang/crypto/nacl/box If error, returns nil.

func (PubKeyEd25519) VerifyBytes

func (pubKey PubKeyEd25519) VerifyBytes(msg []byte, sig_ Signature) bool

TODO: Consider returning a reason for failure, or logging a runtime type mismatch.

type Signable

type Signable interface {
	WriteSignBytes(chainID string, w io.Writer, n *int64, err *error)
}

Signable is an interface for all signable things. It typically removes signatures before serializing.

type Signature

type Signature interface {
	IsZero() bool
	String() string
}

Signature is a part of Txs and consensus Votes.

type SignatureEd25519

type SignatureEd25519 [64]byte

Implements Signature

func (SignatureEd25519) IsZero

func (sig SignatureEd25519) IsZero() bool

func (SignatureEd25519) String

func (sig SignatureEd25519) String() string

Jump to

Keyboard shortcuts

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