Skip to content

Commit

Permalink
Merge branch 'master' into dp/feature/add-NumEntries-trait
Browse files Browse the repository at this point in the history
* master:
  Bump fixed-hash to 0.3.2 (#134)
  Use EntropyRng instead of OsRng (#130)
  Bump parity-crypto to 0.3.1 (#132)
  rust-crypto dependency removal (#85)
  Use newly stablized TryFrom trait for primitive-types (#127)
  change dependencies of `keccak-hash`and `trie-standardmap` (#111)
  bring appveyor back (#118)
  Extract `should_replace` from Scoring and supply pooled txs from same sender (#116)
  • Loading branch information
ordian committed May 6, 2019
2 parents 00195f5 + ecdc90c commit e708a18
Show file tree
Hide file tree
Showing 30 changed files with 699 additions and 259 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ matrix:
rust: nightly
- os: osx
rust: stable
- os: windows
rust: stable
allow_failures:
- rust: nightly
script:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[![Build Status travis][travis-image]][travis-url]
[![Build Status appveyor][appveyor-image]][appveyor-url]

[travis-image]: https://travis-ci.org/paritytech/parity-common.svg?branch=master
[travis-url]: https://travis-ci.org/paritytech/parity-common
[appveyor-image]: https://ci.appveyor.com/api/projects/status/github/paritytech/parity-common/branch/master?svg=true
[appveyor-url]: https://ci.appveyor.com/project/paritytech/parity-common/branch/master

# parity-common
Collection of crates used in [Parity Technologies](https://www.paritytech.io/) projects
29 changes: 29 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
environment:
matrix:
- FEATURES: ""

platform:
- x86_64-pc-windows-msvc

# avoid running tests twice
branches:
only:
- master

install:
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
- rustup-init.exe -y --default-host %PLATFORM%
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- rustc -vV
- cargo -vV

build_script:
- cargo check --tests --features "%FEATURES%"
- cargo build --all --features "%FEATURES%"

test_script:
- cargo test --all --features "%FEATURES%" --exclude uint --exclude fixed-hash
- cd fixed-hash/ && cargo test --all-features && cd ..
- cd uint/ && cargo test --features=std,quickcheck --release && cd ..
- cd plain_hasher/ && cargo test --no-default-features && cd ..
- cd parity-util-mem/ && cargo test --features=estimate-heapsize && cd ..
2 changes: 1 addition & 1 deletion fixed-hash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fixed-hash"
version = "0.3.1"
version = "0.3.2"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
homepage = "https://github.com/paritytech/parity-common"
Expand Down
2 changes: 1 addition & 1 deletion fixed-hash/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ macro_rules! impl_rand_for_fixed_hash {

/// Assign `self` to a cryptographically random value.
pub fn randomize(&mut self) {
let mut rng = $crate::rand::OsRng::new().unwrap();
let mut rng = $crate::rand::rngs::EntropyRng::new();
self.randomize_using(&mut rng);
}

Expand Down
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
21 changes: 18 additions & 3 deletions parity-crypto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
[package]
name = "parity-crypto"
version = "0.3.0"
version = "0.3.1"
authors = ["Parity Technologies <admin@parity.io>"]
repository = "https://github.com/paritytech/parity-common"
description = "Crypto utils used by ethstore and network."
license = "GPL-3.0"
autobenches = false

[[bench]]
name = "bench"
harness = false


[dependencies]
quick-error = "1.2.2"
ring = "0.14.3"
rust-crypto = "0.2.36"
tiny-keccak = "1.4"
scrypt = { version = "0.1.1", default-features = false }
ripemd160 = "0.8.0"
sha2 = "0.8.0"
digest = "0.8"
aes = "0.3.2"
aes-ctr = "0.3.0"
block-modes = "0.3.3"
ring = "0.14.6"

[dev-dependencies]
criterion = "0.2"
56 changes: 56 additions & 0 deletions parity-crypto/benches/bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.

// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// 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 parity_crypto;

#[macro_use]
extern crate criterion;

use criterion::{Criterion, Bencher};

criterion_group!(benches, input_len);

criterion_main!(benches);

/// general benches for multiple input size
fn input_len(c: &mut Criterion) {

c.bench_function_over_inputs("ripemd",
|b: &mut Bencher, size: &usize| {
let data = vec![0u8; *size];
b.iter(|| parity_crypto::digest::ripemd160(&data[..]));
},
vec![100, 500, 1_000, 10_000, 100_000]
);

c.bench_function_over_inputs("aes_ctr",
|b: &mut Bencher, size: &usize| {
let data = vec![0u8; *size];
let mut dest = vec![0; *size];
let k = [0; 16];
let iv = [0; 16];

b.iter(||{
parity_crypto::aes::encrypt_128_ctr(&k[..], &iv[..], &data[..], &mut dest[..]).unwrap();
// same as encrypt but add it just in case
parity_crypto::aes::decrypt_128_ctr(&k[..], &iv[..], &data[..], &mut dest[..]).unwrap();
});
},
vec![100, 500, 1_000, 10_000, 100_000]
);

}
Loading

0 comments on commit e708a18

Please sign in to comment.