common

package module
v0.0.0-...-b9de21a Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: LGPL-3.0 Imports: 11 Imported by: 43

Documentation

Index

Constants

View Source
const AddressSize = 14

AddressSize is 14 bytes

View Source
const CoordinateSize = 6

CoordinateSize is 6 bytes

View Source
const PublicHashSize = 31

PublicHashSize is 31 bytes

View Source
const PublicKeySize = 33

PublicKeySize is 33 bytes

View Source
const SignatureSize = 65

SignatureSize is 65 bytes

Variables

View Source
var (
	ErrInvalidAddressFormat         = errors.New("invalid address format")
	ErrInvalidAddressCheckSum       = errors.New("invalid address checksum")
	ErrInvalidCoordinateFormat      = errors.New("invalid coordinate format")
	ErrInvalidCoordinateBytesLength = errors.New("invalid coordinate bytes length")
	ErrInvalidSignatureFormat       = errors.New("invalid signature format")
	ErrInvalidSignature             = errors.New("invalid signature")
	ErrInvalidPublicKeyFormat       = errors.New("invalid public key format")
	ErrInvalidPublicHash            = errors.New("invalid public hash")
	ErrInvalidPublicHashFormat      = errors.New("invalid public hash format")
	ErrInsufficientSignature        = errors.New("insufficient signature")
	ErrDuplicatedSignature          = errors.New("duplicated signature")
)

common errors

Functions

func ValidateSignaturesMajority

func ValidateSignaturesMajority(signedHash hash.Hash256, sigs []Signature, KeyMap map[PublicHash]bool) error

ValidateSignaturesMajority validates signatures with the signed hash and checks majority

func VerifySignature

func VerifySignature(pubkey PublicKey, h hash.Hash256, sig Signature) error

VerifySignature checks the signature with the public key and the hash value

Types

type Address

type Address [AddressSize]byte

Address is the [AddressSize]byte with methods

func MustParseAddress

func MustParseAddress(str string) Address

MustParseAddress panic when error occurred

func NewAddress

func NewAddress(accCoord *Coordinate, nonce uint64) Address

NewAddress returns a Address by the AccountCoordinate, by the nonce

func ParseAddress

func ParseAddress(str string) (Address, error)

ParseAddress parse the address from the string

func (Address) Checksum

func (addr Address) Checksum() byte

Checksum returns the checksum byte

func (Address) Clone

func (addr Address) Clone() Address

Clone returns the clonend value of it

func (Address) Coordinate

func (addr Address) Coordinate() *Coordinate

Coordinate returns the coordinate of the address

func (Address) Equal

func (addr Address) Equal(b Address) bool

Equal checks that two values is same or not

func (Address) MarshalJSON

func (addr Address) MarshalJSON() ([]byte, error)

MarshalJSON is a marshaler function

func (*Address) ReadFrom

func (addr *Address) ReadFrom(r io.Reader) (int64, error)

ReadFrom is a deserialization function

func (Address) String

func (addr Address) String() string

String returns a base58 value of the address

func (*Address) UnmarshalJSON

func (addr *Address) UnmarshalJSON(bs []byte) error

UnmarshalJSON is a unmarshaler function

func (Address) WithNonce

func (addr Address) WithNonce(nonce uint64) Address

WithNonce returns derive the address using the nonce

func (Address) WriteTo

func (addr Address) WriteTo(w io.Writer) (int64, error)

WriteTo is a serialization function

type Coordinate

type Coordinate struct {
	Height uint32
	Index  uint16
}

Coordinate is (BlockHeight, TransactionIndexOfTheBlock)

func MustParseCoordinate

func MustParseCoordinate(str string) *Coordinate

MustParseCoordinate panic when error occurred

func NewCoordinate

func NewCoordinate(Height uint32, Index uint16) *Coordinate

NewCoordinate returns a Coordinate

func NewCoordinateByID

func NewCoordinateByID(id uint64) *Coordinate

NewCoordinateByID returns a Coordinate using compacted id

func ParseCoordinate

func ParseCoordinate(str string) (*Coordinate, error)

ParseCoordinate parse the public hash from the string

func (*Coordinate) Bytes

func (crd *Coordinate) Bytes() []byte

Bytes returns a byte array

func (*Coordinate) Clone

func (crd *Coordinate) Clone() *Coordinate

Clone returns the clonend value of it

func (*Coordinate) Equal

func (crd *Coordinate) Equal(b *Coordinate) bool

Equal checks that two values is same or not

func (*Coordinate) ID

func (crd *Coordinate) ID() uint64

ID returns a compacted id

func (*Coordinate) MarshalJSON

func (crd *Coordinate) MarshalJSON() ([]byte, error)

MarshalJSON is a marshaler function

func (*Coordinate) ReadFrom

func (crd *Coordinate) ReadFrom(r io.Reader) (int64, error)

ReadFrom is a deserialization function

func (*Coordinate) SetBytes

func (crd *Coordinate) SetBytes(bs []byte) error

SetBytes updates the coordinate using given bytes

func (*Coordinate) String

func (crd *Coordinate) String() string

String returns a hex value of the byte array

func (*Coordinate) UnmarshalJSON

func (crd *Coordinate) UnmarshalJSON(bs []byte) error

UnmarshalJSON is a unmarshaler function

func (*Coordinate) WriteTo

func (crd *Coordinate) WriteTo(w io.Writer) (int64, error)

WriteTo is a serialization function

type PublicHash

type PublicHash [PublicHashSize]byte

PublicHash is the [PublicHashSize]byte with methods

func MustParsePublicHash

func MustParsePublicHash(str string) PublicHash

MustParsePublicHash panic when error occurred

func NewPublicHash

func NewPublicHash(pubkey PublicKey) PublicHash

NewPublicHash returns the PublicHash of the pubkey

func ParsePublicHash

func ParsePublicHash(str string) (PublicHash, error)

ParsePublicHash parse the public hash from the string

func (PublicHash) Clone

func (pubhash PublicHash) Clone() PublicHash

Clone returns the clonend value of it

func (PublicHash) Equal

func (pubhash PublicHash) Equal(b PublicHash) bool

Equal checks that two values is same or not

func (PublicHash) Less

func (pubhash PublicHash) Less(b PublicHash) bool

Less returns the value is less or not

func (PublicHash) MarshalJSON

func (pubhash PublicHash) MarshalJSON() ([]byte, error)

MarshalJSON is a marshaler function

func (*PublicHash) ReadFrom

func (pubhash *PublicHash) ReadFrom(r io.Reader) (int64, error)

ReadFrom is a deserialization function

func (PublicHash) String

func (pubhash PublicHash) String() string

String returns a base58 value of the public hash

func (*PublicHash) UnmarshalJSON

func (pubhash *PublicHash) UnmarshalJSON(bs []byte) error

UnmarshalJSON is a unmarshaler function

func (PublicHash) WriteTo

func (pubhash PublicHash) WriteTo(w io.Writer) (int64, error)

WriteTo is a serialization function

type PublicKey

type PublicKey [PublicKeySize]byte

PublicKey is the [PublicKeySize]byte with methods

func MustParsePublicKey

func MustParsePublicKey(str string) PublicKey

MustParsePublicKey panic when error occurred

func ParsePublicKey

func ParsePublicKey(str string) (PublicKey, error)

ParsePublicKey parse the public hash from the string

func RecoverPubkey

func RecoverPubkey(h hash.Hash256, sig Signature) (PublicKey, error)

RecoverPubkey recover the public key using the hash value and the signature

func (PublicKey) Checksum

func (pubkey PublicKey) Checksum() byte

Checksum returns the checksum byte

func (PublicKey) Clone

func (pubkey PublicKey) Clone() PublicKey

Clone returns the clonend value of it

func (PublicKey) Equal

func (pubkey PublicKey) Equal(b PublicKey) bool

Equal checks that two values is same or not

func (PublicKey) MarshalJSON

func (pubkey PublicKey) MarshalJSON() ([]byte, error)

MarshalJSON is a marshaler function

func (*PublicKey) ReadFrom

func (pubkey *PublicKey) ReadFrom(r io.Reader) (int64, error)

ReadFrom is a deserialization function

func (PublicKey) String

func (pubkey PublicKey) String() string

String returns the hex string of the public key

func (*PublicKey) UnmarshalJSON

func (pubkey *PublicKey) UnmarshalJSON(bs []byte) error

UnmarshalJSON is a unmarshaler function

func (PublicKey) WriteTo

func (pubkey PublicKey) WriteTo(w io.Writer) (int64, error)

WriteTo is a serialization function

type Signature

type Signature [SignatureSize]byte

Signature is the [SignatureSize]byte with methods

func MustParseSignature

func MustParseSignature(str string) Signature

MustParseSignature panic when error occurred

func ParseSignature

func ParseSignature(str string) (Signature, error)

ParseSignature parse the public hash from the string

func (Signature) Clone

func (sig Signature) Clone() Signature

Clone returns the clonend value of it

func (Signature) Equal

func (sig Signature) Equal(b Signature) bool

Equal checks that two values is same or not

func (Signature) MarshalJSON

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

MarshalJSON is a marshaler function

func (*Signature) ReadFrom

func (sig *Signature) ReadFrom(r io.Reader) (int64, error)

ReadFrom is a deserialization function

func (Signature) String

func (sig Signature) String() string

String returns the hex string of the signature

func (*Signature) UnmarshalJSON

func (sig *Signature) UnmarshalJSON(bs []byte) error

UnmarshalJSON is a unmarshaler function

func (Signature) WriteTo

func (sig Signature) WriteTo(w io.Writer) (int64, error)

WriteTo is a serialization function

Directories

Path Synopsis
ethereum/crypto/secp256k1
Package secp256k1 wraps the bitcoin secp256k1 C library.
Package secp256k1 wraps the bitcoin secp256k1 C library.
ethereum/crypto/sha3
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.

Jump to

Keyboard shortcuts

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