Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions keccak-hash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[package]
name = "keccak-hash"
version = "0.1.2"
version = "0.1.3"
description = "`keccak-hash` is a set of utility functions to facilitate working with Keccak hashes (256/512 bits long)."
authors = ["Parity Technologies <admin@parity.io>"]
repository = "https://github.com/paritytech/parity-common"
readme = "README.md"
license = "GPL-3.0"

[dependencies]
ethereum-types = "0.4"
tiny-keccak = "1.4"
primitive-types = { path = "../primitive-types", version = "0.2" }

[dev-dependencies]
tempdir = "0.3"
3 changes: 1 addition & 2 deletions keccak-hash/benches/keccak_256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
#![feature(test)]

extern crate test;
extern crate ethereum_types;
extern crate keccak_hash;

use keccak_hash::{keccak, write_keccak};
use keccak_hash::keccak;
use test::Bencher;

#[bench]
Expand Down
9 changes: 6 additions & 3 deletions keccak-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

extern crate ethereum_types;
extern crate primitive_types;
extern crate tiny_keccak;

use std::io;
use std::slice;

use tiny_keccak::Keccak;

pub use ethereum_types::H256;
pub use primitive_types::H256;

/// Get the KECCAK (i.e. Keccak) hash of the empty bytes string.
pub const KECCAK_EMPTY: H256 = H256( [0xc5, 0xd2, 0x46, 0x01, 0x86, 0xf7, 0x23, 0x3c, 0x92, 0x7e, 0x7d, 0xb2, 0xdc, 0xc7, 0x03, 0xc0, 0xe5, 0x00, 0xb6, 0x53, 0xca, 0x82, 0x27, 0x3b, 0x7b, 0xfa, 0xd8, 0x04, 0x5d, 0x85, 0xa4, 0x70] );
Expand Down Expand Up @@ -91,6 +92,8 @@ mod tests {

use std::fs;
use std::io::{Write, BufReader};
use std::str::FromStr;

use self::tempdir::TempDir;
use super::{keccak, write_keccak, keccak_buffer, KECCAK_EMPTY};

Expand All @@ -101,7 +104,7 @@ mod tests {

#[test]
fn keccak_as() {
assert_eq!(keccak([0x41u8; 32]), From::from("59cad5948673622c1d64e2322488bf01619f7ff45789741b15a9f782ce9290a8"));
assert_eq!(keccak([0x41u8; 32]), FromStr::from_str("59cad5948673622c1d64e2322488bf01619f7ff45789741b15a9f782ce9290a8").unwrap());
}

#[test]
Expand Down
5 changes: 2 additions & 3 deletions trie-standardmap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[package]
name = "trie-standardmap"
description = "Standard test map for profiling tries"
version = "0.1.1"
version = "0.1.2"
authors = ["debris <marek.kotewicz@gmail.com>", "Parity Technologies <admin@parity.io>"]
repository = "https://github.com/paritytech/parity-common"
license = "GPL-3.0"

[dependencies]
ethereum-types = "0.4"
keccak-hash = { version = "0.1", path = "../keccak-hash" }
parity-bytes = { version = "0.1", path = "../parity-bytes" }
rlp = { version = "0.3.0", path = "../rlp" }
rlp = { version = "0.3", path = "../rlp" }
8 changes: 3 additions & 5 deletions trie-standardmap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
//! Key-value datastore with a modified Merkle tree.

extern crate parity_bytes as bytes;
extern crate ethereum_types;
extern crate keccak_hash;
extern crate rlp;

use bytes::Bytes;
use ethereum_types::H256;
use keccak_hash::keccak;
use keccak_hash::{keccak, H256};
use rlp::encode;

/// Alphabet to use when creating words for insertion into tries.
Expand Down Expand Up @@ -77,7 +75,7 @@ impl StandardMap {
*seed = keccak(&seed);
match seed[0] % 2 {
1 => vec![seed[31];1],
_ => seed.to_vec(),
_ => seed.as_bytes().to_vec(),
}
}

Expand All @@ -96,7 +94,7 @@ impl StandardMap {

/// Create the standard map (set of keys and values) for the object's fields.
pub fn make(&self) -> Vec<(Bytes, Bytes)> {
self.make_with(&mut H256::new())
self.make_with(&mut H256::zero())
}

/// Create the standard map (set of keys and values) for the object's fields, using the given seed.
Expand Down