Add sha2-256 hash function (#4218)

* Add sha2-256 hash function

Widely used hash function, supported by bitcoin and ethereum

* Add runtime io support

* add test

* add test

* Update hashing.rs

* Update hashing.rs
This commit is contained in:
Weiliang Li
2019-11-28 02:32:35 +09:00
committed by Gavin Wood
parent f8bf17dc49
commit dcaabbaacf
4 changed files with 57 additions and 2 deletions
@@ -10,7 +10,7 @@ use rstd::{vec::Vec, vec};
#[cfg(not(feature = "std"))]
use runtime_io::{
storage, hashing::{blake2_128, blake2_256, twox_128, twox_256},
storage, hashing::{blake2_128, blake2_256, sha2_256, twox_128, twox_256},
crypto::{ed25519_verify, sr25519_verify},
};
#[cfg(not(feature = "std"))]
@@ -60,6 +60,10 @@ primitives::wasm_export_functions! {
blake2_128(&input).to_vec()
}
fn test_sha2_256(input: Vec<u8>) -> Vec<u8> {
sha2_256(&input).to_vec()
}
fn test_twox_256(input: Vec<u8>) -> Vec<u8> {
twox_256(&input).to_vec()
}