types

package
v0.0.0-...-85b665a Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2018 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const EncodeXrb = "13456789abcdefghijkmnopqrstuwxyz"

Variables

View Source
var WorkThreshold = uint64(0xffffffc000000000)

Functions

func GenerateKey

func GenerateKey(rd io.Reader) (PubKey, PrvKey, error)

func KeypairFromPrvKey

func KeypairFromPrvKey(key PrvKey) (PubKey, PrvKey, error)

func KeypairFromSeed

func KeypairFromSeed(seed PrvKey, index uint32) (PubKey, PrvKey, error)

func Reversed

func Reversed(str []byte) (result []byte)

func ValidateAddress

func ValidateAddress(addr string) bool

Types

type BlockHash

type BlockHash [32]byte

func BlockHashFromSlice

func BlockHashFromSlice(data []byte) BlockHash

func BlockHashFromString

func BlockHashFromString(s string) (BlockHash, error)

func (BlockHash) IsZero

func (h BlockHash) IsZero() bool

func (BlockHash) MarshalJSON

func (h BlockHash) MarshalJSON() ([]byte, error)

func (BlockHash) Sign

func (h BlockHash) Sign(prv ed25519.PrivateKey) Signature

func (BlockHash) Slice

func (h BlockHash) Slice() []byte

func (BlockHash) String

func (h BlockHash) String() string

func (*BlockHash) UnmarshalJSON

func (h *BlockHash) UnmarshalJSON(data []byte) error

type PrvKey

type PrvKey ed25519.PrivateKey

func PrvKeyFromSlice

func PrvKeyFromSlice(data []byte) PrvKey

func PrvKeyFromString

func PrvKeyFromString(data string) (PrvKey, error)

func (PrvKey) Equal

func (k PrvKey) Equal(o PrvKey) bool

func (PrvKey) MarshalJSON

func (k PrvKey) MarshalJSON() ([]byte, error)

func (PrvKey) Sign

func (k PrvKey) Sign(data []byte) Signature

func (PrvKey) String

func (k PrvKey) String() string

func (*PrvKey) UnmarshalJSON

func (k *PrvKey) UnmarshalJSON(data []byte) error

type PubKey

type PubKey ed25519.PublicKey

func PubKeyFromAddress

func PubKeyFromAddress(addr string) (PubKey, error)

func PubKeyFromHex

func PubKeyFromHex(s string) (PubKey, error)

func PubKeyFromSlice

func PubKeyFromSlice(data []byte) PubKey

func (PubKey) Address

func (a PubKey) Address() string

func (PubKey) Checksum

func (a PubKey) Checksum() []byte

func (PubKey) Equal

func (a PubKey) Equal(o PubKey) bool

func (PubKey) Hex

func (a PubKey) Hex() string

func (PubKey) MarshalJSON

func (a PubKey) MarshalJSON() ([]byte, error)

func (*PubKey) UnmarshalJSON

func (a *PubKey) UnmarshalJSON(data []byte) error

type Signature

type Signature [64]byte

func NewSignature

func NewSignature(str string) (Signature, error)

func SignatureFromSlice

func SignatureFromSlice(data []byte) Signature

func (Signature) MarshalJSON

func (s Signature) MarshalJSON() ([]byte, error)

func (Signature) Slice

func (s Signature) Slice() []byte

func (Signature) String

func (s Signature) String() string

func (*Signature) UnmarshalJSON

func (s *Signature) UnmarshalJSON(data []byte) error

type Work

type Work [8]byte

func GenerateWorkForHash

func GenerateWorkForHash(b BlockHash) Work

func WorkFromSlice

func WorkFromSlice(b []byte) Work

func WorkFromString

func WorkFromString(s string) (Work, error)

func (Work) MarshalJSON

func (w Work) MarshalJSON() ([]byte, error)

func (Work) Slice

func (w Work) Slice() []byte

func (Work) String

func (w Work) String() string

func (*Work) UnmarshalJSON

func (w *Work) UnmarshalJSON(data []byte) error

func (Work) Validate

func (w Work) Validate(blockHash BlockHash) bool

ValidateWork takes the "work" value (little endian from hex) and block hash and verifies that the work passes the difficulty. To verify this, we create a new 8 byte hash of the work and the block hash and convert this to a uint64 which must be higher (or equal) than the difficulty (0xffffffc000000000) to be valid.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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