Skip to main content

ECDSA

[Git Source](https://github.com/GVI-Tech-JSC/ggvi-v3/blob/85927f39f9ef0f1355aa04e3451eec63a7df478f/src/external/Tech Holding JSCERC20.sol)

Elliptic Curve Digital Signature Algorithm (ECDSA) operations. These functions can be used to verify that a message was signed by the holder of the private keys of a given address.

Functions

_throwError

function _throwError(RecoverError error) private pure;

tryRecover

Returns the address that signed a hashed message (hash) with signature or error string. This address can then be used for verification purposes. The ecrecover EVM opcode allows for malleable (non-unique) signatures: this function rejects them by requiring the s value to be in the lower half order, and the v value to be either 27 or 28. IMPORTANT: hash must be the result of a hash operation for the verification to be secure: it is possible to craft signatures that recover to arbitrary addresses for non-hashed data. A safe way to ensure this is by receiving a hash of the original message (which may otherwise be too long), and then calling [toEthSignedMessageHash](/main/contracts/docs/src/external/Tech Holding JSCERC20.sol/library.ECDSA#toethsignedmessagehash) on it. Documentation for signature generation:

function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError);

recover

Returns the address that signed a hashed message (hash) with signature. This address can then be used for verification purposes. The ecrecover EVM opcode allows for malleable (non-unique) signatures: this function rejects them by requiring the s value to be in the lower half order, and the v value to be either 27 or 28. IMPORTANT: hash must be the result of a hash operation for the verification to be secure: it is possible to craft signatures that recover to arbitrary addresses for non-hashed data. A safe way to ensure this is by receiving a hash of the original message (which may otherwise be too long), and then calling [toEthSignedMessageHash](/main/contracts/docs/src/external/Tech Holding JSCERC20.sol/library.ECDSA#toethsignedmessagehash) on it.

function recover(bytes32 hash, bytes memory signature) internal pure returns (address);

tryRecover

Overload of [ECDSA-tryRecover](/main/contracts/docs/src/external/Tech Holding JSCERC20.sol/library.ECDSA#tryrecover) that receives the r and vs short-signature fields separately. See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] Available since v4.3.

function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError);

recover

Overload of [ECDSA-recover](/main/contracts/docs/src/external/Tech Holding JSCERC20.sol/library.ECDSA#recover) that receives the r andvs` short-signature fields separately. Available since v4.2.

function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address);

tryRecover

Overload of [ECDSA-tryRecover](/main/contracts/docs/src/external/Tech Holding JSCERC20.sol/library.ECDSA#tryrecover) that receives the v, r and s signature fields separately. Available since v4.3.

function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError);

recover

Overload of [ECDSA-recover](/main/contracts/docs/src/external/Tech Holding JSCERC20.sol/library.ECDSA#recover) that receives the v, r and s signature fields separately.

function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address);

toEthSignedMessageHash

Returns an Ethereum Signed Message, created from a hash. This produces hash corresponding to the one signed with the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method as part of EIP-191. See [recover](/main/contracts/docs/src/external/Tech Holding JSCERC20.sol/library.ECDSA#recover).

function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32);

toTypedDataHash

Returns an Ethereum Signed Typed Data, created from a domainSeparator and a structHash. This produces hash corresponding to the one signed with the https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712. See [recover](/main/contracts/docs/src/external/Tech Holding JSCERC20.sol/library.ECDSA#recover).

function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32);

Enums

RecoverError

enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}