diff options
Diffstat (limited to 'crypto/crypto.go')
-rw-r--r-- | crypto/crypto.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go index ecc3be3ce..0b8c06008 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -37,6 +37,7 @@ var ( secp256k1_halfN = new(big.Int).Div(secp256k1_N, big.NewInt(2)) ) +// Keccak256 calculates and returns the Keccak256 hash of the input data. func Keccak256(data ...[]byte) []byte { d := sha3.NewKeccak256() for _, b := range data { @@ -45,6 +46,8 @@ func Keccak256(data ...[]byte) []byte { return d.Sum(nil) } +// Keccak256Hash calculates and returns the Keccak256 hash of the input data, +// converting it to an internal Hash data structure. func Keccak256Hash(data ...[]byte) (h common.Hash) { d := sha3.NewKeccak256() for _, b := range data { @@ -54,6 +57,15 @@ func Keccak256Hash(data ...[]byte) (h common.Hash) { return h } +// Keccak512 calculates and returns the Keccak512 hash of the input data. +func Keccak512(data ...[]byte) []byte { + d := sha3.NewKeccak512() + for _, b := range data { + d.Write(b) + } + return d.Sum(nil) +} + // Deprecated: For backward compatibility as other packages depend on these func Sha3Hash(data ...[]byte) common.Hash { return Keccak256Hash(data...) } |