diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2016-10-06 20:24:36 +0800 |
---|---|---|
committer | Yoichi Hirai <i@yoichihirai.com> | 2016-10-06 22:34:41 +0800 |
commit | 111d33d7aced317605fd88c74b01ffbc6ab266c7 (patch) | |
tree | fb1b64e7b4a3f20327b8514baadae6151c1f19e4 /docs/units-and-global-variables.rst | |
parent | 34df80c502c5e20fda6db1d2152beccdfb3342cc (diff) | |
download | dexon-solidity-111d33d7aced317605fd88c74b01ffbc6ab266c7.tar dexon-solidity-111d33d7aced317605fd88c74b01ffbc6ab266c7.tar.gz dexon-solidity-111d33d7aced317605fd88c74b01ffbc6ab266c7.tar.bz2 dexon-solidity-111d33d7aced317605fd88c74b01ffbc6ab266c7.tar.lz dexon-solidity-111d33d7aced317605fd88c74b01ffbc6ab266c7.tar.xz dexon-solidity-111d33d7aced317605fd88c74b01ffbc6ab266c7.tar.zst dexon-solidity-111d33d7aced317605fd88c74b01ffbc6ab266c7.zip |
Rename sha3 to keccak256 in the documentation
Diffstat (limited to 'docs/units-and-global-variables.rst')
-rw-r--r-- | docs/units-and-global-variables.rst | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst index 9ee334cf..3499bc71 100644 --- a/docs/units-and-global-variables.rst +++ b/docs/units-and-global-variables.rst @@ -79,7 +79,7 @@ Block and Transaction Properties You can only access the hashes of the most recent 256 blocks, all other values will be zero. -.. index:: sha3, ripemd160, sha256, ecrecover, addmod, mulmod, cryptography, this, super, selfdestruct, balance, send +.. index:: keccak256, ripemd160, sha256, ecrecover, addmod, mulmod, cryptography, this, super, selfdestruct, balance, send Mathematical and Cryptographic Functions ---------------------------------------- @@ -88,8 +88,10 @@ Mathematical and Cryptographic Functions compute ``(x + y) % k`` where the addition is performed with arbitrary precision and does not wrap around at ``2**256``. ``mulmod(uint x, uint y, uint k) returns (uint)``: compute ``(x * y) % k`` where the multiplication is performed with arbitrary precision and does not wrap around at ``2**256``. +``keccak256(...) returns (bytes32)``: + compute the Ethereum-SHA-3 (Keccak-256) hash of the (tightly packed) arguments ``sha3(...) returns (bytes32)``: - compute the Ethereum-SHA-3 (KECCAK-256) hash of the (tightly packed) arguments + alias to `keccak256()` ``sha256(...) returns (bytes32)``: compute the SHA-256 hash of the (tightly packed) arguments ``ripemd160(...) returns (bytes20)``: @@ -100,18 +102,18 @@ Mathematical and Cryptographic Functions In the above, "tightly packed" means that the arguments are concatenated without padding. This means that the following are all identical:: - sha3("ab", "c") - sha3("abc") - sha3(0x616263) - sha3(6382179) - sha3(97, 98, 99) + keccak256("ab", "c") + keccak256("abc") + keccak256(0x616263) + keccak256(6382179) + keccak256(97, 98, 99) -If padding is needed, explicit type conversions can be used: ``sha3("\x00\x12")`` is the -same as ``sha3(uint16(0x12))``. +If padding is needed, explicit type conversions can be used: ``keccak256("\x00\x12")`` is the +same as ``keccak256(uint16(0x12))``. Note that constants will be packed using the minimum number of bytes required to store them. -This means that, for example, ``sha3(0) == sha3(uint8(0))`` and -``sha3(0x12345678) == sha3(uint32(0x12345678))``. +This means that, for example, ``keccak256(0) == keccak256(uint8(0))`` and +``keccak256(0x12345678) == keccak256(uint32(0x12345678))``. It might be that you run into Out-of-Gas for ``sha256``, ``ripemd160`` or ``ecrecover`` on a *private blockchain*. The reason for this is that those are implemented as so-called precompiled contracts and these contracts only really exist after they received the first message (although their contract code is hardcoded). Messages to non-existing contracts are more expensive and thus the execution runs into an Out-of-Gas error. A workaround for this problem is to first send e.g. 1 Wei to each of the contracts before you use them in your actual contracts. This is not an issue on the official or test net. |