From 0e702d0a059d90dc7b843b7760e90eb0530a200c Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Mon, 3 Feb 2020 19:46:19 -0300 Subject: [PATCH] Revert to host keccak fuctions --- ethbridge/Cargo.lock | 30 ------------------------------ ethtypes/Cargo.toml | 3 +-- ethtypes/src/lib.rs | 21 ++------------------- 3 files changed, 3 insertions(+), 51 deletions(-) diff --git a/ethbridge/Cargo.lock b/ethbridge/Cargo.lock index 91aa05e92..00dc9cbd8 100644 --- a/ethbridge/Cargo.lock +++ b/ethbridge/Cargo.lock @@ -321,7 +321,6 @@ dependencies = [ "rlp_derive 0.1.0 (git+https://github.com/paritytech/parity-ethereum/)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (git+https://github.com/nearprotocol/json?rev=1f5779f3b0bd3d2a4b0b975abc46f3d3fe873331)", - "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -894,29 +893,6 @@ dependencies = [ "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "near-rpc-error-core" -version = "0.1.0" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "near-rpc-error-macro" -version = "0.1.0" -dependencies = [ - "near-rpc-error-core 0.1.0", - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "near-runtime-fees" version = "0.4.3" @@ -927,11 +903,6 @@ dependencies = [ [[package]] name = "near-vm-errors" version = "0.4.3" -dependencies = [ - "borsh 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "near-rpc-error-macro 0.1.0", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "near-vm-logic" @@ -1511,7 +1482,6 @@ name = "serde_json" version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ethtypes/Cargo.toml b/ethtypes/Cargo.toml index d56779c0c..efe9ed6da 100644 --- a/ethtypes/Cargo.toml +++ b/ethtypes/Cargo.toml @@ -15,5 +15,4 @@ borsh = "0.2.10" rlp = "0.4.2" rlp_derive = { git = "https://github.com/paritytech/parity-ethereum/" } ethereum-types = "0.8.0" -derive_more = "^0.99.2" -sha3 = "0.8" \ No newline at end of file +derive_more = "^0.99.2" \ No newline at end of file diff --git a/ethtypes/src/lib.rs b/ethtypes/src/lib.rs index 3341b1a94..8559c725e 100644 --- a/ethtypes/src/lib.rs +++ b/ethtypes/src/lib.rs @@ -5,7 +5,6 @@ use ethereum_types; use borsh::{BorshDeserialize, BorshSerialize}; use serde::{Serialize, Deserialize}; use derive_more::{Add, Sub, Mul, Div, Rem, AddAssign, SubAssign, MulAssign, DivAssign, RemAssign, Display, From, Into}; -use sha3::{Keccak256, Keccak512}; macro_rules! arr_declare_wrapper_and_serde { ($name: ident, $len: expr) => { @@ -237,29 +236,13 @@ pub fn near_sha256(data: &[u8]) -> [u8; 32] { } pub fn near_keccak256(data: &[u8]) -> [u8; 32] { - // let mut buffer = [0u8; 32]; - // buffer.copy_from_slice(&near_bindgen::env::keccak256(data).as_slice()); - // buffer - - use sha3::Digest; - - let mut hasher = Keccak256::default(); - hasher.input(&data); let mut buffer = [0u8; 32]; - buffer.copy_from_slice(hasher.result().as_slice()); + buffer.copy_from_slice(&near_bindgen::env::keccak256(data).as_slice()); buffer } pub fn near_keccak512(data: &[u8]) -> [u8; 64] { - // let mut buffer = [0u8; 64]; - // buffer.copy_from_slice(&near_bindgen::env::keccak512(data).as_slice()); - // buffer - - use sha3::Digest; - - let mut hasher = Keccak512::default(); - hasher.input(&data); let mut buffer = [0u8; 64]; - buffer.copy_from_slice(hasher.result().as_slice()); + buffer.copy_from_slice(&near_bindgen::env::keccak512(data).as_slice()); buffer }