Skip to content

Commit 0a495f7

Browse files
hitchhoclaude
andcommitted
Add WASM ECIES test for subxt-signer
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3374cad commit 0a495f7

3 files changed

Lines changed: 58 additions & 4 deletions

File tree

signer/tests/wasm/Cargo.lock

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

signer/tests/wasm/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ subxt-signer = { path = "../../", default-features = false, features = [
1717
"web",
1818
"sr25519",
1919
"ecdsa",
20+
"ecies",
2021
"unstable-eth",
2122
"std",
2223
] }

signer/tests/wasm/tests/wasm.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,27 @@ async fn wasm_sr25519_signing_works() {
2929
));
3030
}
3131

32+
#[wasm_bindgen_test]
33+
async fn wasm_sr25519_ecies_works() {
34+
let alice = sr25519::dev::alice();
35+
let bob = sr25519::dev::bob();
36+
37+
let plaintext = b"hello from wasm";
38+
let ctx = b"wasm-ecies-test";
39+
40+
let encrypted = alice.encrypt(plaintext, &bob.public_key(), ctx)
41+
.expect("encryption failed");
42+
let decrypted = bob.decrypt(&encrypted, ctx)
43+
.expect("decryption failed");
44+
45+
assert_eq!(&decrypted[..], plaintext);
46+
47+
// Wrong key should fail
48+
assert!(alice.decrypt(&encrypted, ctx).is_err());
49+
// Wrong context should fail
50+
assert!(bob.decrypt(&encrypted, b"wrong-ctx").is_err());
51+
}
52+
3253
#[wasm_bindgen_test]
3354
async fn wasm_ecdsa_signing_works() {
3455
let alice = ecdsa::dev::alice();

0 commit comments

Comments
 (0)