Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions advanced/signal-protocol.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,18 @@ pub fn derive_keys(secret_input: &[u8]) -> (RootKey, ChainKey, InitialPQRKey) {

Location: `wacore/libsignal/src/protocol/ratchet.rs:18-39`

### X25519 Key Agreement
Comment thread
jlucaso1 marked this conversation as resolved.
Outdated

Every DH step in session setup, and every ratchet turn, goes through this — `RootKey::create_chain` calls it once per turn, which in an alternating conversation is per message:
Comment thread
jlucaso1 marked this conversation as resolved.
Outdated
Comment thread
jlucaso1 marked this conversation as resolved.
Outdated

```rust
pub fn calculate_agreement(&self, their_key: &PublicKey) -> Result<[u8; 32], CurveError>
```

Location: `wacore/libsignal/src/core/curve.rs`

As of PR #1218, the agreement routes through the same pluggable crypto-provider trait as the other primitives on this page (`SignalCryptoProvider`, overridden via `set_crypto_provider` in `wacore/libsignal/src/crypto/provider.rs`) instead of calling the X25519 implementation directly. The default is this crate's own implementation and cannot fail. A substituted backend can refuse the operation; that surfaces as `CurveError::AgreementFailed` and, through `SignalProtocolError`, as `KeyAgreementFailed` — a refusal is treated as a local failure and takes priority over the MAC-based decrypt verdicts (`InvalidMessage`, `BadMac`) rather than being reported as message corruption.
Comment thread
jlucaso1 marked this conversation as resolved.
Outdated
Comment thread
jlucaso1 marked this conversation as resolved.
Outdated
Comment thread
jlucaso1 marked this conversation as resolved.
Outdated

## PreKey Management

Pre-keys enable asynchronous session establishment in the Signal Protocol. whatsapp-rust manages pre-key generation and upload to match WhatsApp Web's behavior.
Expand Down