Documentation ¶
Index ¶
- func CopyBytes(data []byte) []byte
- func EcRecover(data []byte, sig []byte) (ethcommon.Address, error)
- func EcRecoverEx(data []byte, sig []byte) (ethcommon.Address, error)
- func GetERC1271Magic() [4]byte
- func Has0xPrefix(str string) bool
- func HashTypedData(data apitypes.TypedData) ([]byte, []byte, error)
- func HexDecode(s string) ([]byte, error)
- func IsErrExecutionReverted(err error) bool
- func IsErrNoContractCode(err error) bool
- func RecoveryAddress(data []byte, sig []byte) (ethcommon.Address, error)
- func RecoveryAddressEx(data []byte, sig []byte) (ethcommon.Address, error)
- func RecoveryTypedDataAddressEx(data apitypes.TypedData, signature []byte) (ethcommon.Address, error)
- func VerifyERC1271HexSignature(ctx context.Context, client *ethclient.Client, address ethcommon.Address, ...) (bool, error)
- func VerifyERC1271Signature(ctx context.Context, client *ethclient.Client, address ethcommon.Address, ...) (bool, error)
- func VerifyEllipticCurveHexSignatureEx(address ethcommon.Address, data []byte, signature string) (bool, error)
- func VerifyEllipticCurveSignature(address ethcommon.Address, data []byte, signature []byte) (bool, error)
- func VerifyEllipticCurveSignatureEx(address ethcommon.Address, data []byte, signature []byte) (bool, error)
- func VerifyHexSignatureEx(ctx context.Context, client *ethclient.Client, address ethcommon.Address, ...) (bool, error)
- func VerifySignatureEx(ctx context.Context, client *ethclient.Client, address ethcommon.Address, ...) (bool, error)
- func VerifyTypedDataHexSignatureEx(address ethcommon.Address, data apitypes.TypedData, signature string) (bool, error)
- func VerifyTypedDataSignatureEx(address ethcommon.Address, data apitypes.TypedData, signature []byte) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EcRecover ¶
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 ¶
EcRecoverEx is an extension to EcRecover that supports more signature formats, such as ledger signatures.
func GetERC1271Magic ¶
func GetERC1271Magic() [4]byte
GetERC1271Magic is used to get the magic value defined by ERC1271
func Has0xPrefix ¶
Has0xPrefix validates str begins with '0x' or '0X'.
func HashTypedData ¶
HashTypedData is used to calculate the hash of EIP-712 conformant typed data hash = keccak256("\x19${byteVersion}${domainSeparator}${hashStruct(message)}")
func HexDecode ¶
HexDecode returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func IsErrExecutionReverted ¶
IsErrExecutionReverted is used to determine whether err is an ExecutionReverted error
func IsErrNoContractCode ¶
IsErrNoContractCode is used to determine whether err is an NoContractCode error
func RecoveryAddress ¶
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 ¶
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 VerifyERC1271HexSignature ¶
func VerifyERC1271HexSignature(ctx context.Context, client *ethclient.Client, address ethcommon.Address, data []byte, signature string) (bool, error)
VerifyERC1271HexSignature is a helper function. look up VerifyERC1271 for more comments.
func VerifyERC1271Signature ¶
func VerifyERC1271Signature(ctx context.Context, client *ethclient.Client, address ethcommon.Address, data []byte, signature []byte) (bool, error)
VerifyERC1271Signature verifies signatures based on the ERC1271 standard 1. When the given address is EOA, "no contract code at given address" will be thrown: 2. When the given address is a contract but does not conform to the erc1271 specification, "execution reverted" will be thrown
func VerifyEllipticCurveHexSignatureEx ¶ added in v1.1.0
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 VerifyHexSignatureEx ¶
func VerifyHexSignatureEx(ctx context.Context, client *ethclient.Client, address ethcommon.Address, msg []byte, signature string) (bool, error)
VerifyHexSignatureEx is used to verify text signature
func VerifySignatureEx ¶
func VerifySignatureEx(ctx context.Context, client *ethclient.Client, address ethcommon.Address, msg []byte, signature []byte) (bool, error)
VerifySignatureEx is used to verify text signature
Types ¶
This section is empty.