SignatureChecker
Author: M^0 Labs
Functions
isValidSignature
Returns whether a signature is valid (ECDSA/secp256k1 or ERC1271) for a signer and digest.
Signatures must not be used as unique identifiers since the ecrecover
EVM opcode allows for malleable (non-unique) signatures. See https://github.com/OpenZeppelin/openzeppelin-contracts/security/advisories/GHSA-4h98-2769-gh6h
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account purported to have signed. |
|
| The hash of the data that was signed. |
|
| A byte array signature. |
Returns
Name | Type | Description |
---|---|---|
|
| Whether the signature is valid or not. |
isValidERC1271Signature
Returns whether an ERC1271 signature is valid for a signer and digest.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account purported to have signed. |
|
| The hash of the data that was signed. |
|
| A byte array ERC1271 signature. |
Returns
Name | Type | Description |
---|---|---|
|
| Whether the signature is valid or not. |
decodeECDSASignature
Decodes an ECDSA/secp256k1 signature from a byte array to standard v, r, and s parameters.
Parameters
Name | Type | Description |
---|---|---|
|
| A byte array ECDSA/secp256k1 signature. |
Returns
Name | Type | Description |
---|---|---|
|
| An ECDSA/secp256k1 signature parameter. |
|
| An ECDSA/secp256k1 signature parameter. |
|
| An ECDSA/secp256k1 signature parameter. |
decodeShortECDSASignature
Decodes an ECDSA/secp256k1 short signature as defined by EIP2098 from a byte array to standard v, r, and s parameters.
Parameters
Name | Type | Description |
---|---|---|
|
| A byte array ECDSA/secp256k1 short signature. |
Returns
Name | Type | Description |
---|---|---|
|
| An ECDSA/secp256k1 signature parameter. |
|
| An ECDSA/secp256k1 short signature parameter. |
isValidECDSASignature
Returns whether an ECDSA/secp256k1 signature is valid for a signer and digest.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account purported to have signed. |
|
| The hash of the data that was signed. |
|
| A byte array ECDSA/secp256k1 signature (encoded r, s, v). |
Returns
Name | Type | Description |
---|---|---|
|
| Whether the signature is valid or not. |
isValidECDSASignature
Returns whether an ECDSA/secp256k1 short signature is valid for a signer and digest.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account purported to have signed. |
|
| The hash of the data that was signed. |
|
| An ECDSA/secp256k1 signature parameter. |
|
| An ECDSA/secp256k1 short signature parameter. |
Returns
Name | Type | Description |
---|---|---|
|
| Whether the signature is valid or not. |
recoverECDSASigner
Returns the signer of an ECDSA/secp256k1 signature for some digest.
Parameters
Name | Type | Description |
---|---|---|
|
| The hash of the data that was signed. |
|
| A byte array ECDSA/secp256k1 signature. |
Returns
Name | Type | Description |
---|---|---|
|
| An error, if any, that occurred during the signer recovery. |
|
| The address of the account recovered form the signature (0 if error). |
recoverECDSASigner
Returns the signer of an ECDSA/secp256k1 short signature for some digest.
See https://eips.ethereum.org/EIPS/eip-2098
Parameters
Name | Type | Description |
---|---|---|
|
| The hash of the data that was signed. |
|
| An ECDSA/secp256k1 signature parameter. |
|
| An ECDSA/secp256k1 short signature parameter. |
Returns
Name | Type | Description |
---|---|---|
|
| An error, if any, that occurred during the signer recovery. |
|
| The address of the account recovered form the signature (0 if error). |
recoverECDSASigner
Returns the signer of an ECDSA/secp256k1 signature for some digest.
Parameters
Name | Type | Description |
---|---|---|
|
| The hash of the data that was signed. |
|
| An ECDSA/secp256k1 signature parameter. |
|
| An ECDSA/secp256k1 signature parameter. |
|
| An ECDSA/secp256k1 signature parameter. |
Returns
Name | Type | Description |
---|---|---|
|
| An error, if any, that occurred during the signer recovery. |
|
| The address of the account recovered form the signature (0 if error). |
validateECDSASignature
Returns an error, if any, in validating an ECDSA/secp256k1 signature for a signer and digest.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account purported to have signed. |
|
| The hash of the data that was signed. |
|
| A byte array ERC1271 signature. |
Returns
Name | Type | Description |
---|---|---|
|
| An error, if any, that occurred during the signer recovery. |
validateECDSASignature
Returns an error, if any, in validating an ECDSA/secp256k1 short signature for a signer and digest.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account purported to have signed. |
|
| The hash of the data that was signed. |
|
| An ECDSA/secp256k1 signature parameter. |
|
| An ECDSA/secp256k1 short signature parameter. |
Returns
Name | Type | Description |
---|---|---|
|
| An error, if any, that occurred during the signer recovery. |
validateECDSASignature
Returns an error, if any, in validating an ECDSA/secp256k1 signature for a signer and digest.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account purported to have signed. |
|
| The hash of the data that was signed. |
|
| An ECDSA/secp256k1 signature parameter. |
|
| An ECDSA/secp256k1 signature parameter. |
|
| An ECDSA/secp256k1 signature parameter. |
Returns
Name | Type | Description |
---|---|---|
|
| An error, if any, that occurred during the signer recovery. |
validateRecoveredSigner
Returns an error if signer
is not recoveredSigner
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the some signer. |
|
| The address of the some recoveredSigner. |
Returns
Name | Type | Description |
---|---|---|
|
| An error if |
Enums
Error
An enum representing the possible errors that can be emitted during signature validation.