Skip to content

Commit

Permalink
[rooch-networkgh-2152] update ripemd160 from rust crypto.
Browse files Browse the repository at this point in the history
  • Loading branch information
Feliciss committed Jul 11, 2024
1 parent ab3bb17 commit 697f9f0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ uuid = { version = "1.10.0", features = ["v4", "fast-rng"] }
protobuf = { version = "2.28", features = ["with-bytes"] }
redb = { version = "2.1.1" }
rust-rocksdb = { version = "0.27.0", features = ["lz4", "jemalloc"] }

ripemd = { version = "0.1.3" }

# Note: the BEGIN and END comments below are required for external tooling. Do not remove.
# BEGIN MOVE DEPENDENCIES
Expand Down
1 change: 1 addition & 0 deletions frameworks/moveos-stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ bech32 = { workspace = true }
bs58 = { workspace = true, features = ["check"] }
revm-precompile = { workspace = true }
revm-primitives = { workspace = true }
ripemd = { workspace = true }

move-binary-format = { workspace = true }
move-bytecode-utils = { workspace = true }
Expand Down
7 changes: 5 additions & 2 deletions frameworks/moveos-stdlib/src/natives/moveos_stdlib/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use crate::natives::helpers::{make_module_natives, make_native};
use fastcrypto::hash::{Blake2b256, HashFunction, Keccak256, Ripemd160};
use fastcrypto::hash::{Blake2b256, HashFunction, HashFunctionWrapper, Keccak256};
use ripemd::Ripemd160;
use move_binary_format::errors::PartialVMResult;
use move_core_types::gas_algebra::{InternalGas, InternalGasPerByte, NumBytes};
use move_vm_runtime::native_functions::{NativeContext, NativeFunction};
Expand All @@ -15,6 +16,8 @@ use move_vm_types::{
use smallvec::smallvec;
use std::collections::VecDeque;

type Ripemd160Hash = HashFunctionWrapper<Ripemd160, 20>;

fn hash<H: HashFunction<DIGEST_SIZE>, const DIGEST_SIZE: usize>(
gas_params: &FromBytesGasParameters,
_: &mut NativeContext,
Expand Down Expand Up @@ -82,7 +85,7 @@ pub fn native_ripemd160(
ty_args: Vec<Type>,
args: VecDeque<Value>,
) -> PartialVMResult<NativeResult> {
hash::<Ripemd160, 20>(gas_params, context, ty_args, args)
hash::<Ripemd160Hash, 20>(gas_params, context, ty_args, args)
}

#[derive(Debug, Clone)]
Expand Down

0 comments on commit 697f9f0

Please sign in to comment.