Peer Handshake Protocol

← Back to Cryptography I: Blockchain Security and Cryptographic Foundations

Introduction

When two rippled nodes connect over the internet, they can't trust each other initially. How does node A know that the node claiming to be B really controls B's private key? How do they prevent man-in-the-middle attacks? How do they avoid accidentally connecting to themselves?

The peer handshake protocol solves all these problems through careful cryptographic design. This chapter explores how XRPL nodes establish secure, authenticated connections.

The Challenge

What We Need to Prove

Node A                                    Node B
  |                                         |
  |  "I am Node A with public key PK_A"    |
  |  "Prove you have secret key SK_A"      |
  |────────────────────────────────────────>|
  |                                         |
  |  "I am Node B with public key PK_B"    |
  |  "Prove you have secret key SK_B"      |
  |<────────────────────────────────────────|
  |                                         |
  |  Both nodes must prove:                |
  |  1. Identity (I own this key)          |
  |  2. Liveness (I'm here NOW, not replay)|
  |  3. Session binding (THIS connection)  |

Attack Scenarios to Prevent

1. Man-in-the-Middle (MITM)

2. Replay Attack

3. Self-Connection

4. Network Mismatch

The Solution: Cryptographic Handshake

High-Level Flow

The Shared Value: Session Binding

Why We Need It

Signatures alone aren't enough:

We need something unique to THIS specific connection:

Implementation

Hashing the SSL Finished Messages

What are "Finished" messages?

In the SSL/TLS handshake, both parties send a "Finished" message that contains:

  • A hash of all previous handshake messages

  • A MAC (Message Authentication Code) proving they know the session keys

These messages are:

  • Unique per session: Different for every SSL connection

  • Unpredictable: Depend on random values exchanged during handshake

  • Authenticated: Part of SSL's own security

Properties of the Shared Value

Building the Handshake

Header Fields Explained

Network-ID:

Network-Time:

Public-Key:

Session-Signature:

Instance-Cookie:

Server-Domain (optional):

Verifying the Handshake

Complete Handshake Flow

Security Properties

1. Mutual Authentication

Both nodes prove they possess their private keys:

2. Session Binding

Signatures are specific to this connection:

3. Replay Prevention

4. MITM Prevention

5. Self-Connection Prevention

6. Network Segregation

Attack Analysis

Can an attacker impersonate Node A?

No:

Can an attacker replay old handshakes?

No:

Can an attacker perform MITM?

Very difficult:

Implementation Best Practices

✅ DO:

❌ DON'T:

Performance Considerations

Summary

The peer handshake protocol provides:

  1. Mutual authentication: Both nodes prove identity

  2. Session binding: Signatures tied to specific SSL session

  3. Replay prevention: Old signatures don't work

  4. MITM protection: Requires private keys to forge

  5. Self-connection prevention: Instance cookies detect loops

  6. Network segregation: Network IDs prevent cross-network connections

Key components:

  • Shared value: Derived from SSL session, unique per connection

  • Signatures: Prove possession of private keys

  • Headers: Exchange identities and verification data

  • Validation: Multiple checks ensure security

This cryptographic handshake enables XRPL to operate as a decentralized network where nodes don't need to trust each other—they can verify everything cryptographically.

Last updated