secp256k1

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: LGPL-3.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const MessageLength = 32

MessageLength is the fixed Message Length

View Source
const PrivateKeyLength = 32

PrivateKeyLength is the fixed Private Key Length

View Source
const SignatureLength = 64

SignatureLength is the fixed Signature Length

Variables

This section is empty.

Functions

func RecoverPublicKey added in v0.3.0

func RecoverPublicKey(msg, sig []byte) ([]byte, error)

RecoverPublicKey returns the 64-byte uncompressed public key that created the given signature.

func RecoverPublicKeyCompressed added in v0.3.2

func RecoverPublicKeyCompressed(msg, sig []byte) ([]byte, error)

RecoverPublicKeyCompressed returns the 33-byte compressed public key that signed the given message.

Types

type Keypair

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

Keypair holds the pub,pk keys

func GenerateKeypair

func GenerateKeypair() (*Keypair, error)

GenerateKeypair will generate a Keypair

func NewKeypair

func NewKeypair(pk ecdsa.PrivateKey) *Keypair

NewKeypair will returned a Keypair from a PrivateKey

func NewKeypairFromPrivate

func NewKeypairFromPrivate(priv *PrivateKey) (*Keypair, error)

NewKeypairFromPrivate will return a Keypair for a PrivateKey

func NewKeypairFromPrivateKeyString added in v0.2.0

func NewKeypairFromPrivateKeyString(in string) (*Keypair, error)

NewKeypairFromPrivateKeyString returns a Keypair given a 0x prefixed private key string

func (*Keypair) Private

func (kp *Keypair) Private() crypto.PrivateKey

Private returns pk

func (*Keypair) Public

func (kp *Keypair) Public() crypto.PublicKey

Public returns the pub key

func (*Keypair) Sign

func (kp *Keypair) Sign(msg []byte) ([]byte, error)

Sign will sign

func (*Keypair) Type added in v0.2.0

func (kp *Keypair) Type() crypto.KeyType

Type returns Secp256k1Type

type PrivateKey

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

PrivateKey struct for PrivateKey

func NewPrivateKey

func NewPrivateKey(in []byte) (*PrivateKey, error)

NewPrivateKey will return a PrivateKey for a []byte

func (*PrivateKey) Decode

func (pk *PrivateKey) Decode(in []byte) error

Decode will decode

func (*PrivateKey) Encode

func (pk *PrivateKey) Encode() []byte

Encode will encode

func (*PrivateKey) Hex

func (pk *PrivateKey) Hex() string

Hex will return PrivateKey Hex

func (*PrivateKey) Public

func (pk *PrivateKey) Public() (crypto.PublicKey, error)

Public will return pub key

func (*PrivateKey) Sign

func (pk *PrivateKey) Sign(msg []byte) ([]byte, error)

Sign a message

type PublicKey

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

PublicKey struct for PublicKey

func (*PublicKey) Address

func (k *PublicKey) Address() common.Address

Address will return PublicKey Address

func (*PublicKey) Decode

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

Decode will decode to PublicKey key field

func (*PublicKey) Encode

func (k *PublicKey) Encode() []byte

Encode will encode to []byte

func (*PublicKey) Hex

func (k *PublicKey) Hex() string

Hex will return PublicKey Hex

func (*PublicKey) UnmarshalPubkey added in v0.3.0

func (k *PublicKey) UnmarshalPubkey(pub []byte) error

UnmarshalPubkey converts [65]byte to a secp256k1 public key.

func (*PublicKey) Verify

func (k *PublicKey) Verify(msg, sig []byte) (bool, error)

Verify a msg

Jump to

Keyboard shortcuts

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