Skip to content

A simple diffie-hellman handshake implementation for a P2P node

Notifications You must be signed in to change notification settings

t00ts/handshake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Handshake

A handshake implementation for a P2P node

  • Based on ljedrz's pea2pea P2P node architecture.
  • Uses the Elliptic Curve Diffie-Hellman key exchange, leveraging Rust's ring cryptographic primitives.
  • Aims to keep things simple: only mandatory parameters are exchanged during the handhake, as explicitly required.

Brief overview

On any handshake we consider two participants:

  1. The initiator: The node that wants to join the network
  2. The responder: An existing peer in the network

The handshake process goes as follows:

  1. Both nodes have generated an ephemeral key pair for the session.
  2. The initiator generates a random salt and sends it along with its public key to the responder.
  3. The responder receives the salt and the initiator's public key, and responds with its own public key.
  4. The initiator receives the responder's public key.
  5. Both compute and store the shared secret that will allow them to talk to each other during the session.

Testing

Running cargo test should run all tests that showcase the handshake works in multiple environments:

  1. Basic scenario with just two nodes.
  2. A linear topology consisting of 10 nodes.
  3. A mesh topology consisting of 10 nodes.

To ensure the handshake has indeed taken place we check the following:

  1. Both nodes have agreed on a common shared secret (and the secrets match)
  2. Nodes are sequentially connected and have agreed on a common shared secret only with the next node in the chain.
  3. All nodes have successfully connected to all other peers in the network.

About

A simple diffie-hellman handshake implementation for a P2P node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages