signature

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyBytes

func CopyBytes(data []byte) []byte

CopyBytes is used to copy slice

func EcRecover

func EcRecover(data []byte, sig []byte) (ethcommon.Address, error)

EcRecover returns the address for the account that was used to create the signature, Note, this function is compatible with eth_sign and personal_sign. As such it recovers the address of: hash = keccak256("\x19Ethereum Signed Message:\n"${message length}${message}) addr = ecrecover(hash, signature)

Note, the signature must conform to the secp256k1 curve R, S and V values, where the V value must be 27 or 28 for legacy reasons.

https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecover

func EcRecoverEx

func EcRecoverEx(data []byte, sig []byte) (ethcommon.Address, error)

EcRecoverEx is an extension to EcRecover that supports more signature formats, such as ledger signatures.

func Has0xPrefix

func Has0xPrefix(str string) bool

Has0xPrefix validates str begins with '0x' or '0X'.

func HashTypedData

func HashTypedData(data apitypes.TypedData) ([]byte, []byte, error)

HashTypedData is used to calculate the hash of EIP-712 conformant typed data hash = keccak256("\x19${byteVersion}${domainSeparator}${hashStruct(message)}")

func HexDecode

func HexDecode(s string) ([]byte, error)

HexDecode returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".

func PersonalSign

func PersonalSign(message string, privateKey *ecdsa.PrivateKey) (string, error)

Returns a signature string

func RecoveryAddress

func RecoveryAddress(data []byte, sig []byte) (ethcommon.Address, error)

RecoveryAddress returns the address for the account that was used to create the signature, this function is almost a fork of EcRecover However, EcRecover in go-ethereum will automatically perform accounts.TextHash for data in EcRecover, which makes EIP712 unable to reuse this function This design makes the function lose versatility, so this behavior is changed here

func RecoveryAddressEx

func RecoveryAddressEx(data []byte, sig []byte) (ethcommon.Address, error)

RecoveryAddressEx is an extension to RecoveryAddress that supports more signature formats, such as ledger signatures.

func RecoveryTypedDataAddressEx

func RecoveryTypedDataAddressEx(data apitypes.TypedData, signature []byte) (ethcommon.Address, error)

RecoveryTypedDataAddressEx is used to recover the signer address of the TypedData signature

func VerifyEllipticCurveHexSignatureEx

func VerifyEllipticCurveHexSignatureEx(address ethcommon.Address, data []byte, signature string) (bool, error)

VerifyEllipticCurveHexSignatureEx is used to verify elliptic curve signatures It calls the EcRecoverEx function to verify the signature.

func VerifyEllipticCurveSignature

func VerifyEllipticCurveSignature(address ethcommon.Address, data []byte, signature []byte) (bool, error)

VerifyEllipticCurveSignature is used to verify the elliptic curve signature It calls the native ecrecover function to verify the signature

func VerifyEllipticCurveSignatureEx

func VerifyEllipticCurveSignatureEx(address ethcommon.Address, data []byte, signature []byte) (bool, error)

VerifyEllipticCurveSignatureEx is used to verify elliptic curve signatures It calls the EcRecoverEx function to verify the signature.

func VerifySignature

func VerifySignature(addr string, data []byte, signature []byte) (bool, error)

func VerifyTypedDataHexSignatureEx

func VerifyTypedDataHexSignatureEx(address ethcommon.Address, data apitypes.TypedData, signature string) (bool, error)

VerifyTypedDataHexSignatureEx is used to verify the signer address of the TypedData signature

func VerifyTypedDataSignatureEx

func VerifyTypedDataSignatureEx(address ethcommon.Address, data apitypes.TypedData, signature []byte) (bool, error)

VerifyTypedDataSignatureEx is used to verify the signer address of the TypedData signature

Types

type EIP191

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

Jump to

Keyboard shortcuts

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