Documentation
¶
Index ¶
- Constants
- Variables
- func ValidateSignaturesMajority(signedHash hash.Hash256, sigs []Signature, KeyMap map[PublicHash]bool) error
- func VerifySignature(pubkey PublicKey, h hash.Hash256, sig Signature) error
- type Address
- func (addr Address) Checksum() byte
- func (addr Address) Clone() Address
- func (addr Address) Coordinate() *Coordinate
- func (addr Address) Equal(b Address) bool
- func (addr Address) MarshalJSON() ([]byte, error)
- func (addr *Address) ReadFrom(r io.Reader) (int64, error)
- func (addr Address) String() string
- func (addr *Address) UnmarshalJSON(bs []byte) error
- func (addr Address) WithNonce(nonce uint64) Address
- func (addr Address) WriteTo(w io.Writer) (int64, error)
- type Coordinate
- func (crd *Coordinate) Bytes() []byte
- func (crd *Coordinate) Clone() *Coordinate
- func (crd *Coordinate) Equal(b *Coordinate) bool
- func (crd *Coordinate) ID() uint64
- func (crd *Coordinate) MarshalJSON() ([]byte, error)
- func (crd *Coordinate) ReadFrom(r io.Reader) (int64, error)
- func (crd *Coordinate) SetBytes(bs []byte) error
- func (crd *Coordinate) String() string
- func (crd *Coordinate) UnmarshalJSON(bs []byte) error
- func (crd *Coordinate) WriteTo(w io.Writer) (int64, error)
- type PublicHash
- func (pubhash PublicHash) Clone() PublicHash
- func (pubhash PublicHash) Equal(b PublicHash) bool
- func (pubhash PublicHash) Less(b PublicHash) bool
- func (pubhash PublicHash) MarshalJSON() ([]byte, error)
- func (pubhash *PublicHash) ReadFrom(r io.Reader) (int64, error)
- func (pubhash PublicHash) String() string
- func (pubhash *PublicHash) UnmarshalJSON(bs []byte) error
- func (pubhash PublicHash) WriteTo(w io.Writer) (int64, error)
- type PublicKey
- func (pubkey PublicKey) Checksum() byte
- func (pubkey PublicKey) Clone() PublicKey
- func (pubkey PublicKey) Equal(b PublicKey) bool
- func (pubkey PublicKey) MarshalJSON() ([]byte, error)
- func (pubkey *PublicKey) ReadFrom(r io.Reader) (int64, error)
- func (pubkey PublicKey) String() string
- func (pubkey *PublicKey) UnmarshalJSON(bs []byte) error
- func (pubkey PublicKey) WriteTo(w io.Writer) (int64, error)
- type Signature
- func (sig Signature) Clone() Signature
- func (sig Signature) Equal(b Signature) bool
- func (sig Signature) MarshalJSON() ([]byte, error)
- func (sig *Signature) ReadFrom(r io.Reader) (int64, error)
- func (sig Signature) String() string
- func (sig *Signature) UnmarshalJSON(bs []byte) error
- func (sig Signature) WriteTo(w io.Writer) (int64, error)
Constants ¶
const AddressSize = 14
AddressSize is 14 bytes
const CoordinateSize = 6
CoordinateSize is 6 bytes
const PublicHashSize = 31
PublicHashSize is 31 bytes
const PublicKeySize = 33
PublicKeySize is 33 bytes
const SignatureSize = 65
SignatureSize is 65 bytes
Variables ¶
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
Types ¶
type Address ¶
type Address [AddressSize]byte
Address is the [AddressSize]byte with methods
func MustParseAddress ¶
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 ¶
ParseAddress parse the address from the string
func (Address) Coordinate ¶
func (addr Address) Coordinate() *Coordinate
Coordinate returns the coordinate of the address
func (Address) MarshalJSON ¶
MarshalJSON is a marshaler function
func (*Address) UnmarshalJSON ¶
UnmarshalJSON is a unmarshaler function
type Coordinate ¶
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) 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) 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
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
type PublicKey ¶
type PublicKey [PublicKeySize]byte
PublicKey is the [PublicKeySize]byte with methods
func MustParsePublicKey ¶
MustParsePublicKey panic when error occurred
func ParsePublicKey ¶
ParsePublicKey parse the public hash from the string
func RecoverPubkey ¶
RecoverPubkey recover the public key using the hash value and the signature
func (PublicKey) MarshalJSON ¶
MarshalJSON is a marshaler function
func (*PublicKey) UnmarshalJSON ¶
UnmarshalJSON is a unmarshaler function
type Signature ¶
type Signature [SignatureSize]byte
Signature is the [SignatureSize]byte with methods
func MustParseSignature ¶
MustParseSignature panic when error occurred
func ParseSignature ¶
ParseSignature parse the public hash from the string
func (Signature) MarshalJSON ¶
MarshalJSON is a marshaler function
func (*Signature) UnmarshalJSON ¶
UnmarshalJSON is a unmarshaler function
Source Files
¶
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. |