Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] fix: use sha3 keccak256 lib #91

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ readme = "README.md"
[dependencies]
serde = "^1.0"
serde_derive = "^1.0"
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
secp256k1 = {version = "0.27.0", features = ["recovery"] }
rlp = "0.5.2"
num-traits = "0.2"
bytes = "^1.4.0"
hex = "0.4.3"
sha3 = "0.10.8"

[dev-dependencies]
ethereum-types= "0.14"
Expand Down
10 changes: 4 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern crate hex;
extern crate num_traits;
extern crate rlp;
extern crate secp256k1;
extern crate tiny_keccak;
extern crate sha3;

#[cfg(test)]
extern crate ethereum_types;
Expand All @@ -21,7 +21,7 @@ use serde::de::Error as SerdeErr;
use serde::ser::SerializeSeq;
use serde::Deserialize;
use std::convert::TryInto;
use tiny_keccak::{Hasher, Keccak};
use sha3::{Keccak256, Digest};

/// Ethereum transaction
pub trait Transaction {
Expand Down Expand Up @@ -555,11 +555,9 @@ impl EcdsaSig {
}

fn keccak256_hash(bytes: &[u8]) -> [u8; 32] {
let mut hasher = Keccak::v256();
let mut hasher = Keccak256::new();
hasher.update(bytes);
let mut resp: [u8; 32] = Default::default();
hasher.finalize(&mut resp);
resp
hasher.finalize().into()
}

#[cfg(test)]
Expand Down