secp256k1

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PublicKeyToAddress

func PublicKeyToAddress(pubKey *btcec.PublicKey) *ethtypes.Address0xHex

Types

type KeyPair

type KeyPair struct {
	PrivateKey *btcec.PrivateKey
	PublicKey  *btcec.PublicKey
	Address    ethtypes.Address0xHex
}

func GenerateSecp256k1KeyPair

func GenerateSecp256k1KeyPair() (*KeyPair, error)

func NewSecp256k1KeyPair

func NewSecp256k1KeyPair(b []byte) (*KeyPair, error)

func (*KeyPair) PrivateKeyBytes

func (k *KeyPair) PrivateKeyBytes() []byte

func (*KeyPair) PublicKeyBytes

func (k *KeyPair) PublicKeyBytes() []byte

func (*KeyPair) Sign

func (k *KeyPair) Sign(message []byte) (ethSig *SignatureData, err error)

Sign hashes the input then signs it

func (*KeyPair) SignDirect added in v1.1.11

func (k *KeyPair) SignDirect(message []byte) (ethSig *SignatureData, err error)

SignDirect performs raw signing - give legacy 27/28 V values

type SignatureData

type SignatureData struct {
	V *big.Int
	R *big.Int
	S *big.Int
}

func (*SignatureData) Recover

func (s *SignatureData) Recover(message []byte, chainID int64) (a *ethtypes.Address0xHex, err error)

Recover obtains the original signer from the hash of the message

func (*SignatureData) RecoverDirect added in v1.1.11

func (s *SignatureData) RecoverDirect(message []byte, chainID int64) (a *ethtypes.Address0xHex, err error)

Recover obtains the original signer

func (*SignatureData) UpdateEIP155

func (s *SignatureData) UpdateEIP155(chainID int64)

EIP-155 rules - 2xChainID + 35 - starting point must be legacy 27/28

func (*SignatureData) UpdateEIP2930

func (s *SignatureData) UpdateEIP2930()

EIP-2930 (/ EIP-1559) rules - 0 or 1 V value for raw Y-parity value (chainID goes into the payload)

type Signer added in v0.9.14

type Signer interface {
	Sign(msgToHashAndSign []byte) (*SignatureData, error)
}

Signer is the low level common interface that can be implemented by any module which provides signature capability

type SignerDirect added in v1.1.11

type SignerDirect interface {
	Signer
	SignDirect(message []byte) (*SignatureData, error)
}

Jump to

Keyboard shortcuts

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