Skip to content

Commit

Permalink
Use sha3 instead of tiny-keccak
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson committed Aug 1, 2024
1 parent 6b2c564 commit 753529c
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 46 deletions.
36 changes: 20 additions & 16 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion checksums.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
3d659b15f2aad5f9350f55ce471806c6d6ad4f51a555a82b7918e9d88f84f04a build/release/ccc-btc-lock
66861394d68c78a0d7fc23355b2e33390f88700b1d0dea824c820dc2be9ddaf5 build/release/ccc-eth-lock
4ae08bd7ed954997dcbca5ff88700bf7f949b1080c2bd1cb024f15c8b0436396 build/release/ccc-eth-lock
4 changes: 2 additions & 2 deletions contracts/ccc-eth-lock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ edition = "2021"
[dependencies]
ckb-std = "0.15"
ckb-lock-helper = { path = "../../crates/ckb-lock-helper" }
k256 = { version = "=0.13.1", default-features = false, features = ["arithmetic", "ecdsa", "alloc"] }
hex = { version = "0.4", default-features = false, features = ["alloc"] }
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
k256 = { version = "=0.13.1", default-features = false, features = ["arithmetic", "ecdsa", "alloc"] }
sha3 = { version = "0.10.8", default-features = false }
8 changes: 3 additions & 5 deletions contracts/ccc-eth-lock/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ use ckb_std::{
high_level::{load_script, load_witness_args},
};
use k256::ecdsa::{RecoveryId, Signature};
use tiny_keccak::Hasher;
use sha3::Digest;

fn keccak(msg: &[u8]) -> [u8; 32] {
let mut output = [0u8; 32];
let mut hasher = tiny_keccak::Keccak::v256();
let mut hasher = sha3::Keccak256::new();
hasher.update(msg);
hasher.finalize(&mut output);
output
hasher.finalize().into()
}

fn keccak160(msg: &[u8]) -> [u8; 20] {
Expand Down
36 changes: 20 additions & 16 deletions tests/Cargo.lock

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

2 changes: 1 addition & 1 deletion tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ k256 = "0.13.1"
ripemd = "0.1.3"
serde_json = "1.0"
sha2 = "0.10.8"
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
sha3 = "0.10.8"
8 changes: 3 additions & 5 deletions tests/src/test_eth.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use crate::common::{assert_script_error, generate_sighash_all, println_hex};
use crate::core::{Pickaxer, Resource, Verifier};
use ckb_types::prelude::{Builder, Entity, Pack};
use tiny_keccak::Hasher;
use sha3::Digest;

static BINARY_CCC_LOCK_ETH: &[u8] = include_bytes!("../../build/release/ccc-eth-lock");

fn keccak(msg: &[u8]) -> [u8; 32] {
let mut output = [0u8; 32];
let mut hasher = tiny_keccak::Keccak::v256();
let mut hasher = sha3::Keccak256::new();
hasher.update(msg);
hasher.finalize(&mut output);
output
hasher.finalize().into()
}

fn keccak160(msg: &[u8]) -> [u8; 20] {
Expand Down

0 comments on commit 753529c

Please sign in to comment.