Skip to content

Commit

Permalink
rand_seeder & ed25519-dalek no longer wasm-incompatible
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Aug 26, 2024
1 parent 12d3da5 commit 259aaf2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
6 changes: 3 additions & 3 deletions vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ categories = ["cryptography::cryptocurrencies", "development-tools::debugging"]

[features]
# not supported when compiling to wasm
wasm-incompatible = ["rand", "rand_seeder", "ed25519-dalek"]
wasm-incompatible = ["rand"]

[dependencies]
num-bigint = "0.4"
Expand All @@ -31,8 +31,8 @@ hex-literal = "=0.4.1"
bitflags = "=2.6.0"
colored = "2.1.0"
rand = { version= "0.8.5", optional = true }
rand_seeder = { version= "0.3.0", optional = true }
ed25519-dalek = { version = "2.1.0" , optional = true }
rand_seeder = "0.3.0"
ed25519-dalek = "2.1.0"

[dependencies.multiversx-chain-vm-executor]
version = "0.2.0"
8 changes: 1 addition & 7 deletions vm/src/crypto_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ pub fn keccak256(data: &[u8]) -> [u8; KECCAK256_RESULT_LEN] {
hasher.finalize().into()
}

#[cfg(feature = "wasm-incompatible")]
pub fn verify_ed25519(key: &[u8], message: &[u8], signature: &[u8]) -> bool {
use ed25519_dalek::{Signature, VerifyingKey, Verifier};
use ed25519_dalek::{Signature, Verifier, VerifyingKey};

let key_32: [u8; 32] = if let Ok(key_32) = key.try_into() {
key_32
Expand All @@ -43,8 +42,3 @@ pub fn verify_ed25519(key: &[u8], message: &[u8], signature: &[u8]) -> bool {
let result = verifying_key.verify(message, &sig);
result.is_ok()
}

#[cfg(not(feature = "wasm-incompatible"))]
pub fn verify_ed25519(_key: &[u8], _message: &[u8], _signature: &[u8]) -> bool {
panic!("verify_ed25519 not supported for wasm builds, feature `wasm-incompatible` needs to be enabled")
}

0 comments on commit 259aaf2

Please sign in to comment.