key

package
v0.0.0-...-24e5678 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownKeyType = errors.New("unknown key")
)

key errors

Functions

This section is empty.

Types

type Key

type Key interface {
	Sign(h hash.Hash256) (common.Signature, error)
	SignWithPassphrase(h hash.Hash256, passphrase []byte) (common.Signature, error)
	Verify(h hash.Hash256, sig common.Signature) bool
	PublicKey() common.PublicKey
	PrivateKey() *ecdsa.PrivateKey
	Clear()
}

Key defines crypto key functions

type MemoryKey

type MemoryKey struct {
	PrivKey *ecdsa.PrivateKey

	ChainID *big.Int
	// contains filtered or unexported fields
}

MemoryKey is the in-memory crypto key

func NewMemoryKey

func NewMemoryKey(chainID *big.Int) (*MemoryKey, error)

NewMemoryKey returns a MemoryKey

func NewMemoryKeyFromBytes

func NewMemoryKeyFromBytes(chainID *big.Int, pk []byte) (*MemoryKey, error)

NewMemoryKeyFromBytes parse memory key by the byte array

func NewMemoryKeyFromString

func NewMemoryKeyFromString(chainID *big.Int, sk string) (*MemoryKey, error)

NewMemoryKeyFromString parse memory key by the hex string

func (*MemoryKey) Bytes

func (ac *MemoryKey) Bytes() []byte

Bytes returns the byte array of the key

func (*MemoryKey) Clear

func (ac *MemoryKey) Clear()

Clear removes private key bytes data

func (*MemoryKey) PrivateKey

func (ac *MemoryKey) PrivateKey() *ecdsa.PrivateKey

PrivateKey returns *ecdsa.PrivateKey of the private key

func (*MemoryKey) PublicKey

func (ac *MemoryKey) PublicKey() common.PublicKey

PublicKey returns the public key of the private key

func (*MemoryKey) Sign

func (ac *MemoryKey) Sign(h hash.Hash256) (common.Signature, error)

Sign generates the signature of the target hash

func (*MemoryKey) SignWithPassphrase

func (ac *MemoryKey) SignWithPassphrase(h hash.Hash256, passphrase []byte) (common.Signature, error)

SignWithPassphrase doesn't implemented yet

func (*MemoryKey) Verify

func (ac *MemoryKey) Verify(h hash.Hash256, sig common.Signature) bool

Verify checks that the signatures is generated by the hash and the key or not

Jump to

Keyboard shortcuts

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