perf(crypto): native Argon2id via dryoc — 6x faster vault unlock

Phase A of the crypto/livekit rust-native migration.

Rust side
- dryoc crate (pure-rust libsodium-compat, no C toolchain)
- Tauri commands: crypto_random_bytes, crypto_secretbox_encrypt/decrypt,
  crypto_box_keypair, crypto_box_encrypt/decrypt, crypto_box_seal/open,
  crypto_pwhash — all bit-compatible with libsodium-wrappers-sumo
- Commands registered via invoke_handler in lib.rs
- All IPC payloads base64-encoded to survive serde_json

JS side
- lib/nativeCryptoOps.ts exposes pwhashArgon2id + randomBytesAsync
  plus optional secretbox accelerators for future call-site migration
- Native-first, WASM fallback on error or when VITE_USE_NATIVE_CRYPTO is
  false / in browser preview
- Argon2id call-sites migrated: secureFileStore.deriveKey and
  deviceBackup.deriveKey (covers vault unlock + backup/recovery flows)

Impact
- Vault unlock: ~1200ms → ~200ms (measured locally, Argon2id moderate)
- Per-message AEAD left on WASM-worker path: IPC overhead ~40µs would
  dominate any native speedup below ~100µs/op
- WASM stays installed as graceful fallback so browser-preview builds
  keep working and a native failure self-heals at runtime
This commit is contained in:
2026-04-21 10:46:26 +02:00
parent 44088b35d7
commit 725a7e0364
7 changed files with 494 additions and 16 deletions
+23
View File
@@ -680,6 +680,8 @@ dependencies = [
name = "chat-app-desktop"
version = "0.9.0"
dependencies = [
"base64 0.22.1",
"dryoc",
"serde",
"serde_json",
"tauri",
@@ -1242,6 +1244,27 @@ dependencies = [
"serde",
]
[[package]]
name = "dryoc"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4684d84cc4dc1a8705dcbe8be0e258581dfdbb308477ed604f52797c336bb3d2"
dependencies = [
"bitflags 2.11.1",
"chacha20",
"curve25519-dalek",
"generic-array",
"lazy_static",
"libc",
"rand_core 0.9.5",
"salsa20",
"serde",
"sha2",
"subtle",
"winapi",
"zeroize",
]
[[package]]
name = "dtoa"
version = "1.0.11"