From abe119abbaabfd86ee586454b7a9a8f69767fbb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 11 Dec 2020 16:41:18 +0100 Subject: [PATCH] Add keccak-512 to host functions. (#7531) --- substrate/primitives/core/src/hashing.rs | 5 +++++ substrate/primitives/io/src/lib.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/substrate/primitives/core/src/hashing.rs b/substrate/primitives/core/src/hashing.rs index 98dc0c2efc..6807da02fe 100644 --- a/substrate/primitives/core/src/hashing.rs +++ b/substrate/primitives/core/src/hashing.rs @@ -16,6 +16,11 @@ // limitations under the License. //! Hashing functions. +//! +//! This module is gated by `full-crypto` feature. If you intend to use any of the functions +//! defined here within your runtime, you should most likely rather use [sp_io::hashing] instead, +//! unless you know what you're doing. Using `sp_io` will be more performant, since instead of +//! computing the hash in WASM it delegates that computation to the host client. use blake2_rfc; use sha2::{Digest, Sha256}; diff --git a/substrate/primitives/io/src/lib.rs b/substrate/primitives/io/src/lib.rs index b6ae64e5f8..023bf7dcb3 100644 --- a/substrate/primitives/io/src/lib.rs +++ b/substrate/primitives/io/src/lib.rs @@ -735,6 +735,11 @@ pub trait Hashing { sp_core::hashing::keccak_256(data) } + /// Conduct a 512-bit Keccak hash. + fn keccak_512(data: &[u8]) -> [u8; 64] { + sp_core::hashing::keccak_512(data) + } + /// Conduct a 256-bit Sha2 hash. fn sha2_256(data: &[u8]) -> [u8; 32] { sp_core::hashing::sha2_256(data)