mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 03:31:10 +00:00
update tiny-keccak (#4093)
* update tiny-keccak * fix * Update Cargo.toml * update Cargo.lock * remove keccak-hasher
This commit is contained in:
@@ -21,8 +21,7 @@ runtime-interface = { package = "substrate-runtime-interface", path = "../runtim
|
||||
externalities = { package = "substrate-externalities", path = "../externalities" }
|
||||
parking_lot = "0.9.0"
|
||||
log = "0.4.8"
|
||||
libsecp256k1 = "0.3.0"
|
||||
tiny-keccak = "1.5.0"
|
||||
libsecp256k1 = "0.3.2"
|
||||
|
||||
cranelift-codegen = { version = "0.46.1", optional = true }
|
||||
cranelift-entity = { version = "0.46.1", optional = true }
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use codec::Encode;
|
||||
use std::{convert::TryFrom, str};
|
||||
use primitives::{
|
||||
blake2_128, blake2_256, twox_64, twox_128, twox_256, ed25519, sr25519, Blake2Hasher, Pair,
|
||||
blake2_128, blake2_256, twox_64, twox_128, twox_256, ed25519, sr25519, keccak_256, Blake2Hasher, Pair,
|
||||
crypto::KeyTypeId, offchain,
|
||||
};
|
||||
use trie::{TrieConfiguration, trie_types::Layout};
|
||||
@@ -538,11 +538,11 @@ impl_wasm_host_interface! {
|
||||
|
||||
ext_keccak_256(data: Pointer<u8>, len: WordSize, out: Pointer<u8>) {
|
||||
let result: [u8; 32] = if len == 0 {
|
||||
tiny_keccak::keccak256(&[0u8; 0])
|
||||
keccak_256(&[0u8; 0])
|
||||
} else {
|
||||
let mem = context.read_memory(data, len)
|
||||
.map_err(|_| "Invalid attempt to get data in ext_keccak_256")?;
|
||||
tiny_keccak::keccak256(&mem)
|
||||
keccak_256(&mem)
|
||||
};
|
||||
context.write_memory(out, &result)
|
||||
.map_err(|_| "Invalid attempt to set result in ext_keccak_256")?;
|
||||
|
||||
@@ -32,7 +32,7 @@ zeroize = { version = "0.10.1", default-features = false }
|
||||
lazy_static = { version = "1.4.0", default-features = false, optional = true }
|
||||
parking_lot = { version = "0.9.0", optional = true }
|
||||
libsecp256k1 = { version = "0.3.0", default-features = false, optional = true }
|
||||
tiny-keccak = { version = "1.5.0", optional = true }
|
||||
tiny-keccak = { version = "2.0.1", features = ["keccak"], optional = true }
|
||||
substrate-debug-derive = { version = "2.0.0", path = "./debug-derive" }
|
||||
externalities = { package = "substrate-externalities", path = "../externalities", optional = true }
|
||||
primitives-storage = { package = "substrate-primitives-storage", path = "storage", default-features = false }
|
||||
@@ -100,6 +100,7 @@ std = [
|
||||
full_crypto = [
|
||||
"ed25519-dalek",
|
||||
"blake2-rfc",
|
||||
"tiny-keccak",
|
||||
"schnorrkel",
|
||||
"libsecp256k1",
|
||||
"hex",
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
//! Hashing functions.
|
||||
|
||||
use blake2_rfc;
|
||||
use tiny_keccak::{Hasher, Keccak};
|
||||
use twox_hash;
|
||||
|
||||
/// Do a Blake2 512-bit hash and place result in `dest`.
|
||||
@@ -121,3 +122,12 @@ pub fn twox_256(data: &[u8]) -> [u8; 32] {
|
||||
twox_256_into(data, &mut r);
|
||||
r
|
||||
}
|
||||
|
||||
/// Do a keccak 256 hash and return result.
|
||||
pub fn keccak_256(data: &[u8]) -> [u8; 32] {
|
||||
let mut keccak = Keccak::v256();
|
||||
keccak.update(data);
|
||||
let mut output = [0u8; 32];
|
||||
keccak.finalize(&mut output);
|
||||
output
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ pub use impl_serde::serialize as bytes;
|
||||
#[cfg(feature = "full_crypto")]
|
||||
pub mod hashing;
|
||||
#[cfg(feature = "full_crypto")]
|
||||
pub use hashing::{blake2_128, blake2_256, twox_64, twox_128, twox_256};
|
||||
pub use hashing::{blake2_128, blake2_256, twox_64, twox_128, twox_256, keccak_256};
|
||||
#[cfg(feature = "std")]
|
||||
pub mod hexdisplay;
|
||||
pub mod crypto;
|
||||
|
||||
@@ -10,7 +10,6 @@ hash-db = { version = "0.15.2", default-features = false }
|
||||
primitives = { package = "substrate-primitives", path = "../primitives", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../sr-std", default-features = false }
|
||||
libsecp256k1 = { version = "0.3.0", optional = true }
|
||||
tiny-keccak = { version = "1.5.0", optional = true }
|
||||
substrate-state-machine = { path = "../state-machine", optional = true }
|
||||
runtime-interface = { package = "substrate-runtime-interface", path = "../runtime-interface", default-features = false }
|
||||
trie = { package = "substrate-trie", path = "../trie", optional = true }
|
||||
@@ -27,7 +26,6 @@ std = [
|
||||
"trie",
|
||||
"substrate-state-machine",
|
||||
"libsecp256k1",
|
||||
"tiny-keccak",
|
||||
"runtime-interface/std",
|
||||
"externalities",
|
||||
"log",
|
||||
|
||||
@@ -376,7 +376,7 @@ pub trait Crypto {
|
||||
pub trait Hashing {
|
||||
/// Conduct a 256-bit Keccak hash.
|
||||
fn keccak_256(data: &[u8]) -> [u8; 32] {
|
||||
tiny_keccak::keccak256(data)
|
||||
primitives::hashing::keccak_256(data)
|
||||
}
|
||||
|
||||
/// Conduct a 128-bit Blake2 hash.
|
||||
|
||||
@@ -23,7 +23,6 @@ primitives = { package = "substrate-primitives", path = "../primitives", defaul
|
||||
[dev-dependencies]
|
||||
trie-bench = "0.16.2"
|
||||
trie-standardmap = "0.15.2"
|
||||
keccak-hasher = "0.15.2"
|
||||
criterion = "0.2.11"
|
||||
hex-literal = "0.2.1"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user