ecc

package
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 10, 2018 License: MIT Imports: 12 Imported by: 0

README

EOSIO Elliptic Curve Cryptography Wrapper

This is a simple wrapper for btcec, that handles the specificities of the format for keys in EOS.

It was crafted in reference to eosjs-ecc, eosjs-keygen and the C++ codebase of EOS.IO Software.

This handles the EOS prefix on public keys, manages the version and checksums in public and private keys.

Documentation

Index

Constants

View Source
const PublicKeyPrefix = "EOS"

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateKey

type PrivateKey struct {
	// contains filtered or unexported fields
}

func NewDeterministicPrivateKey

func NewDeterministicPrivateKey(randSource io.Reader) (*PrivateKey, error)

func NewPrivateKey

func NewPrivateKey(wif string) (*PrivateKey, error)

func NewRandomPrivateKey

func NewRandomPrivateKey() (*PrivateKey, error)

func (*PrivateKey) PublicKey

func (p *PrivateKey) PublicKey() PublicKey

func (*PrivateKey) Sign

func (p *PrivateKey) Sign(hash []byte) (Signature, error)

Sign signs a 32 bytes SHA256 hash..

func (*PrivateKey) String

func (p *PrivateKey) String() string

type PublicKey

type PublicKey []byte

func MustNewPublicKey

func MustNewPublicKey(pubKey string) PublicKey

func NewPublicKey

func NewPublicKey(pubKey string) (PublicKey, error)

func (PublicKey) Key

func (p PublicKey) Key() (*btcec.PublicKey, error)

func (PublicKey) MarshalBinary

func (p PublicKey) MarshalBinary() ([]byte, error)

func (PublicKey) MarshalJSON

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

func (PublicKey) String

func (p PublicKey) String() string

func (PublicKey) ToHex

func (p PublicKey) ToHex() string

func (*PublicKey) UnmarshalBinary

func (p *PublicKey) UnmarshalBinary(data []byte) (err error)

func (PublicKey) UnmarshalBinarySize

func (a PublicKey) UnmarshalBinarySize() int

func (*PublicKey) UnmarshalJSON

func (p *PublicKey) UnmarshalJSON(data []byte) error

type Signature

type Signature []byte

Signature represents a signature for some hash

func NewSignature

func NewSignature(fromText string) (Signature, error)

func (Signature) MarshalBinary

func (a Signature) MarshalBinary() ([]byte, error)

func (Signature) MarshalJSON

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

func (Signature) PublicKey

func (s Signature) PublicKey(hash []byte) (PublicKey, error)

PublicKey retrieves the public key, but requires the payload.. that's the way to validate the signature. Use Verify() if you only want to validate.

func (Signature) String

func (s Signature) String() string

func (*Signature) UnmarshalBinary

func (a *Signature) UnmarshalBinary(data []byte) error

func (*Signature) UnmarshalBinarySize

func (a *Signature) UnmarshalBinarySize() int

func (*Signature) UnmarshalJSON

func (a *Signature) UnmarshalJSON(data []byte) (err error)

func (Signature) Verify

func (s Signature) Verify(hash []byte, pubKey PublicKey) bool

Verify checks the signature against the pubKey. `hash` is a sha256 hash of the payload to verify.

Jump to

Keyboard shortcuts

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