Skip to content

Step 1 of 5 · Reading · ~1 min

Read

Double Ratchet

DH Ratchet Step

When a party sends a message after receiving one from the peer with a new DH public key, they perform a DH ratchet step:

python

Where:

python

The flow:

  1. Alice sends msg1 (DH pub A1).
  2. Bob receives msg1 → DH ratchet receive (uses A1 + Bob's current DH B0). Now has shared state.
  3. Bob sends msg2 (DH pub B1).
  4. Alice receives msg2 → DH ratchet receive with B1.
  5. Alice sends msg3 (DH pub A2). Etc.

Ratchet advances only when direction CHANGES. If Alice sends 5 in a row, only one DH ratchet step total.

Headers per message:

{
    dh_pub: <Alice's current DH pub>
    pn: <previous chain length — for skipped key caching>
    n: <message number in current chain>
}

pn lets the receiver know "the previous chain had N messages; if you missed any, derive their mks now before switching chains."

Up nextSession State ManagementSessions & Group Chat

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…