Skip to content

Commit af65199

Browse files
refactor: use k256 std feature instead of custom critical-section impl
Simpler approach - no custom code needed. Slightly larger WASM (+4K) but cleaner codebase.
1 parent 15cc9ed commit af65199

3 files changed

Lines changed: 4 additions & 36 deletions

File tree

packages/wasm-bip32/Cargo.lock

Lines changed: 3 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/wasm-bip32/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ k256 = { version = "0.13", default-features = false, features = [
2121
"sha256",
2222
"alloc",
2323
"precomputed-tables",
24-
"critical-section",
24+
"std",
2525
] }
2626
sha2 = { version = "0.10", default-features = false }
2727
ripemd = { version = "0.1", default-features = false }
@@ -30,8 +30,6 @@ bs58 = { version = "0.5", default-features = false, features = [
3030
"alloc",
3131
] }
3232
getrandom = { version = "0.2", features = ["js"] }
33-
# Provide critical-section implementation for WASM (single-threaded, so no-op)
34-
critical-section = "1.2"
3533

3634
[dev-dependencies]
3735
wasm-bindgen-test = "0.3"

packages/wasm-bip32/src/lib.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,3 @@ mod message;
66
pub use bip32::WasmBIP32;
77
pub use ecpair::WasmECPair;
88
pub use error::WasmBip32Error;
9-
10-
// Provide a no-op critical section implementation for single-threaded WASM
11-
use critical_section::RawRestoreState;
12-
13-
struct SingleThreadedCs;
14-
critical_section::set_impl!(SingleThreadedCs);
15-
16-
unsafe impl critical_section::Impl for SingleThreadedCs {
17-
unsafe fn acquire() -> RawRestoreState {
18-
// WASM is single-threaded, no actual locking needed
19-
}
20-
21-
unsafe fn release(_restore_state: RawRestoreState) {
22-
// WASM is single-threaded, no actual unlocking needed
23-
}
24-
}

0 commit comments

Comments
 (0)