keypair

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2019 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidKey is the error that the key format is invalid
	ErrInvalidKey = errors.New("invalid key format")
	// ErrPublicKey indicates the error of public key
	ErrPublicKey = errors.New("invalid public key")
	// ErrPrivateKey indicates the error of private key
	ErrPrivateKey = errors.New("invalid private key")
)

Functions

func StringToPubKeyBytes

func StringToPubKeyBytes(pubKey string) ([]byte, error)

StringToPubKeyBytes converts a string of public key to byte slice

Types

type PrivateKey

type PrivateKey interface {
	Bytes() []byte
	HexString() string
	EcdsaPrivateKey() *ecdsa.PrivateKey
	PublicKey() PublicKey
	Sign([]byte) ([]byte, error)
	Zero()
}

PrivateKey represents a private key

func BytesToPrivateKey

func BytesToPrivateKey(prvKey []byte) (PrivateKey, error)

BytesToPrivateKey converts a byte slice to SECP256K1 PrivateKey

func GenerateKey added in v0.5.0

func GenerateKey() (PrivateKey, error)

GenerateKey generates a SECP256K1 PrivateKey

func HexStringToPrivateKey added in v0.5.0

func HexStringToPrivateKey(prvKey string) (PrivateKey, error)

HexStringToPrivateKey decodes a string to SECP256K1 PrivateKey

func KeystoreToPrivateKey added in v0.5.0

func KeystoreToPrivateKey(account accounts.Account, password string) (PrivateKey, error)

KeystoreToPrivateKey generates PrivateKey from Keystore account

type PublicKey

type PublicKey interface {
	Bytes() []byte
	HexString() string
	EcdsaPublicKey() *ecdsa.PublicKey
	Hash() []byte
	Verify([]byte, []byte) bool
}

PublicKey represents a public key

func BytesToPublicKey

func BytesToPublicKey(pubKey []byte) (PublicKey, error)

BytesToPublicKey converts a byte slice to SECP256K1 PublicKey

func HexStringToPublicKey added in v0.5.0

func HexStringToPublicKey(pubKey string) (PublicKey, error)

HexStringToPublicKey decodes a string to SECP256K1 PublicKey

Jump to

Keyboard shortcuts

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