Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

k256 signal: 10, SIGBUS: access to undefined memory #886

Open
satoshiotomakan opened this issue Apr 25, 2023 · 1 comment
Open

k256 signal: 10, SIGBUS: access to undefined memory #886

satoshiotomakan opened this issue Apr 25, 2023 · 1 comment

Comments

@satoshiotomakan
Copy link

satoshiotomakan commented Apr 25, 2023

When I try to call SigningKey::sign_prehash_recoverable in wasm32-unknown-emscripten, I get the following error:

10, SIGBUS: access to undefined memory

The problems seems to be with the precomputed-tables feature enabled by default.

How to test:

# Cargo.toml

[package]
name = "k256-test"
version = "0.1.0"
edition = "2021"

[dependencies]
hex = "0.4.3"
k256 = "0.13.0"
# The fix:
# k256 = { version = "0.13.0", features = ["ecdh", "ecdsa", "schnorr", "std"], default-features = false }
// lib.rs

use k256::ecdsa::SigningKey;

#[test]
fn test_ecdsa_sign() {
  let secret = hex::decode("afeefca74d9a325cf1d6b6911d61a65c32afa8e02bd5e78e2e4ac2910bab45f5").unwrap();
  let signing = SigningKey::from_slice(&secret);
  let hash = hex::decode("1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8").unwrap();

  let (_signature, _recovery_id) = signing.sign_prehash_recoverable(&hash).unwrap();
}

To run the test (emsdk should be installed already).

source path/to/emsdk/emsdk_env.sh
CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node cargo test --target wasm32-unknown-emscripten --release
@tarcieri
Copy link
Member

cc @fjarri

If this is true, it seems like a bug in once_cell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@tarcieri @satoshiotomakan and others