RustCrypto / RustCrypto/elliptic-curves
k256 signal: 10, SIGBUS: access to undefined memory
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 874
- Forks
- 299
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 12
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Cargo.toml feature configuration and the lib.rs reproduction, then run the provided wasm32-unknown-emscripten command with the default features enabled. Trace the precomputed-tables path used by sign_prehash_recoverable and verify that the test completes without the SIGBUS error while retaining the default configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- cryptography
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100