From 9028fca302f9fc2dbe0e03448f5f695865c7fbf5 Mon Sep 17 00:00:00 2001 From: "glm-5.2" Date: Tue, 23 Jun 2026 13:20:28 +0000 Subject: [PATCH] =?UTF-8?q?refactor(vault):=20remove=20irpc=20actor=20disp?= =?UTF-8?q?atch=20=E2=80=94=20direct=20method=20calls=20on=20VaultServiceH?= =?UTF-8?q?andle=20(ADR-025)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop the irpc-based actor dispatch path from alknet-vault and convert to direct method calls on VaultServiceHandle (drift item #4, ADR-025). Removed: - VaultProtocol enum with #[rpc_requests] derive from protocol.rs - VaultServiceActor (mpsc + oneshot dispatch loop) from service.rs - VaultService wrapper struct (only the handle is needed) - Client usage - irpc, irpc-derive, tokio from [dependencies] - postcard from [dev-dependencies] - VaultMessage/VaultProtocol/VaultServiceActor re-exports from lib.rs - Serialize/Deserialize derives from VaultServiceError - postcard round-trip tests from protocol.rs - actor tokio::test tests from service.rs The vault now has zero async runtime dependency and zero RPC framework dependency — it is local-only by construction. VaultServiceHandle is the sole API: Arc> with synchronous methods. lib.rs re-exports match the vault README Public API section. Also fixes pre-existing clippy field_reassign_with_default warnings in cache.rs tests so cargo clippy -- -D warnings passes. --- Cargo.lock | 1591 +-------------------------- crates/alknet-vault/Cargo.toml | 6 +- crates/alknet-vault/src/cache.rs | 24 +- crates/alknet-vault/src/lib.rs | 11 +- crates/alknet-vault/src/protocol.rs | 173 +-- crates/alknet-vault/src/service.rs | 327 +----- 6 files changed, 66 insertions(+), 2066 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c67965..3daf0fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,7 +20,7 @@ checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", "cipher", - "cpufeatures 0.2.17", + "cpufeatures", ] [[package]] @@ -37,15 +37,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "aho-corasick" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" -dependencies = [ - "memchr", -] - [[package]] name = "alknet-vault" version = "0.1.0" @@ -56,85 +47,21 @@ dependencies = [ "ed25519-bip32", "hex", "hmac", - "irpc", - "irpc-derive", - "postcard", - "rand 0.8.6", + "rand", "secp256k1", "serde", "serde_json", "sha2", "thiserror", - "tokio", "zeroize", ] -[[package]] -name = "anyhow" -version = "1.0.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" - [[package]] name = "arrayvec" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" -[[package]] -name = "asn1-rs" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f43a50ac4fdca5df8e885c21b835997f0a1cdee65494a6847694a98652d9d8" -dependencies = [ - "asn1-rs-derive", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror", - "time", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "asn1-rs-impl" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "atomic-polyfill" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" -dependencies = [ - "critical-section", -] - -[[package]] -name = "autocfg" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" - [[package]] name = "base64" version = "0.22.1" @@ -148,21 +75,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90dbd31c98227229239363921e60fcf5e558e43ec69094d46fc4996f08d1d5bc" dependencies = [ "bitcoin_hashes", - "rand 0.8.6", - "rand_core 0.6.4", + "rand", + "rand_core", "serde", "unicode-normalization", ] -[[package]] -name = "bit-vec" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" -dependencies = [ - "serde", -] - [[package]] name = "bitcoin_hashes" version = "0.14.100" @@ -172,12 +90,6 @@ dependencies = [ "hex-conservative", ] -[[package]] -name = "bitflags" -version = "2.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84d7ced0ae9557296835c32bf1b1e02b44c746701f898460fb000d7eaa84f00a" - [[package]] name = "block-buffer" version = "0.10.4" @@ -187,24 +99,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bumpalo" -version = "3.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "bytes" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" - [[package]] name = "cc" version = "1.2.63" @@ -221,23 +115,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" -[[package]] -name = "cfg_aliases" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" - -[[package]] -name = "chacha20" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.0", - "rand_core 0.10.1", -] - [[package]] name = "cipher" version = "0.4.4" @@ -248,34 +125,6 @@ dependencies = [ "inout", ] -[[package]] -name = "cobs" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" -dependencies = [ - "thiserror", -] - -[[package]] -name = "convert_case" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "cordyceps" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688d7fbb8092b8de775ef2536f36c8c31f2bc4006ece2e8d8ad2d17d00ce0a2a" -dependencies = [ - "loom", - "tracing", -] - [[package]] name = "cpufeatures" version = "0.2.17" @@ -285,21 +134,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cpufeatures" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" -dependencies = [ - "libc", -] - -[[package]] -name = "critical-section" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" - [[package]] name = "crypto-common" version = "0.1.7" @@ -307,7 +141,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "typenum", ] @@ -326,64 +160,6 @@ dependencies = [ "cipher", ] -[[package]] -name = "data-encoding" -version = "2.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8" - -[[package]] -name = "der-parser" -version = "10.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07da5016415d5a3c4dd39b11ed26f915f52fc4e0dc197d87908bc916e51bc1a6" -dependencies = [ - "asn1-rs", - "displaydoc", - "nom", - "num-bigint", - "num-traits", - "rusticata-macros", -] - -[[package]] -name = "deranged" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" -dependencies = [ - "powerfmt", -] - -[[package]] -name = "derive_more" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" -dependencies = [ - "derive_more-impl", -] - -[[package]] -name = "derive_more-impl" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn", - "unicode-xid", -] - -[[package]] -name = "diatomic-waker" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab03c107fafeb3ee9f5925686dbb7a73bc76e3932abb0d2b365cb64b169cf04c" - [[package]] name = "digest" version = "0.10.7" @@ -395,17 +171,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "displaydoc" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "ed25519-bip32" version = "0.4.2" @@ -415,143 +180,12 @@ dependencies = [ "cryptoxide", ] -[[package]] -name = "embedded-io" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" - -[[package]] -name = "embedded-io" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" - -[[package]] -name = "enum-assoc" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed8956bd5c1f0415200516e78ff07ec9e16415ade83c056c230d7b7ea0d55b7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - -[[package]] -name = "fastrand" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" - [[package]] name = "find-msvc-tools" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - -[[package]] -name = "futures-buffered" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4421cb78ee172b6b06080093479d3c50f058e7c81b7d577bbb8d118d551d4cd5" -dependencies = [ - "cordyceps", - "diatomic-waker", - "futures-core", - "pin-project-lite", - "spin 0.10.0", -] - -[[package]] -name = "futures-core" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" - -[[package]] -name = "futures-io" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" - -[[package]] -name = "futures-lite" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "parking", - "pin-project-lite", -] - -[[package]] -name = "futures-macro" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" - -[[package]] -name = "futures-task" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" - -[[package]] -name = "futures-util" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" -dependencies = [ - "futures-core", - "futures-macro", - "futures-sink", - "futures-task", - "pin-project-lite", - "slab", -] - -[[package]] -name = "generator" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3b854b0e584ead1a33f18b2fcad7cf7be18b3875c78816b753639aa501513ae" -dependencies = [ - "cc", - "cfg-if", - "libc", - "log", - "rustversion", - "windows-link", - "windows-result", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -569,26 +203,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi", - "wasm-bindgen", -] - -[[package]] -name = "getrandom" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "r-efi", - "rand_core 0.10.1", - "wasip2", - "wasip3", - "wasm-bindgen", ] [[package]] @@ -601,50 +217,6 @@ dependencies = [ "polyval", ] -[[package]] -name = "hash32" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash", -] - -[[package]] -name = "hashbrown" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" - -[[package]] -name = "heapless" -version = "0.7.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" -dependencies = [ - "atomic-polyfill", - "hash32", - "rustc_version", - "serde", - "spin 0.9.8", - "stable_deref_trait", -] - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - [[package]] name = "hex" version = "0.4.3" @@ -669,30 +241,6 @@ dependencies = [ "digest", ] -[[package]] -name = "id-arena" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" - -[[package]] -name = "identity-hash" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfdd7caa900436d8f13b2346fe10257e0c05c1f1f9e351f4f5d57c03bd5f45da" - -[[package]] -name = "indexmap" -version = "2.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" -dependencies = [ - "equivalent", - "hashbrown 0.17.1", - "serde", - "serde_core", -] - [[package]] name = "inout" version = "0.1.4" @@ -702,361 +250,30 @@ dependencies = [ "generic-array", ] -[[package]] -name = "irpc" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a05799eb70acd04843c327ef939233ccf80f607d30e9ca94857ac7f3d8f18b46" -dependencies = [ - "futures-buffered", - "futures-util", - "irpc-derive", - "n0-error", - "n0-future", - "noq", - "postcard", - "rcgen", - "rustls", - "serde", - "smallvec", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "irpc-derive" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445d81dbc1eed4dab6379bf7f97d12ac28ce8e6f3f7d6660c9f333b7b5d8d03b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "itoa" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" -[[package]] -name = "js-sys" -version = "0.3.99" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142bc4740e452c1e57ade0cbc129f139c9093e354346f0872ef985f4f5cf5f11" -dependencies = [ - "cfg-if", - "futures-util", - "once_cell", - "wasm-bindgen", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "leb128fmt" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" - [[package]] name = "libc" version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" -[[package]] -name = "lock_api" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a" - -[[package]] -name = "loom" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca" -dependencies = [ - "cfg-if", - "generator", - "scoped-tls", - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "lru-slab" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" - -[[package]] -name = "matchers" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" -dependencies = [ - "regex-automata", -] - [[package]] name = "memchr" version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8" -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - -[[package]] -name = "mio" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda" -dependencies = [ - "libc", - "wasi", - "windows-sys 0.61.2", -] - -[[package]] -name = "n0-error" -version = "1.0.0-rc.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "223e946a84aa91644507a6b7865cfebbb9a231ace499041c747ab0fd30408212" -dependencies = [ - "n0-error-macros", - "spez", -] - -[[package]] -name = "n0-error-macros" -version = "1.0.0-rc.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "565305a21e6b3bf26640ad98f05a0fda12d3ab4315394566b52a7bddb8b34828" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "n0-future" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2ab99dfb861450e68853d34ae665243a88b8c493d01ba957321a1e9b2312bbe" -dependencies = [ - "cfg_aliases", - "derive_more", - "futures-buffered", - "futures-lite", - "futures-util", - "js-sys", - "pin-project", - "send_wrapper", - "tokio", - "tokio-util", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-time", -] - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "noq" -version = "1.0.0-rc.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "198b99fc085a5db1f7d259edb5ede8311e59f28cdd2687920b4313613d21a73f" -dependencies = [ - "bytes", - "cfg_aliases", - "derive_more", - "noq-proto", - "noq-udp", - "pin-project-lite", - "rustc-hash", - "rustls", - "socket2", - "thiserror", - "tokio", - "tokio-stream", - "tracing", - "web-time", -] - -[[package]] -name = "noq-proto" -version = "1.0.0-rc.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab0ac774795ce1e42a7e61266e71f3be8110210630441169ac8dda403dd23f1" -dependencies = [ - "aes-gcm", - "bytes", - "derive_more", - "enum-assoc", - "getrandom 0.4.2", - "identity-hash", - "lru-slab", - "rand 0.10.1", - "rand_pcg", - "ring", - "rustc-hash", - "rustls", - "rustls-pki-types", - "slab", - "sorted-index-buffer", - "thiserror", - "tinyvec", - "tracing", - "web-time", -] - -[[package]] -name = "noq-udp" -version = "1.0.0-rc.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3c1520eacd33fd6b009e2e70116b05508ade51db5e0d315ff8bf6b702148c2b" -dependencies = [ - "cfg_aliases", - "libc", - "socket2", - "tracing", - "windows-sys 0.61.2", -] - -[[package]] -name = "nu-ansi-term" -version = "0.50.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" -dependencies = [ - "windows-sys 0.61.2", -] - -[[package]] -name = "num-bigint" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-conv" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "oid-registry" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f40cff3dde1b6087cc5d5f5d4d65712f34016a03ed60e9c08dcc392736b5b7" -dependencies = [ - "asn1-rs", -] - -[[package]] -name = "once_cell" -version = "1.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" - [[package]] name = "opaque-debug" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" -[[package]] -name = "parking" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" - -[[package]] -name = "pem" -version = "3.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" -dependencies = [ - "base64", - "serde_core", -] - -[[package]] -name = "pin-project" -version = "1.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" - [[package]] name = "polyval" version = "0.6.2" @@ -1064,30 +281,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" dependencies = [ "cfg-if", - "cpufeatures 0.2.17", + "cpufeatures", "opaque-debug", "universal-hash", ] -[[package]] -name = "postcard" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" -dependencies = [ - "cobs", - "embedded-io 0.4.0", - "embedded-io 0.6.1", - "heapless", - "serde", -] - -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - [[package]] name = "ppv-lite86" version = "0.2.21" @@ -1097,16 +295,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn", -] - [[package]] name = "proc-macro2" version = "1.0.106" @@ -1125,12 +313,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "r-efi" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" - [[package]] name = "rand" version = "0.8.6" @@ -1139,18 +321,7 @@ checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.4", -] - -[[package]] -name = "rand" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207" -dependencies = [ - "chacha20", - "getrandom 0.4.2", - "rand_core 0.10.1", + "rand_core", ] [[package]] @@ -1160,7 +331,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -1169,146 +340,9 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.17", + "getrandom", ] -[[package]] -name = "rand_core" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" - -[[package]] -name = "rand_pcg" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a" -dependencies = [ - "rand_core 0.10.1", -] - -[[package]] -name = "rcgen" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57f6d249aad744e274e682777a50283a225a32705394ee6d5fcc01efa25e4055" -dependencies = [ - "pem", - "ring", - "rustls-pki-types", - "time", - "x509-parser", - "yasna", -] - -[[package]] -name = "regex-automata" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" - -[[package]] -name = "ring" -version = "0.17.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" -dependencies = [ - "cc", - "cfg-if", - "getrandom 0.2.17", - "libc", - "untrusted", - "windows-sys 0.52.0", -] - -[[package]] -name = "rustc-hash" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "rusticata-macros" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" -dependencies = [ - "nom", -] - -[[package]] -name = "rustls" -version = "0.23.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b" -dependencies = [ - "once_cell", - "ring", - "rustls-pki-types", - "rustls-webpki", - "subtle", - "zeroize", -] - -[[package]] -name = "rustls-pki-types" -version = "1.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" -dependencies = [ - "web-time", - "zeroize", -] - -[[package]] -name = "rustls-webpki" -version = "0.103.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" -dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", -] - -[[package]] -name = "rustversion" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" - -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "secp256k1" version = "0.29.1" @@ -1327,18 +361,6 @@ dependencies = [ "cc", ] -[[package]] -name = "semver" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" - -[[package]] -name = "send_wrapper" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" - [[package]] name = "serde" version = "1.0.228" @@ -1389,85 +411,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", - "cpufeatures 0.2.17", + "cpufeatures", "digest", ] -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - [[package]] name = "shlex" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" -[[package]] -name = "slab" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" - -[[package]] -name = "smallvec" -version = "1.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" - -[[package]] -name = "socket2" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51" -dependencies = [ - "libc", - "windows-sys 0.61.2", -] - -[[package]] -name = "sorted-index-buffer" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea06cc588e43c632923a55450401b8f25e628131571d4e1baea1bdfdb2b5ed06" - -[[package]] -name = "spez" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87e960f4dca2788eeb86bbdde8dd246be8948790b7618d656e68f9b720a86e8" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spin" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fe4ccb98d9c292d56fec89a5e07da7fc4cf0dc11e156b41793132775d3e591" - -[[package]] -name = "stable_deref_trait" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" - [[package]] name = "subtle" version = "2.6.1" @@ -1485,17 +438,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "synstructure" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "thiserror" version = "2.0.18" @@ -1516,46 +458,6 @@ dependencies = [ "syn", ] -[[package]] -name = "thread_local" -version = "1.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "time" -version = "0.3.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" -dependencies = [ - "deranged", - "itoa", - "num-conv", - "powerfmt", - "serde_core", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" - -[[package]] -name = "time-macros" -version = "0.2.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" -dependencies = [ - "num-conv", - "time-core", -] - [[package]] name = "tinyvec" version = "1.11.0" @@ -1571,119 +473,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" -[[package]] -name = "tokio" -version = "1.52.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" -dependencies = [ - "bytes", - "libc", - "mio", - "pin-project-lite", - "socket2", - "tokio-macros", - "windows-sys 0.61.2", -] - -[[package]] -name = "tokio-macros" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-stream" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", - "tokio-util", -] - -[[package]] -name = "tokio-util" -version = "0.7.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "futures-util", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tracing" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" -dependencies = [ - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "regex-automata", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", -] - [[package]] name = "typenum" version = "1.20.1" @@ -1705,18 +494,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" - -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - [[package]] name = "universal-hash" version = "0.5.1" @@ -1727,18 +504,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - -[[package]] -name = "valuable" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" - [[package]] name = "version_check" version = "0.9.5" @@ -1751,342 +516,6 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" -[[package]] -name = "wasip2" -version = "1.0.3+wasi-0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" -dependencies = [ - "wit-bindgen 0.57.1", -] - -[[package]] -name = "wasip3" -version = "0.4.0+wasi-0.3.0-rc-2026-01-06" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" -dependencies = [ - "wit-bindgen 0.51.0", -] - -[[package]] -name = "wasm-bindgen" -version = "0.2.122" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed04576f974d2b2fba0f38c51dbc5518011e38c36bf1143164be765528fd409" -dependencies = [ - "cfg-if", - "once_cell", - "rustversion", - "wasm-bindgen-macro", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9473dbd2991ae90b6291c3c32c30c6187ac49aa32f9905d1cce280ec1e110b0f" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.122" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "916151b09da36bd82f6615cbf3a419e2f0ba23a03c6160e8e92eb6bd4aa1dec6" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.122" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "299047362ccbfce148b67ab7e73349f77748e00c8296f9542adfad2ad82c5c5e" -dependencies = [ - "bumpalo", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.122" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a929b2c61f11ba3e9bc35b50c1f25cb38e0e892c0c231ae2b8cf78d5dad4437" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "wasm-encoder" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" -dependencies = [ - "leb128fmt", - "wasmparser", -] - -[[package]] -name = "wasm-metadata" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" -dependencies = [ - "anyhow", - "indexmap", - "wasm-encoder", - "wasmparser", -] - -[[package]] -name = "wasmparser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" -dependencies = [ - "bitflags", - "hashbrown 0.15.5", - "indexmap", - "semver", -] - -[[package]] -name = "web-time" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "windows-link" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" - -[[package]] -name = "windows-result" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-sys" -version = "0.61.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "wit-bindgen" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" -dependencies = [ - "wit-bindgen-rust-macro", -] - -[[package]] -name = "wit-bindgen" -version = "0.57.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" - -[[package]] -name = "wit-bindgen-core" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" -dependencies = [ - "anyhow", - "heck", - "wit-parser", -] - -[[package]] -name = "wit-bindgen-rust" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" -dependencies = [ - "anyhow", - "heck", - "indexmap", - "prettyplease", - "syn", - "wasm-metadata", - "wit-bindgen-core", - "wit-component", -] - -[[package]] -name = "wit-bindgen-rust-macro" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" -dependencies = [ - "anyhow", - "prettyplease", - "proc-macro2", - "quote", - "syn", - "wit-bindgen-core", - "wit-bindgen-rust", -] - -[[package]] -name = "wit-component" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" -dependencies = [ - "anyhow", - "bitflags", - "indexmap", - "log", - "serde", - "serde_derive", - "serde_json", - "wasm-encoder", - "wasm-metadata", - "wasmparser", - "wit-parser", -] - -[[package]] -name = "wit-parser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" -dependencies = [ - "anyhow", - "id-arena", - "indexmap", - "log", - "semver", - "serde", - "serde_derive", - "serde_json", - "unicode-xid", - "wasmparser", -] - -[[package]] -name = "x509-parser" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d43b0f71ce057da06bc0851b23ee24f3f86190b07203dd8f567d0b706a185202" -dependencies = [ - "asn1-rs", - "data-encoding", - "der-parser", - "lazy_static", - "nom", - "oid-registry", - "ring", - "rusticata-macros", - "thiserror", - "time", -] - -[[package]] -name = "yasna" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5f6765e852b9b4dc8e2a76843e4d64d1cea8e79bcde0b6901aea8e7c7f08282" -dependencies = [ - "bit-vec", - "time", -] - [[package]] name = "zerocopy" version = "0.8.50" diff --git a/crates/alknet-vault/Cargo.toml b/crates/alknet-vault/Cargo.toml index b92b81f..497d517 100644 --- a/crates/alknet-vault/Cargo.toml +++ b/crates/alknet-vault/Cargo.toml @@ -25,11 +25,7 @@ zeroize = { version = "1", features = ["derive"] } hmac = "0.12" rand = "0.8" base64 = "0.22" -irpc = { workspace = true } -irpc-derive = { workspace = true } -tokio = { version = "1", features = ["sync", "rt", "macros"] } secp256k1 = { version = "0.29", optional = true } [dev-dependencies] -hex = "0.4" -postcard = { version = "1", features = ["alloc"] } \ No newline at end of file +hex = "0.4" \ No newline at end of file diff --git a/crates/alknet-vault/src/cache.rs b/crates/alknet-vault/src/cache.rs index 1b3e11b..6417b96 100644 --- a/crates/alknet-vault/src/cache.rs +++ b/crates/alknet-vault/src/cache.rs @@ -231,8 +231,10 @@ mod tests { #[test] fn test_cache_expired_entry_evicted_on_access() { - let mut config = CacheConfig::default(); - config.ttl = Duration::from_millis(1); + let config = CacheConfig { + ttl: Duration::from_millis(1), + ..Default::default() + }; let mut cache = KeyCache::new(config); cache.insert("m/74'/0'/0'/0'", make_cached_key(KeyType::Ed25519)); @@ -245,8 +247,10 @@ mod tests { #[test] fn test_cache_lru_eviction() { - let mut config = CacheConfig::default(); - config.max_entries = 3; + let config = CacheConfig { + max_entries: 3, + ..Default::default() + }; let mut cache = KeyCache::new(config); @@ -267,8 +271,10 @@ mod tests { #[test] fn test_cache_lru_access_reorders() { - let mut config = CacheConfig::default(); - config.max_entries = 3; + let config = CacheConfig { + max_entries: 3, + ..Default::default() + }; let mut cache = KeyCache::new(config); @@ -303,8 +309,10 @@ mod tests { #[test] fn test_evict_expired_removes_only_expired() { - let mut config = CacheConfig::default(); - config.ttl = Duration::from_millis(10); + let config = CacheConfig { + ttl: Duration::from_millis(10), + ..Default::default() + }; let mut cache = KeyCache::new(config); cache.insert("path1", make_cached_key(KeyType::Ed25519)); diff --git a/crates/alknet-vault/src/lib.rs b/crates/alknet-vault/src/lib.rs index dfbaacd..a99a73d 100644 --- a/crates/alknet-vault/src/lib.rs +++ b/crates/alknet-vault/src/lib.rs @@ -25,8 +25,8 @@ //! - [`mnemonic`] — BIP39 mnemonic generation, validation, and seed derivation //! - [`derivation`] — SLIP-0010 Ed25519 HD key derivation and path constants //! - [`encryption`] — AES-256-GCM encrypt/decrypt and `EncryptedData` type -//! - [`protocol`] — `VaultProtocol` irpc message enum, `DerivedKey`, `KeyType` -//! - [`service`] — `VaultService` implementation with Unlock/Lock lifecycle +//! - [`protocol`] — `DerivedKey` and `KeyType` (return types from vault methods) +//! - [`service`] — `VaultServiceHandle` runtime API with Unlock/Lock lifecycle //! - [`ethereum`] — BIP-0032 secp256k1 HD key derivation (behind `secp256k1` feature) pub mod cache; @@ -42,7 +42,8 @@ pub mod ethereum; // Re-export primary public API pub use cache::CacheConfig; pub use derivation::{DerivationError, ExtendedPrivKey, PATHS}; -pub use encryption::{EncryptedData, EncryptionError}; +pub use encryption::CURRENT_KEY_VERSION; +pub use encryption::{EncryptedData, EncryptionError, EncryptionKey}; pub use mnemonic::{Language, Mnemonic, Seed}; -pub use protocol::{DerivedKey, KeyType, VaultMessage, VaultProtocol}; -pub use service::{VaultService, VaultServiceActor, VaultServiceError, VaultServiceHandle}; +pub use protocol::{DerivedKey, KeyType}; +pub use service::{VaultServiceError, VaultServiceHandle}; diff --git a/crates/alknet-vault/src/protocol.rs b/crates/alknet-vault/src/protocol.rs index dd148c4..d4ab611 100644 --- a/crates/alknet-vault/src/protocol.rs +++ b/crates/alknet-vault/src/protocol.rs @@ -1,32 +1,19 @@ -//! VaultProtocol irpc message definition and associated types. +//! Vault key types: `DerivedKey` and `KeyType`. //! -//! This module defines the `VaultProtocol` enum for irpc-based message dispatch. -//! The protocol supports unlock/lock lifecycle, key derivation, -//! and encryption/decryption operations. +//! The vault's dispatch is direct method calls on `VaultServiceHandle` +//! (ADR-025). The types defined here — `DerivedKey`, `KeyType` — are the +//! return types from those methods. There is no `VaultProtocol` enum, no +//! `VaultMessage`, no `VaultServiceActor`, and no remote dispatch capability. //! -//! # Protocol Operation -//! -//! The VaultProtocol follows a lifecycle: the vault starts in a **locked** -//! state where no derivation or encryption operations are possible. The `Unlock` -//! call loads the seed into memory (derived from the mnemonic passphrase). After -//! that, derive and encrypt/decrypt operations are available. The `Lock` call -//! purges the seed and all cached keys. -//! -//! # Wire Format -//! -//! For local (in-process) calls, the protocol uses tokio channels directly. -//! For remote (in-cluster) calls, the protocol is serialized with postcard. -//! For cross-node (call protocol) exposure, the vault is wrapped in an -//! operation that serializes to JSON. +//! The vault is **local-only by construction**. If remote vault access is +//! ever needed, it requires a separate crate that wraps the vault and adds +//! remote transport + auth (ADR-025, OQ-021). use std::fmt; -use irpc::rpc_requests; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use zeroize::Zeroize; -use crate::encryption::EncryptedData; - /// The type of a derived key. #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub enum KeyType { @@ -46,10 +33,8 @@ pub enum KeyType { /// by `#[zeroize(drop)]`). /// /// Serialization redacts the `private_key` field for human-readable formats -/// (JSON) for safety, showing `"[REDACTED]"` instead of the key bytes. For -/// binary formats (postcard, used by irpc), the actual bytes are serialized -/// so that remote communication works correctly. Deserialization always reads -/// the full bytes. +/// (JSON) for safety, showing `"[REDACTED]"` instead of the key bytes. +/// Deserialization always reads the full bytes. #[derive(Zeroize, Deserialize)] #[zeroize(drop)] pub struct DerivedKey { @@ -98,115 +83,6 @@ impl Serialize for DerivedKey { } } -/// VaultProtocol message definition. -/// -/// This is the irpc protocol enum that defines all vault operations. -/// The `#[rpc_requests]` macro generates: -/// - **`VaultMessage`**: message enum with `WithChannels` wrappers for each variant -/// - **`Channels`** impls for each wrapper type -/// - **`From`** impls for protocol enum and message enum conversions -/// - **`Service`** and **`RemoteService`** trait impls for remote dispatch -/// -/// # State Requirements -/// -/// All operations except `Unlock` require the vault to be in an **unlocked** -/// state. Calling derive/encrypt/decrypt on a locked vault returns an error. -#[rpc_requests(message = VaultMessage, no_spans)] -#[derive(Debug, Serialize, Deserialize)] -pub enum VaultProtocol { - /// Derive an Ed25519 keypair at the given path. - /// - /// Path format: `m/74'/0'/0'/0'` (SLIP-0010 hardened-only notation). - /// Returns a `DerivedKey` with `KeyType::Ed25519`. - #[rpc(tx = irpc::channel::oneshot::Sender>)] - #[wrap(DeriveEd25519)] - DeriveEd25519 { - /// SLIP-0010 derivation path (e.g., "m/74'/0'/0'/0'"). - path: String, - }, - - /// Derive an AES-256-GCM encryption key at the given path. - /// - /// The default encryption path is `m/74'/2'/0'/0'`. - /// Returns a `DerivedKey` with `KeyType::Aes256Gcm`. - #[rpc(tx = irpc::channel::oneshot::Sender>)] - #[wrap(DeriveEncryptionKey)] - DeriveEncryptionKey { - /// SLIP-0010 derivation path for the encryption key. - path: String, - }, - - /// Derive a secp256k1 (Ethereum) keypair at the given path. - /// - /// The default Ethereum path is `m/44'/60'/0'/0/0`. - /// Returns a `DerivedKey` with `KeyType::Secp256k1`. - #[rpc(tx = irpc::channel::oneshot::Sender>)] - #[wrap(DeriveEthereumKey)] - DeriveEthereumKey { - /// BIP-0032 derivation path (e.g., "m/44'/60'/0'/0/0"). - path: String, - }, - - /// Derive a deterministic password at the given path. - /// - /// Path format: `m/74'/1'/0'/{hash}'` (SLIP-0010 hardened notation). - /// The `length` parameter controls the output length. - #[rpc(tx = irpc::channel::oneshot::Sender, crate::service::VaultServiceError>>)] - #[wrap(DerivePassword)] - DerivePassword { - /// SLIP-0010 derivation path for the password. - path: String, - /// Desired password length in bytes. - length: usize, - }, - - /// Encrypt plaintext using a derived encryption key. - /// - /// The key is derived at the path `m/74'/2'/0'/0'` with the given version. - /// Returns an `EncryptedData` blob suitable for storage. - #[rpc(tx = irpc::channel::oneshot::Sender>)] - #[wrap(Encrypt)] - Encrypt { - /// The plaintext string to encrypt. - plaintext: String, - /// The key version for rotation tracking. - key_version: u32, - }, - - /// Decrypt an `EncryptedData` blob back to plaintext. - /// - /// The key is derived from the seed at the path indicated by the key version. - #[rpc(tx = irpc::channel::oneshot::Sender>)] - #[wrap(Decrypt)] - Decrypt { - /// The encrypted data blob to decrypt. - encrypted: EncryptedData, - }, - - /// Lock the service, purging the seed and all cached derived keys. - /// - /// After locking, no derive/encrypt/decrypt operations are possible - /// until `Unlock` is called again. Calls `zeroize()` on all sensitive - /// material (ADR-038). - #[rpc(tx = irpc::channel::oneshot::Sender>)] - #[wrap(Lock)] - Lock, - - /// Unlock the service with a BIP39 mnemonic and optional passphrase. - /// - /// The mnemonic is the space-separated BIP39 word list. The passphrase is - /// the optional BIP39 password extension (the "25th word"). After unlocking, - /// derive and encrypt/decrypt operations are available. - #[rpc(tx = irpc::channel::oneshot::Sender>)] - #[wrap(Unlock)] - Unlock { - /// The BIP39 mnemonic phrase (space-separated word list). - mnemonic: String, - /// Optional BIP39 passphrase (the "25th word" password extension). - passphrase: Option, - }, -} - #[cfg(test)] mod tests { use super::*; @@ -249,35 +125,6 @@ mod tests { assert!(json.contains("Ed25519"), "JSON must contain key_type"); } - #[test] - fn test_derived_key_serialize_preserves_bytes_postcard() { - let key = make_test_key(); - let bytes = postcard::to_allocvec(&key).unwrap(); - let restored: DerivedKey = postcard::from_bytes(&bytes).unwrap(); - assert_eq!( - restored.private_key, - vec![0xABu8; 32], - "postcard must preserve private_key bytes" - ); - assert_eq!( - restored.public_key, - vec![0xCDu8; 32], - "postcard must preserve public_key bytes" - ); - } - - #[test] - fn test_derived_key_deserialize_preserves_bytes() { - let key = make_test_key(); - let bytes = postcard::to_allocvec(&key.private_key).unwrap(); - let restored: Vec = postcard::from_bytes(&bytes).unwrap(); - assert_eq!( - restored, - vec![0xABu8; 32], - "Deserialization must preserve private_key bytes" - ); - } - #[test] fn test_derived_key_zeroize_on_drop() { let key = DerivedKey { diff --git a/crates/alknet-vault/src/service.rs b/crates/alknet-vault/src/service.rs index c3ffb17..d365d41 100644 --- a/crates/alknet-vault/src/service.rs +++ b/crates/alknet-vault/src/service.rs @@ -1,8 +1,8 @@ -//! VaultService implementation with Unlock/Lock lifecycle. +//! VaultServiceHandle — the sole runtime API for the vault. //! -//! The `VaultService` is the primary runtime interface for key management. -//! It holds the master seed in `Zeroize`-protected memory and provides methods -//! for the Unlock/Lock lifecycle, key derivation, and encryption/decryption. +//! The `VaultServiceHandle` wraps the vault's state in an +//! `Arc>` and provides direct, synchronous method calls +//! for the unlock/lock lifecycle, key derivation, and encryption/decryption. //! //! # Lifecycle //! @@ -25,37 +25,30 @@ //! → vault returns to locked state //! ``` //! -//! # Dispatch Paths +//! # Dispatch //! -//! There are two ways to interact with the vault: -//! -//! 1. **Local (in-process)**: `VaultServiceHandle` wraps `VaultServiceInner` -//! behind `Arc>` and provides direct method calls without serialization. -//! 2. **Remote (in-cluster)**: `VaultServiceActor` processes `VaultMessage` -//! variants from an mpsc channel and dispatches to the handle methods. +//! The vault uses **direct method calls** on `VaultServiceHandle` — no actor, +//! no message enum, no channels, no serialization (ADR-025). The handle is +//! `Arc>` — clone it, share it, call +//! methods directly. All methods are synchronous (no `async`, no `.await`). +//! The vault does not depend on `tokio` (ADR-025). //! //! # Assembly //! -//! The `VaultService` is assembled by the CLI binary. The CLI unlocks the vault -//! at startup and injects derived/decrypted material into operation contexts. -//! No handler crate accesses the vault directly — they receive keys through -//! their operation context or via the call protocol. +//! The `VaultServiceHandle` is assembled by the CLI binary. The CLI unlocks +//! the vault at startup and injects derived/decrypted material into operation +//! contexts. No handler crate accesses the vault directly — they receive keys +//! through their operation context or via the call protocol. use std::sync::{Arc, RwLock}; use base64::engine::general_purpose::URL_SAFE_NO_PAD; use base64::Engine; -use irpc::WithChannels; -use serde::{Deserialize, Serialize}; use crate::cache::{CacheConfig, CachedKey, KeyCache}; use crate::derivation::{self, DerivationError, PATHS}; use crate::encryption::{self, EncryptedData, EncryptionKey}; use crate::mnemonic::{Language, Mnemonic, Seed}; -use crate::protocol::{ - Decrypt, DeriveEd25519, DeriveEncryptionKey, DeriveEthereumKey, DerivePassword, Encrypt, - VaultMessage, VaultProtocol, Unlock, -}; use crate::protocol::{DerivedKey, KeyType}; /// Handle to a running VaultService for local (in-process) use. @@ -80,7 +73,7 @@ struct VaultServiceInner { } /// Errors that can occur during vault operations. -#[derive(Debug, thiserror::Error, Serialize, Deserialize)] +#[derive(Debug, thiserror::Error)] pub enum VaultServiceError { #[error("vault is locked; call Unlock first")] VaultLocked, @@ -206,10 +199,7 @@ impl VaultServiceHandle { }); } - let seed = inner - .seed - .as_ref() - .ok_or(VaultServiceError::VaultLocked)?; + let seed = inner.seed.as_ref().ok_or(VaultServiceError::VaultLocked)?; let key = derivation::derive_path_from_seed(seed.as_bytes(), path)?; let private_key = key.private_key().to_vec(); let public_key = key.public_key().to_vec(); @@ -237,10 +227,7 @@ impl VaultServiceHandle { }); } - let seed = inner - .seed - .as_ref() - .ok_or(VaultServiceError::VaultLocked)?; + let seed = inner.seed.as_ref().ok_or(VaultServiceError::VaultLocked)?; let key = derivation::derive_path_from_seed(seed.as_bytes(), path)?; let private_key = key.private_key().to_vec(); let public_key = key.public_key().to_vec(); @@ -274,10 +261,7 @@ impl VaultServiceHandle { }); } - let seed = inner - .seed - .as_ref() - .ok_or(VaultServiceError::VaultLocked)?; + let seed = inner.seed.as_ref().ok_or(VaultServiceError::VaultLocked)?; let key = crate::ethereum::derive_secp256k1_path(seed.as_bytes(), path)?; let private_key = key.private_key().to_vec(); @@ -299,19 +283,12 @@ impl VaultServiceHandle { } } - pub fn derive_password( - &self, - path: &str, - length: usize, - ) -> Result, VaultServiceError> { + pub fn derive_password(&self, path: &str, length: usize) -> Result, VaultServiceError> { let inner = self.inner.read().unwrap(); if !inner.unlocked { return Err(VaultServiceError::VaultLocked); } - let seed = inner - .seed - .as_ref() - .ok_or(VaultServiceError::VaultLocked)?; + let seed = inner.seed.as_ref().ok_or(VaultServiceError::VaultLocked)?; let key = derivation::derive_path_from_seed(seed.as_bytes(), path)?; let private_key = key.private_key(); @@ -345,10 +322,7 @@ impl VaultServiceHandle { let private_key = if let Some(cached) = inner.cache.get(PATHS::ENCRYPTION) { cached.private_key.clone() } else { - let seed = inner - .seed - .as_ref() - .ok_or(VaultServiceError::VaultLocked)?; + let seed = inner.seed.as_ref().ok_or(VaultServiceError::VaultLocked)?; let derived = derivation::derive_path_from_seed(seed.as_bytes(), PATHS::ENCRYPTION)?; let pk = derived.private_key().to_vec(); let pubk = derived.public_key().to_vec(); @@ -372,10 +346,7 @@ impl VaultServiceHandle { let private_key = if let Some(cached) = inner.cache.get(PATHS::ENCRYPTION) { cached.private_key.clone() } else { - let seed = inner - .seed - .as_ref() - .ok_or(VaultServiceError::VaultLocked)?; + let seed = inner.seed.as_ref().ok_or(VaultServiceError::VaultLocked)?; let derived = derivation::derive_path_from_seed(seed.as_bytes(), PATHS::ENCRYPTION)?; let pk = derived.private_key().to_vec(); let pubk = derived.public_key().to_vec(); @@ -396,166 +367,9 @@ impl Default for VaultServiceHandle { } } -/// The VaultService manages the lifecycle of the master seed and provides -/// secret operations. This is the type used by the irpc service handler. -/// -/// For local (in-process) use, prefer `VaultServiceHandle` which wraps -/// this in thread-safe locks. -pub struct VaultService { - handle: VaultServiceHandle, -} - -impl VaultService { - /// Create a new VaultService in the locked state. - pub fn new() -> Self { - Self { - handle: VaultServiceHandle::new(), - } - } - - /// Get a handle for local (in-process) use. - pub fn handle(&self) -> &VaultServiceHandle { - &self.handle - } -} - -impl Default for VaultService { - fn default() -> Self { - Self::new() - } -} - -/// Actor that processes `VaultMessage` variants and dispatches to `VaultServiceHandle`. -/// -/// The actor runs as a `tokio::task`, receives messages from an mpsc channel, -/// dispatches to the handle methods, and sends responses through oneshot channels. -/// -/// # Usage -/// -/// ```ignore -/// let handle = VaultServiceHandle::new(); -/// let (client, actor) = VaultServiceActor::spawn(handle); -/// tokio::task::spawn(actor.run(rx)); -/// // Use client to send messages -/// ``` -pub struct VaultServiceActor { - handle: VaultServiceHandle, -} - -impl VaultServiceActor { - /// Create a new actor wrapping the given handle. - pub fn new(handle: VaultServiceHandle) -> Self { - Self { handle } - } - - /// Run the actor message loop, processing `VaultMessage` variants. - /// - /// This method runs until the receiver channel is closed. Each message - /// variant is dispatched to the corresponding `VaultServiceHandle` method - /// and the response is sent through the oneshot channel embedded in the message. - pub async fn run(mut self, mut rx: tokio::sync::mpsc::Receiver) { - while let Some(msg) = rx.recv().await { - self.handle_message(msg); - } - } - - /// Spawn the actor as a `tokio::task` and return a `Client` for sending messages. - /// - /// The actor runs on a tokio task and processes messages from the mpsc channel. - /// The returned `Client` can be used to send `VaultMessage` variants - /// to the actor. - pub fn spawn( - handle: VaultServiceHandle, - ) -> (irpc::Client, VaultServiceActor) { - let (tx, rx) = tokio::sync::mpsc::channel(64); - let client = irpc::Client::local(tx); - let actor = Self::new(handle.clone()); - tokio::task::spawn(actor.run(rx)); - (client, Self::new(handle)) - } - - /// Handle a single `VaultMessage` by dispatching to the appropriate handle method. - fn handle_message(&mut self, msg: VaultMessage) { - match msg { - VaultMessage::DeriveEd25519(msg) => { - let WithChannels { inner, tx, .. } = msg; - let DeriveEd25519 { path } = inner; - let result = self.handle.derive_ed25519(&path); - tokio::spawn(async move { - let _ = tx.send(result).await; - }); - } - VaultMessage::DeriveEncryptionKey(msg) => { - let WithChannels { inner, tx, .. } = msg; - let DeriveEncryptionKey { path } = inner; - let result = self.handle.derive_encryption_key(&path); - tokio::spawn(async move { - let _ = tx.send(result).await; - }); - } - VaultMessage::DeriveEthereumKey(msg) => { - let WithChannels { inner, tx, .. } = msg; - let DeriveEthereumKey { path } = inner; - let result = self.handle.derive_ethereum_key(&path); - tokio::spawn(async move { - let _ = tx.send(result).await; - }); - } - VaultMessage::DerivePassword(msg) => { - let WithChannels { inner, tx, .. } = msg; - let DerivePassword { path, length } = inner; - let result = self.handle.derive_password(&path, length); - tokio::spawn(async move { - let _ = tx.send(result).await; - }); - } - VaultMessage::Encrypt(msg) => { - let WithChannels { inner, tx, .. } = msg; - let Encrypt { - plaintext, - key_version, - } = inner; - let result = self.handle.encrypt(&plaintext, key_version); - tokio::spawn(async move { - let _ = tx.send(result).await; - }); - } - VaultMessage::Decrypt(msg) => { - let WithChannels { inner, tx, .. } = msg; - let Decrypt { encrypted } = inner; - let result = self.handle.decrypt(&encrypted); - tokio::spawn(async move { - let _ = tx.send(result).await; - }); - } - VaultMessage::Lock(msg) => { - let WithChannels { inner: _, tx, .. } = msg; - self.handle.lock(); - tokio::spawn(async move { - let _ = tx.send(Ok(())).await; - }); - } - VaultMessage::Unlock(msg) => { - let WithChannels { inner, tx, .. } = msg; - let Unlock { - mnemonic, - passphrase, - } = inner; - let result = self.handle.unlock(&mnemonic, passphrase.as_deref()); - tokio::spawn(async move { - let _ = tx.send(result).await; - }); - } - } - } -} - #[cfg(test)] mod tests { use super::*; - use crate::protocol::Lock; - use irpc::channel::oneshot; - use irpc::WithChannels; #[test] fn test_service_starts_locked() { @@ -750,10 +564,7 @@ mod tests { service.unlock_new(24).unwrap(); let result = service.derive_ethereum_key(PATHS::ETHEREUM); - assert!(matches!( - result, - Err(VaultServiceError::UnsupportedKeyType) - )); + assert!(matches!(result, Err(VaultServiceError::UnsupportedKeyType))); } #[test] @@ -847,72 +658,6 @@ mod tests { assert_eq!(service.inner.read().unwrap().cache.len(), 1); } - #[tokio::test] - async fn test_actor_unlock_responds_successfully() { - let handle = VaultServiceHandle::new(); - let (tx, rx) = tokio::sync::mpsc::channel(64); - let actor = VaultServiceActor::new(handle); - tokio::task::spawn(actor.run(rx)); - - let (resp_tx, resp_rx) = oneshot::channel(); - let msg = VaultMessage::Unlock(WithChannels::from(( - Unlock { - mnemonic: "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about".to_string(), - passphrase: None, - }, - resp_tx, - ))); - tx.send(msg).await.unwrap(); - - let result = resp_rx.await.unwrap(); - assert!(result.is_ok(), "Unlock via actor must succeed"); - } - - #[tokio::test] - async fn test_actor_derive_ed25519_returns_key() { - let handle = VaultServiceHandle::new(); - handle.unlock_new(24).unwrap(); - let (tx, rx) = tokio::sync::mpsc::channel(64); - let actor = VaultServiceActor::new(handle); - tokio::task::spawn(actor.run(rx)); - - let (resp_tx, resp_rx) = oneshot::channel(); - let msg = VaultMessage::DeriveEd25519(WithChannels::from(( - DeriveEd25519 { - path: PATHS::IDENTITY.to_string(), - }, - resp_tx, - ))); - tx.send(msg).await.unwrap(); - - let result = resp_rx.await.unwrap(); - assert!(result.is_ok(), "DeriveEd25519 via actor must succeed"); - let key = result.unwrap(); - assert!( - !key.private_key.is_empty(), - "DerivedKey must have private_key" - ); - assert_eq!(key.key_type, KeyType::Ed25519); - } - - #[tokio::test] - async fn test_actor_lock_clears_state() { - let handle = VaultServiceHandle::new(); - handle.unlock_new(24).unwrap(); - let (tx, rx) = tokio::sync::mpsc::channel(64); - let actor = VaultServiceActor::new(handle.clone()); - tokio::task::spawn(actor.run(rx)); - - let (resp_tx, resp_rx): (oneshot::Sender>, _) = - oneshot::channel(); - let msg = VaultMessage::Lock(WithChannels::from((Lock, resp_tx))); - tx.send(msg).await.unwrap(); - - let result = resp_rx.await.unwrap(); - assert!(result.is_ok(), "Lock via actor must succeed"); - assert!(!handle.is_unlocked(), "Handle must be locked after Lock"); - } - #[test] fn test_unlock_with_passphrase_produces_different_seed() { let service_a = VaultServiceHandle::new(); @@ -943,30 +688,4 @@ mod tests { "Unlock with None passphrase must produce same seed as another None passphrase unlock" ); } - - #[tokio::test] - async fn test_actor_unlock_with_passphrase() { - let handle = VaultServiceHandle::new(); - let (tx, rx) = tokio::sync::mpsc::channel(64); - let actor = VaultServiceActor::new(handle); - tokio::task::spawn(actor.run(rx)); - - let mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"; - - let (resp_tx, resp_rx) = oneshot::channel(); - let msg = VaultMessage::Unlock(WithChannels::from(( - Unlock { - mnemonic: mnemonic.to_string(), - passphrase: Some("TREZOR".to_string()), - }, - resp_tx, - ))); - tx.send(msg).await.unwrap(); - - let result = resp_rx.await.unwrap(); - assert!( - result.is_ok(), - "Unlock with passphrase via actor must succeed" - ); - } }