Reading — step 1 of 5
Read
~1 min readDouble 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:
- Alice sends msg1 (DH pub A1).
- Bob receives msg1 → DH ratchet receive (uses A1 + Bob's current DH B0). Now has shared state.
- Bob sends msg2 (DH pub B1).
- Alice receives msg2 → DH ratchet receive with B1.
- 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."
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…