sha512
Hash the input data with SHA-512, according to NIST.FIPS.180-4
Precompile address
0x0100000000000000000000000000000000000101
Warning: SHA-512 vs SHA-512/256 Length-Extension Attacks
SHA-512 is vulnerable to length-extension attacks, which are relevant if you are computing the hash of a secret message. The SHA-512/256 variant is not vulnerable to length-extension attacks.
Gas Cost
115 gas, then 13 gas per word
Example
bytes memory result = sha512(abi.encodePacked("input data"));
Notes:
-
standard: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf
-
see: @oasisprotocol/oasis-sdk :: precompile/sha2.rs :: call_sha512
function sha512(bytes memory input) view returns (bytes memory output);
Parameters
Name | Type | Description |
---|---|---|
input | bytes | Bytes to hash. |
Returns
Name | Type | Description |
---|---|---|
output | bytes | 64 byte digest. |