Skip to content

docs(signal-protocol): document the pluggable X25519 key agreement - #479

Merged
jlucaso1 merged 2 commits into
mainfrom
claude/nifty-bohr-1sgy86
Aug 7, 2026
Merged

docs(signal-protocol): document the pluggable X25519 key agreement#479
jlucaso1 merged 2 commits into
mainfrom
claude/nifty-bohr-1sgy86

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds an X25519 Key Agreement subsection to advanced/signal-protocol.mdx, alongside the existing AES-256-CBC and HKDF-SHA256 primitive write-ups.
  • Documents that PrivateKey::calculate_agreement now routes through the pluggable SignalCryptoProvider trait (x25519_agreement, overridden via set_crypto_provider) instead of calling the X25519 implementation directly.
  • Notes the new fallible path: a substituted backend can refuse the operation, surfacing as CurveError::AgreementFailed and SignalProtocolError::KeyAgreementFailed, which is treated as a local failure and outranks the MAC-based decrypt verdicts rather than being reported as message corruption.

Reflects oxidezap/whatsapp-rust#1218, which added this trait method (default = today's behavior, byte-for-byte unchanged; no build without a custom provider can produce the new error).

Scope note

This repo has no existing page describing the SignalCryptoProvider trait itself (its extension points for AES-256-CBC/AES-256-GCM/HMAC-SHA256/transport AEAD are undocumented; only CryptoProviderError leaks into a few error-reference pages as an opaque source()). Writing that page is a larger, separate documentation effort. This PR stays scoped to the one primitive PR #1218 actually changed, added in the same style as the primitives already documented on this page.

Test plan

  • Docs site builds/renders the updated page correctly (Mintlify preview)

Generated by Claude Code


Summary by cubic

Adds an X25519 key agreement subsection to advanced/signal-protocol.mdx, covering the new pluggable path and updated DH ratchet details.
It explains how calculate_agreement now uses SignalCryptoProvider and clarifies failure handling and provider setup.

  • New Features
    • Routes calculate_agreement through SignalCryptoProvider::x25519_agreement (set via set_crypto_provider; installs once; default path unchanged).
    • Corrects DH ratchet cost: two agreements per ratchet step; none for messages within an open chain.
    • Notes HKDF-SHA256 is not provider-routed (only AES-256-CBC shares this hook) and that backend refusals surface as CurveError::AgreementFailed / SignalProtocolError::KeyAgreementFailed, treated as a local failure ahead of MAC verdicts.

Written for commit 746335d. Summary will update on new commits.

Summary by CodeRabbit

  • Documentation
    • Added guidance on X25519 key agreement during session setup and ratchet operations.
    • Documented the calculate_agreement API and configurable cryptographic provider behavior.
    • Clarified error handling for failed key agreements, including precedence over MAC-related decryption errors.

Adds an "X25519 Key Agreement" subsection alongside the existing
AES-256-CBC / HKDF-SHA256 primitives, reflecting whatsapp-rust PR #1218:
calculate_agreement now routes through SignalCryptoProvider, and a
substituted backend can refuse the operation (CurveError::AgreementFailed /
SignalProtocolError::KeyAgreementFailed).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mintlify

mintlify Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
whatsapp-rust 🟢 Ready View Preview Aug 6, 2026, 11:48 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Signal protocol documentation now describes X25519 key agreement, calculate_agreement, crypto-provider routing, default behavior, and agreement failure propagation.

Changes

Signal protocol documentation

Layer / File(s) Summary
Document X25519 key agreement
advanced/signal-protocol.mdx
Documents X25519 use during session setup and DH ratchet operations. It also documents SignalCryptoProvider dispatch and CurveError::AgreementFailed and SignalProtocolError::KeyAgreementFailed propagation.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit checks the ratchet’s turn,
Where X25519 keys now learn.
Providers guide the agreement through,
Errors keep their meanings true.
Documentation hops in line. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the added documentation for pluggable X25519 key agreement.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown

Greptile Summary

Adds documentation for pluggable X25519 key agreement in the Signal Protocol implementation.

  • Explains when agreement occurs during session setup and DH ratchet transitions.
  • Documents the SignalCryptoProvider::x25519_agreement extension point and provider installation requirements.
  • Describes how backend refusal maps to key-agreement errors and takes precedence over MAC-based decrypt verdicts.

Confidence Score: 5/5

The documentation-only PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
advanced/signal-protocol.mdx Documents X25519 agreement lifecycle, provider customization, and failure propagation without leaving an eligible follow-up issue.

Reviews (2): Last reviewed commit: "docs(signal-protocol): fix agreement-per..." | Re-trigger Greptile

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@advanced/signal-protocol.mdx`:
- Around line 985-987: Update the “X25519 Key Agreement” subsection heading to
sentence case, “X25519 key agreement.” Rewrite its prose in active voice
addressing the reader as “you,” replace the vague “this” reference with
`calculate_agreement`, and split the final paragraph into separate concise
sentences while preserving the technical meaning.
- Line 995: Update the paragraph describing the pluggable crypto-provider flow
to explicitly name SignalCryptoProvider::x25519_agreement as the trait hook used
by PrivateKey::calculate_agreement, while preserving the existing failure and
error-priority details.
- Line 995: Update the crypto-provider discussion in the Signal protocol section
to add a callout requiring callers to invoke set_crypto_provider before any
cryptographic operation, including key agreement. State that the custom backend
is installed only once and that implicit or duplicate initialization after the
default provider has initialized fails.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 26b54f07-6031-4617-8538-6ce3e3495b92

📥 Commits

Reviewing files that changed from the base of the PR and between f4bbf7c and 98a8e2b.

📒 Files selected for processing (1)
  • advanced/signal-protocol.mdx

Comment thread advanced/signal-protocol.mdx Outdated
Comment thread advanced/signal-protocol.mdx Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 98a8e2bc38

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread advanced/signal-protocol.mdx Outdated
Comment thread advanced/signal-protocol.mdx Outdated
Comment thread advanced/signal-protocol.mdx Outdated
Comment thread advanced/signal-protocol.mdx Outdated
Addresses review feedback on PR #479:
- Correct the DH-ratchet cost model: a ratchet step performs two X25519
  agreements (new receiving chain + new sending chain via
  DeferredSenderRatchet::apply), not one per message; ordinary chain
  advances (step_with_message_keys) cost none. Verified against
  session_cipher.rs and ratchet/keys.rs.
- Name SignalCryptoProvider::x25519_agreement explicitly, and stop
  implying HKDF-SHA256 is provider-routed (it always calls hkdf::Hkdf
  directly) — only AES-256-CBC shares the hook with the agreement.
  Verified against ratchet.rs::derive_keys_with_label.
  provider (get_or_init) so a later set_crypto_provider call returns
  Err instead of replacing it. Verified against provider.rs.
- Rewrite in active/second-person voice, sentence-case heading, and
  split run-on sentences.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@greptile-apps
greptile-apps Bot dismissed their stale review August 6, 2026 23:54

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Documentation-only update adding an X25519 key agreement subsection to signal-protocol.mdx; no code, API, config, or behavior changes. The diff is purely explanatory, so no product, security, or operational tradeoff remains for human sign-off.

Re-trigger cubic

@jlucaso1
jlucaso1 merged commit 321eb0b into main Aug 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants