Skip to content

Commit

Permalink
bump crate versions
Browse files Browse the repository at this point in the history
* bump `tiny-keccak` to v2
* bump sha2 to v0.10.8

Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele committed Nov 21, 2024
1 parent 7fe83cc commit d44f678
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 50 deletions.
19 changes: 5 additions & 14 deletions Cargo.lock

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

39 changes: 15 additions & 24 deletions enclave/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 enclave/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tendermint-lc = { path = "../modules/tendermint-lc", default-features = false }

[patch."crates-io"]
# TODO these patches would be better as optional
sha2-0106 = { git = "https://github.com/bluele/hashes", branch = "0.10.6-sha256-hwa-disabled", package = "sha2" }
sha2-0106 = { git = "https://github.com/bluele/hashes", branch = "0.10.8-sha256-hwa-disabled", package = "sha2" }
sha2-099 = { git = "https://github.com/bluele/hashes", branch = "0.9.9-sha256-hwa-disabled", package = "sha2" }

[profile.release]
Expand Down
2 changes: 1 addition & 1 deletion modules/commitments/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
serde = { version = "1.0.184", default-features = false, features = ["alloc"] }
prost = { version = "0.11", default-features = false }
hex = { version = "0.4", default-features = false, features = ["alloc"] }
sha2 = { version = "0.10.6", default-features = false }
sha2 = { version = "0.10.8", default-features = false }
flex-error = { version = "0.4.4", default-features = false }
alloy-sol-types = { version = "0.8", default-features = false }

Expand Down
2 changes: 1 addition & 1 deletion modules/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sgx_trts = { rev = "v1.1.6", git = "https://github.com/apache/incubator-teaclave
sgx_tseal = { rev = "v1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", optional = true }

rand = { version = "0.8", default-features = false, optional = true }
tiny-keccak = "1.4"
tiny-keccak = "2.0"
serde = { version = "1.0.184", default-features = false, features = ["alloc", "derive"] }
serde-big-array = "0.5.1"
hex = { version = "0.4", default-features = false, features = ["alloc"] }
Expand Down
4 changes: 2 additions & 2 deletions modules/crypto/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use libsecp256k1::{
use serde::{Deserialize, Serialize};
use serde_big_array::BigArray;
use sgx_types::sgx_sealed_data_t;
use tiny_keccak::Keccak;
use tiny_keccak::{Hasher, Keccak};
use zeroize::Zeroizing;

pub struct EnclaveKey {
Expand Down Expand Up @@ -223,7 +223,7 @@ pub fn verify_signature_address(sign_bytes: &[u8], signature: &[u8]) -> Result<A
}

fn keccak256(bz: &[u8]) -> [u8; 32] {
let mut keccak = Keccak::new_keccak256();
let mut keccak = Keccak::v256();
let mut result = [0u8; 32];
keccak.update(bz);
keccak.finalize(result.as_mut());
Expand Down
4 changes: 2 additions & 2 deletions modules/crypto/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::prelude::*;
use crate::EnclavePublicKey;
use crate::Error;
use crate::SealedEnclaveKey;
use tiny_keccak::Keccak;
use tiny_keccak::{Hasher, Keccak};

pub trait Verifier {
fn verify(&self, msg: &[u8], signature: &[u8]) -> Result<(), Error>;
Expand All @@ -27,7 +27,7 @@ pub trait Keccak256 {

impl Keccak256 for [u8] {
fn keccak256(&self) -> [u8; 32] {
let mut keccak = Keccak::new_keccak256();
let mut keccak = Keccak::v256();
let mut result = [0u8; 32];
keccak.update(self);
keccak.finalize(result.as_mut());
Expand Down
2 changes: 1 addition & 1 deletion modules/lcp-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ prost = { version = "0.11", default-features = false }
serde = { version = "1.0.184", default-features = false, features = ["alloc", "derive"] }
serde_json = { version = "1.0", default-features = false }
flex-error = { version = "0.4.4", default-features = false }
tiny-keccak = { version = "1.4" }
tiny-keccak = { version = "2.0" }
hex-literal = { version = "0.4.1" }
alloy-sol-types = { version = "0.8", default-features = false }

Expand Down
8 changes: 4 additions & 4 deletions modules/lcp-client/src/client_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use light_client::commitments::{
};
use light_client::types::{ClientId, Height, Time};
use light_client::{HostClientKeeper, HostClientReader};
use tiny_keccak::Keccak;
use tiny_keccak::{Hasher, Keccak};

pub const LCP_CLIENT_TYPE: &str = "0000-lcp";

Expand Down Expand Up @@ -438,7 +438,7 @@ impl LCPClient {
pub fn compute_eip712_register_enclave_key(avr: &str) -> Vec<u8> {
// 0x1901 | DOMAIN_SEPARATOR_REGISTER_ENCLAVE_KEY | keccak256(keccak256("RegisterEnclaveKey(string avr)") | keccak256(avr))
let type_hash = {
let mut h = Keccak::new_keccak256();
let mut h = Keccak::v256();
h.update(&keccak256(b"RegisterEnclaveKey(string avr)"));
h.update(&keccak256(avr.as_bytes()));
let mut result = [0u8; 32];
Expand Down Expand Up @@ -491,7 +491,7 @@ pub fn compute_eip712_update_operators(
thresholdNumerator: threshold_numerator,
thresholdDenominator: threshold_denominator,
};
let mut h = Keccak::new_keccak256();
let mut h = Keccak::v256();
let bz = eip712_update_operator.abi_encode();
h.update(&bz);
let mut result = [0u8; 32];
Expand Down Expand Up @@ -566,7 +566,7 @@ fn enclave_key_path(client_id: &ClientId, ek: Address) -> Vec<u8> {
}

fn keccak256(bz: &[u8]) -> [u8; 32] {
let mut keccak = Keccak::new_keccak256();
let mut keccak = Keccak::v256();
let mut result = [0u8; 32];
keccak.update(bz);
keccak.finalize(result.as_mut());
Expand Down

0 comments on commit d44f678

Please sign in to comment.