Use sha3 crate in ethash

This commit is contained in:
arkpar
2016-01-18 12:49:39 +01:00
parent 3885cc07e4
commit 77d2303b55
9 changed files with 37 additions and 46 deletions

View File

@@ -5,10 +5,6 @@ license = "GPL-3.0"
name = "ethcore-util"
version = "0.1.0"
authors = ["Ethcore <admin@ethcore.io>"]
build = "build.rs"
[build-dependencies]
gcc = "0.3"
[dependencies]
log = "0.3"
@@ -27,6 +23,7 @@ elastic-array = "0.4"
heapsize = "0.2"
itertools = "0.4"
slab = { git = "https://github.com/arkpar/slab.git" }
sha3 = { path = "sha3" }
[dev-dependencies]
json-tests = { path = "json-tests" }

11
util/sha3/Cargo.toml Normal file
View File

@@ -0,0 +1,11 @@
[package]
description = "Rust bindings for tinykeccak C library"
homepage = "http://ethcore.io"
license = "GPL-3.0"
name = "sha3"
version = "0.1.0"
authors = ["Ethcore <admin@ethcore.io>"]
build = "build.rs"
[build-dependencies]
gcc = "0.3"

4
util/sha3/src/lib.rs Normal file
View File

@@ -0,0 +1,4 @@
extern {
pub fn sha3_256(out: *mut u8, outlen: usize, input: *const u8, inputlen: usize) -> i32;
pub fn sha3_512(out: *mut u8, outlen: usize, input: *const u8, inputlen: usize) -> i32;
}

View File

@@ -1,14 +1,13 @@
//! Wrapper around tiny-keccak crate.
extern crate sha3 as sha3_ext;
use std::mem::uninitialized;
use bytes::{BytesConvertable, Populatable};
use hash::{H256, FixedHash};
use self::sha3_ext::*;
pub const SHA3_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] );
extern {
fn sha3_256(out: *mut u8, outlen: usize, input: *const u8, inputlen: usize) -> i32;
}
/// Types implementing this trait are sha3able.
///