Skip to content

Commit

Permalink
Revert to host keccak fuctions
Browse files Browse the repository at this point in the history
  • Loading branch information
k06a committed Feb 3, 2020
1 parent 9d32114 commit 0e702d0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 51 deletions.
30 changes: 0 additions & 30 deletions ethbridge/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions ethtypes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
derive_more = "^0.99.2"
21 changes: 2 additions & 19 deletions ethtypes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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
}

0 comments on commit 0e702d0

Please sign in to comment.