sha512

Git Source

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:

  • https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf

  • @oasisprotocol/oasis-sdk :: precompile/sha2.rs :: call_sha512

function sha512(bytes memory input) view returns (bytes memory output);

Parameters

NameTypeDescription
inputbytesBytes to hash.

Returns

NameTypeDescription
outputbytes64 byte digest.