[keccak-hasher]: rust2018 (#11163)

This commit is contained in:
Niklas Adolfsson 2019-10-10 19:43:33 +02:00 committed by GitHub
parent 9d313e31e6
commit 4f25d43516
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,7 @@
[package] [package]
name = "keccak-hasher" name = "keccak-hasher"
version = "0.1.1" version = "0.1.1"
edition = "2018"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Keccak-256 implementation of the Hasher trait" description = "Keccak-256 implementation of the Hasher trait"
license = "GPL-3.0" license = "GPL-3.0"

View File

@ -15,15 +15,14 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>. // along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
//! Hasher implementation for the Keccak-256 hash //! Hasher implementation for the Keccak-256 hash
extern crate hash_db;
extern crate ethereum_types; #![warn(missing_docs)]
extern crate tiny_keccak;
extern crate plain_hasher;
use hash_db::Hasher; use hash_db::Hasher;
use ethereum_types::H256; use ethereum_types::H256;
use tiny_keccak::Keccak; use tiny_keccak::Keccak;
use plain_hasher::PlainHasher; use plain_hasher::PlainHasher;
/// Concrete `Hasher` impl for the Keccak-256 hash /// Concrete `Hasher` impl for the Keccak-256 hash
#[derive(Default, Debug, Clone, PartialEq)] #[derive(Default, Debug, Clone, PartialEq)]
pub struct KeccakHasher; pub struct KeccakHasher;
@ -32,7 +31,7 @@ impl Hasher for KeccakHasher {
type StdHasher = PlainHasher; type StdHasher = PlainHasher;
const LENGTH: usize = 32; const LENGTH: usize = 32;
fn hash(x: &[u8]) -> Self::Out { fn hash(x: &[u8]) -> Self::Out {
let mut out = [0;32]; let mut out = [0; 32];
Keccak::keccak256(x, &mut out); Keccak::keccak256(x, &mut out);
out.into() out.into()
} }