crypto

package
v0.0.0-...-8f649d9 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var S256 = btcec.S256()

S256 is the secp256k1 elliptic curve

Functions

func CreateAddress

func CreateAddress(addr types.Address, nonce uint64) types.Address

CreateAddress creates an Ethereum address.

func CreateAddress2

func CreateAddress2(addr types.Address, salt [32]byte, inithash []byte) types.Address

CreateAddress2 creates an Ethereum address following the CREATE2 Opcode.

func Ecrecover

func Ecrecover(hash, sig []byte) ([]byte, error)

func GenerateKey

func GenerateKey() (*ecdsa.PrivateKey, error)

GenerateKey generates a new key based on the secp256k1 elliptic curve.

func HexToECDSA

func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)

HexToECDSA parses a secp256k1 private key.

func Keccak256

func Keccak256(v ...[]byte) []byte

Keccak256 calculates the Keccak256

func MarshallPrivateKey

func MarshallPrivateKey(priv *ecdsa.PrivateKey) ([]byte, error)

func MarshallPublicKey

func MarshallPublicKey(pub *ecdsa.PublicKey) []byte

MarshallPublicKey marshalls a public key on the secp256k1 elliptic curve.

func ParsePrivateKey

func ParsePrivateKey(buf []byte) (*ecdsa.PrivateKey, error)

func ParsePublicKey

func ParsePublicKey(buf []byte) (*ecdsa.PublicKey, error)

ParsePublicKey parses bytes into a public key on the secp256k1 elliptic curve.

func PubKeyToAddress

func PubKeyToAddress(pub *ecdsa.PublicKey) types.Address

PubKeyToAddress returns the Ethereum address of a public key

func RecoverPubkey

func RecoverPubkey(signature, hash []byte) (*ecdsa.PublicKey, error)

RecoverPubkey verifies the compact signature "signature" of "hash" for the secp256k1 curve.

func SigToPub

func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error)

SigToPub returns the public key that created the given signature.

func Sign

func Sign(priv *ecdsa.PrivateKey, hash []byte) ([]byte, error)

Sign produces a compact signature of the data in hash with the given private key on the secp256k1 curve.

func ToECDSA

func ToECDSA(d []byte) (*ecdsa.PrivateKey, error)

ToECDSA creates a private key with the given D value.

func ValidateSignatureValues

func ValidateSignatureValues(v byte, r, s []byte) bool

ValidateSignatureValues checks if the signature values are correct

Types

type EIP155Signer

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

func NewEIP155Signer

func NewEIP155Signer(chainID uint64) *EIP155Signer

func (*EIP155Signer) Hash

func (e *EIP155Signer) Hash(tx *types.Transaction) types.Hash

func (*EIP155Signer) Sender

func (e *EIP155Signer) Sender(tx *types.Transaction) (types.Address, error)

func (*EIP155Signer) SignTx

type FrontierSigner

type FrontierSigner struct {
}

func (*FrontierSigner) Hash

func (f *FrontierSigner) Hash(tx *types.Transaction) types.Hash

func (*FrontierSigner) Sender

func (f *FrontierSigner) Sender(tx *types.Transaction) (types.Address, error)

func (*FrontierSigner) SignTx

type TxSigner

type TxSigner interface {
	// Hash returns the hash of the transaction
	Hash(tx *types.Transaction) types.Hash

	// Sender returns the sender to the transaction
	Sender(tx *types.Transaction) (types.Address, error)

	// SignTx signs a transaction
	SignTx(tx *types.Transaction, priv *ecdsa.PrivateKey) (*types.Transaction, error)
}

TxSigner recovers data from a transaction

func NewSigner

func NewSigner(forks chain.ForksInTime, chainID uint64) TxSigner

Jump to

Keyboard shortcuts

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