Merge pull request #6200 from ethereum/docs-high-s

[DOCS] Add mention of high s with ecrecover
This commit is contained in:
chriseth 2019-03-11 13:06:22 +01:00 committed by GitHub
commit 13bb9b633a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -163,6 +163,10 @@ Mathematical and Cryptographic Functions
``keccak256(bytes memory) returns (bytes32)``:
compute the Keccak-256 hash of the input
.. note::
There used to be an alias for ``keccak256`` called ``sha3``, which was removed in version 0.5.0.
``sha256(bytes memory) returns (bytes32)``:
compute the SHA-256 hash of the input
@ -182,13 +186,16 @@ Mathematical and Cryptographic Functions
For further details, read `example usage <https://ethereum.stackexchange.com/q/1777/222>`_.
.. warning::
If you use ``ecrecover``, be aware that a valid signature can be turned into a different valid signature without requiring
knowledge of the corresponding private key. This is usually not a problem unless you require signatures to be unique or
use them to identify items. OpenZeppelin have a `ECDSA helper library <https://docs.openzeppelin.org/docs/cryptography_ecdsa>`_ that you can use as a wrapper for ``ecrecover`` without this issue.
.. note::
When running ``sha256``, ``ripemd160`` or ``ecrecover`` on a *private blockchain*, you might encounter Out-of-Gas. This is because these functions are implemented as "precompiled contracts" and only really exist after they receive the first message (although their contract code is hardcoded). Messages to non-existing contracts are more expensive and thus the execution might run into an Out-of-Gas error. A workaround for this problem is to first send Wei (1 for example) to each of the contracts before you use them in your actual contracts. This is not an issue on the main or test net.
.. note::
There used to be an alias for ``keccak256`` called ``sha3``, which was removed in version 0.5.0.
.. index:: balance, send, transfer, call, callcode, delegatecall, staticcall
.. _address_related: