secp256k1

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2018 License: LGPL-3.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidMsgLen invalid message length
	ErrInvalidMsgLen = errors.New("invalid message length, need 32 bytes")

	// ErrInvalidSignature invalid signature length
	ErrInvalidSignature = errors.New("invalid signature")

	// ErrInvalidPrivateKey invalid private key
	ErrInvalidPrivateKey = errors.New("invalid private key")

	// ErrInvalidPublicKey invalid public key
	ErrInvalidPublicKey = errors.New("invalid public key")

	// ErrSignFailed sign failed
	ErrSignFailed = errors.New("sign failed")

	// ErrRecoverFailed recover failed
	ErrRecoverFailed = errors.New("recovery failed")
)

Functions

func FromECDSAPrivateKey

func FromECDSAPrivateKey(priv *ecdsa.PrivateKey) ([]byte, error)

FromECDSAPrivateKey exports a private key into a binary dump.

func FromECDSAPublicKey

func FromECDSAPublicKey(pub *ecdsa.PublicKey) ([]byte, error)

FromECDSAPublicKey exports a public key into a binary dump.

func HexToECDSAPrivateKey

func HexToECDSAPrivateKey(hexkey string) (*ecdsa.PrivateKey, error)

HexToECDSAPrivateKey parses a secp256k1 private key.

func NewECDSAPrivateKey

func NewECDSAPrivateKey() *ecdsa.PrivateKey

NewECDSAPrivateKey generate a ecdsa private key

func RecoverECDSAPublicKey

func RecoverECDSAPublicKey(msg []byte, signature []byte) (*ecdsa.PublicKey, error)

RecoverECDSAPublicKey recover verifies the compact signature "signature" of "hash"

func S256

func S256() elliptic.Curve

S256 returns an instance of the secp256k1 curve.

func SeckeyVerify added in v1.0.0

func SeckeyVerify(priv *ecdsa.PrivateKey) bool

SeckeyVerify check private is ok for secp256k1

func Sign

func Sign(msg []byte, priv *ecdsa.PrivateKey) ([]byte, error)

Sign sign hash with private key

func ToECDSAPrivateKey

func ToECDSAPrivateKey(d []byte) (*ecdsa.PrivateKey, error)

ToECDSAPrivateKey creates a private key with the given data value.

func ToECDSAPublicKey

func ToECDSAPublicKey(pub []byte) (*ecdsa.PublicKey, error)

ToECDSAPublicKey creates a public key with the given data value.

func Verify

func Verify(msg []byte, signature []byte, pub *ecdsa.PublicKey) (bool, error)

Verify verify with public key

Types

type PrivateKey

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

PrivateKey ecdsa privatekey

func GeneratePrivateKey

func GeneratePrivateKey() *PrivateKey

GeneratePrivateKey generate a new private key

func NewPrivateKey added in v1.0.0

func NewPrivateKey(key *ecdsa.PrivateKey) *PrivateKey

NewPrivateKey new a private key with ecdsa.PrivateKey

func (*PrivateKey) Algorithm

func (k *PrivateKey) Algorithm() keystore.Algorithm

Algorithm algorithm name

func (*PrivateKey) Clear

func (k *PrivateKey) Clear()

Clear clear key content

func (*PrivateKey) Decode

func (k *PrivateKey) Decode(data []byte) error

Decode decode data to key

func (*PrivateKey) Encoded

func (k *PrivateKey) Encoded() ([]byte, error)

Encoded encoded to byte

func (*PrivateKey) PublicKey

func (k *PrivateKey) PublicKey() keystore.PublicKey

PublicKey returns publickey

func (*PrivateKey) Sign

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

Sign sign hash with privatekey

type PublicKey

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

PublicKey ecdsa publickey

func NewPublicKey

func NewPublicKey(pub ecdsa.PublicKey) *PublicKey

NewPublicKey generate PublicKey

func (*PublicKey) Algorithm

func (k *PublicKey) Algorithm() keystore.Algorithm

Algorithm algorithm name

func (*PublicKey) Clear

func (k *PublicKey) Clear()

Clear clear key content

func (*PublicKey) Decode

func (k *PublicKey) Decode(data []byte) error

Decode decode data to key

func (*PublicKey) Encoded

func (k *PublicKey) Encoded() ([]byte, error)

Encoded encoded to byte

func (*PublicKey) Verify

func (k *PublicKey) Verify(hash []byte, signature []byte) (bool, error)

Verify verify ecdsa publickey

type Signature

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

Signature signature ecdsa

func (*Signature) Algorithm

func (s *Signature) Algorithm() keystore.Algorithm

Algorithm secp256k1 algorithm

func (*Signature) InitSign

func (s *Signature) InitSign(priv keystore.PrivateKey) error

InitSign ecdsa init sign

func (*Signature) InitVerify

func (s *Signature) InitVerify(pub keystore.PublicKey) error

InitVerify ecdsa verify init

func (*Signature) RecoverPublic

func (s *Signature) RecoverPublic(data []byte, signature []byte) (keystore.PublicKey, error)

RecoverPublic returns a public key

func (*Signature) Sign

func (s *Signature) Sign(data []byte) (out []byte, err error)

Sign ecdsa sign

func (*Signature) Verify

func (s *Signature) Verify(data []byte, signature []byte) (bool, error)

Verify ecdsa verify

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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