encryption: zero-knowledge envelope crypto crate, native + wasm32#239
Conversation
New workspace member (crates/* glob; NOT a default-member, so plain cargo build is untouched). Carries the forward crypto suite as one agnostic crate compiled from the same source for native servers and stock browsers via wasm32-unknown-unknown: - kdf: Argon2id (password -> 256-bit key), params carried in-band; DEFAULT (64 MiB/3/1) and INTERACTIVE (19 MiB/2/1, OWASP) presets - aead: XChaCha20-Poly1305 with explicit 24-byte random nonces - envelope: the sealed blob — versioned little-endian layout parsed by hand (no serde), header (magic|version|argon params|salt|nonce) is the AEAD associated data so cost-parameter tampering fails open() - sign: Ed25519 (generate/from_seed/sign/verify), RFC 8032 vector test - hash: SHA-384 + RFC 6962-style domain-separated merkle helpers - wasm: optional wasm-bindgen facade (--features wasm-bindings) No SIMD of its own: simd.rs remains the repo's single dispatch entry (simd_avx512/avx2/neon/simd_wasm); vectorized paths live inside the audited RustCrypto crates. Entropy is getrandom-only (js feature -> crypto.getRandomValues on wasm32). Keys zeroize on drop, no Debug on key types, field-free errors, #![forbid(unsafe_code)]. Verified: 23 unit tests green natively; clippy -D warnings clean (all features); cargo check green on wasm32-unknown-unknown with and without wasm-bindings; release cdylib builds a wasm module. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RbXniqYUYgwUsRrEnRRiid
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_b9a23403-eb6e-45a6-a88a-be73df409504) |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (8)
📝 WalkthroughWalkthroughAdds a new ChangesEncryption Crate
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant JS as Browser (JS)
participant Wasm as wasm.rs
participant Envelope as envelope.rs
participant Kdf as kdf.rs
participant Aead as aead.rs
JS->>Wasm: seal_envelope(password, plaintext, interactive)
Wasm->>Envelope: seal(password, plaintext, params)
Envelope->>Kdf: derive_key(password, salt, params)
Kdf-->>Envelope: DerivedKey
Envelope->>Aead: seal_with_key(key, nonce, header, plaintext)
Aead-->>Envelope: ciphertext
Envelope-->>Wasm: header + ciphertext blob
Wasm-->>JS: blob (Vec<u8>)
JS->>Wasm: open_envelope(password, blob)
Wasm->>Envelope: open(password, blob)
Envelope->>Envelope: decode_header(blob)
Envelope->>Kdf: derive_key(password, salt, params)
Kdf-->>Envelope: DerivedKey
Envelope->>Aead: open_with_key(key, nonce, header, ciphertext)
Aead-->>Envelope: plaintext or AeadError
Envelope-->>Wasm: plaintext or EnvelopeError
Wasm-->>JS: plaintext or thrown JsError
Poem
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
New workspace member (crates/* glob; NOT a default-member, so plain cargo build is untouched). Carries the forward crypto suite as one agnostic crate compiled from the same source for native servers and stock browsers via wasm32-unknown-unknown:
No SIMD of its own: simd.rs remains the repo's single dispatch entry (simd_avx512/avx2/neon/simd_wasm); vectorized paths live inside the audited RustCrypto crates. Entropy is getrandom-only (js feature -> crypto.getRandomValues on wasm32). Keys zeroize on drop, no Debug on key types, field-free errors, #![forbid(unsafe_code)].
Verified: 23 unit tests green natively; clippy -D warnings clean (all features); cargo check green on wasm32-unknown-unknown with and without wasm-bindings; release cdylib builds a wasm module.
Claude-Session: https://claude.ai/code/session_01RbXniqYUYgwUsRrEnRRiid
Summary by CodeRabbit