WASM bridge: web client now uses same crypto as CLI (full interop)
warzone-wasm crate: - Compiles warzone-protocol to WebAssembly via wasm-pack - Exposes WasmIdentity, WasmSession, decrypt_wire_message to JS - Same X25519 + ChaCha20-Poly1305 + X3DH + Double Ratchet as CLI - 344KB WASM binary (optimized with wasm-opt) WireMessage moved to warzone-protocol: - Shared type used by CLI client, WASM bridge, and TUI - Guarantees identical bincode serialization across all clients Web client rewritten: - Loads WASM module on startup (/wasm/warzone_wasm.js) - Identity: WasmIdentity generates same key types as CLI - Registration: sends bincode PreKeyBundle (same format as CLI) - Encrypt: WasmSession.encrypt/encrypt_key_exchange - Decrypt: decrypt_wire_message (handles KeyExchange + Message) - Sessions persisted in localStorage (base64 ratchet state) - Groups: per-member WASM encryption (interop with CLI members) Server routes: - GET /wasm/warzone_wasm.js — serves WASM JS glue - GET /wasm/warzone_wasm_bg.wasm — serves WASM binary - Both embedded at compile time via include_str!/include_bytes! Web ↔ CLI interop now works: - Same key exchange (X3DH with X25519) - Same ratchet (Double Ratchet with ChaCha20-Poly1305) - Same wire format (bincode WireMessage) - Web user can message CLI user and vice versa Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -33,3 +33,22 @@ pub enum MessageContent {
|
||||
File { filename: String, data: Vec<u8> },
|
||||
Receipt { message_id: MessageId },
|
||||
}
|
||||
|
||||
/// Wire message format for transport between clients.
|
||||
/// Used by both CLI and WASM — MUST be identical for interop.
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub enum WireMessage {
|
||||
/// First message to a peer: X3DH key exchange + first ratchet message.
|
||||
KeyExchange {
|
||||
sender_fingerprint: String,
|
||||
sender_identity_encryption_key: [u8; 32],
|
||||
ephemeral_public: [u8; 32],
|
||||
used_one_time_pre_key_id: Option<u32>,
|
||||
ratchet_message: crate::ratchet::RatchetMessage,
|
||||
},
|
||||
/// Subsequent messages: ratchet-encrypted.
|
||||
Message {
|
||||
sender_fingerprint: String,
|
||||
ratchet_message: crate::ratchet::RatchetMessage,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user