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 Has0xPrefix(str string) bool
- func HashTypedData(data apitypes.TypedData) ([]byte, []byte, error)
- func HexDecode(s string) ([]byte, error)
- func PersonalSign(message string, privateKey *ecdsa.PrivateKey) (string, error)
- 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 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 VerifySignature(addr string, data []byte, signature []byte) (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)
- type EIP191
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 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 PersonalSign ¶
func PersonalSign(message string, privateKey *ecdsa.PrivateKey) (string, error)
Returns a signature string
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 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.