ecdsa

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(opt AlgorithmOption) (crypto.PrivateKey, error)

GenerateKey generate a pair of key,input is algorithm type

func Unmarshal

func Unmarshal(data []byte) (crypto.PrivateKey, error)

func UnmarshalPrivateKey

func UnmarshalPrivateKey(data []byte, opt AlgorithmOption) (crypto.PrivateKey, error)

func UnmarshalPublicKey

func UnmarshalPublicKey(data []byte, opt AlgorithmOption) (crypto.PublicKey, error)

Types

type AlgorithmOption

type AlgorithmOption string
const (
	// Secp256k1 secp256k1 algorithm
	Secp256k1 AlgorithmOption = "Secp256k1"
	// Secp256r1 secp256r1 algorithm
	Secp256r1 AlgorithmOption = "Secp256r1"
)

type PrivateKey

type PrivateKey struct {
	K *ecdsa.PrivateKey
}

PrivateKey ECDSA private key. never new(PrivateKey), use NewPrivateKey()

func (*PrivateKey) Bytes

func (priv *PrivateKey) Bytes() ([]byte, error)

Bytes returns a serialized, storable representation of this key

func (*PrivateKey) PublicKey

func (priv *PrivateKey) PublicKey() crypto.PublicKey

func (*PrivateKey) Sign

func (priv *PrivateKey) Sign(digest []byte) ([]byte, error)

type PublicKey

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

PublicKey ECDSA public key. never new(PublicKey), use NewPublicKey()

func (*PublicKey) Address

func (pub *PublicKey) Address() (common.Address, error)

func (*PublicKey) Bytes

func (pub *PublicKey) Bytes() ([]byte, error)

func (*PublicKey) Verify

func (pub *PublicKey) Verify(digest []byte, sig []byte) (bool, error)

type Sig

type Sig struct {
	R, S *big.Int
}

ECDSASig holds the r and s values of an ECDSA signature

Jump to

Keyboard shortcuts

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