crypto

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 10 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMessagePrefix

func AddMessagePrefix(data []byte) []byte

AddMessagePrefix adds the Ethereum message prefix to the given data as defined in EIP-191.

func ECPublicKeyToAddress

func ECPublicKeyToAddress(pub *ecdsa.PublicKey) (addr types.Address)

ECPublicKeyToAddress returns the Ethereum address for the given ECDSA public key.

func Keccak256

func Keccak256(data ...[]byte) types.Hash

Keccak256 calculates the Keccak256 hash of the given data.

Types

type Recoverer

type Recoverer interface {
	// RecoverHash recovers the address from a hash and signature.
	RecoverHash(hash types.Hash, sig types.Signature) (*types.Address, error)

	// RecoverMessage recovers the address from a message and signature.
	RecoverMessage(data []byte, sig types.Signature) (*types.Address, error)

	// RecoverTransaction recovers the address from a transaction.
	RecoverTransaction(tx *types.Transaction) (*types.Address, error)
}

Recoverer is an interface for recovering addresses from signatures.

var ECRecoverer Recoverer = &ecRecoverer{}

ECRecoverer is a Recoverer implementation for ECDSA.

type Signer

type Signer interface {
	// SignHash signs a hash.
	SignHash(hash types.Hash) (*types.Signature, error)

	// SignMessage signs a message.
	SignMessage(data []byte) (*types.Signature, error)

	// SignTransaction signs a transaction.
	SignTransaction(tx *types.Transaction) error
}

Signer is an interface for signing data.

func ECSigner

func ECSigner(key *ecdsa.PrivateKey) Signer

ECSigner returns a Signer implementation for ECDSA.

Jump to

Keyboard shortcuts

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