common

package
v0.0.0-...-a8cc34e Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2020 License: LGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const AddressSize = 14

AddressSize is 14 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")
	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(height uint32, index uint16, magic uint64) Address

NewAddress returns a Address by the AccountCoordinate and the magic

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) Height

func (addr Address) Height() uint32

Height returns the height of the address created

func (Address) Index

func (addr Address) Index() uint16

Index returns the index of the address created

func (Address) MarshalJSON

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

MarshalJSON is a marshaler function

func (Address) Nonce

func (addr Address) Nonce() uint64

Nonce returns the nonce of the address created

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

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) 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) 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

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) MarshalJSON

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

MarshalJSON is a marshaler 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

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) MarshalJSON

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

MarshalJSON is a marshaler 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

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