ecc

package
v0.0.0-...-8f1dc17 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 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 (
	CurveK1 = CurveID(iota)
	CurveR1
)
View Source
const PrivateKeyPrefix = "PVT_"
View Source
const PublicKeyK1Prefix = "PUB_K1_"
View Source
const PublicKeyPrefix = "PUB_"
View Source
const PublicKeyPrefixCompat = "EOS"
View Source
const PublicKeyR1Prefix = "PUB_R1_"

Variables

View Source
var TypePubKey = reflect.TypeOf(PublicKey{})

Functions

func ComparePubKey

func ComparePubKey(first interface{}, second interface{}) int

func Ripemd160checksumHashCurve

func Ripemd160checksumHashCurve(in []byte, curve CurveID) []byte

Types

type CurveID

type CurveID uint8

func (CurveID) String

func (c CurveID) String() string

func (CurveID) StringPrefix

func (c CurveID) StringPrefix() string

type PrivateKey

type PrivateKey struct {
	Curve CurveID
	// 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) MarshalJSON

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

func (*PrivateKey) PublicKey

func (p *PrivateKey) PublicKey() PublicKey

func (*PrivateKey) Serialize

func (p *PrivateKey) Serialize() []byte

func (*PrivateKey) Sign

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

Sign signs a 32 bytes SHA256 hash..

func (*PrivateKey) String

func (p *PrivateKey) String() string

func (*PrivateKey) UnmarshalJSON

func (p *PrivateKey) UnmarshalJSON(v []byte) (err error)

type PublicKey

type PublicKey struct {
	Curve   CurveID
	Content [33]byte
	// contains filtered or unexported fields
}

func MustNewPublicKey

func MustNewPublicKey(pubKey string) PublicKey

func MustNewPublicKeyFromData

func MustNewPublicKeyFromData(data []byte) PublicKey

func NewPublicKey

func NewPublicKey(pubKey string) (out PublicKey, err error)

func NewPublicKeyFromData

func NewPublicKeyFromData(data []byte) (out PublicKey, err error)

func NewPublicKeyNil

func NewPublicKeyNil() *PublicKey

func (PublicKey) Compare

func (p PublicKey) Compare(pub PublicKey) bool

func (PublicKey) IsEmpty

func (p PublicKey) IsEmpty() bool

func (PublicKey) Key

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

func (PublicKey) MarshalJSON

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

func (PublicKey) Pack

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

func (PublicKey) String

func (p PublicKey) String() string

func (*PublicKey) UnmarshalJSON

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

func (*PublicKey) Unpack

func (p *PublicKey) Unpack(in []byte) (l int, err error)

func (PublicKey) Valid

func (p PublicKey) Valid() bool

type Signature

type Signature struct {
	Curve   CurveID
	Content []byte // the Compact signature as bytes
	// contains filtered or unexported fields
}

Signature represents a signature for some hash

func MustNewSignatureFromData

func MustNewSignatureFromData(data []byte) Signature

func NewSigNil

func NewSigNil() *Signature

func NewSignature

func NewSignature(fromText string) (Signature, error)

func NewSignatureFromData

func NewSignatureFromData(data []byte) (Signature, error)

func (Signature) IsEmpty

func (s Signature) IsEmpty() bool

func (Signature) MarshalJSON

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

func (Signature) Pack

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

func (Signature) PublicKey

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

func (Signature) String

func (s Signature) String() string

func (*Signature) UnmarshalJSON

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

func (*Signature) Unpack

func (s *Signature) Unpack(in []byte) (l int, err error)

func (Signature) Verify

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

Jump to

Keyboard shortcuts

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