Some checks failed
Build and Deploy / build-macos (push) Failing after 5s
Build and Deploy / build-windows (CLANG64) (push) Has been cancelled
Build and Deploy / package-dist (push) Has been cancelled
Build and Deploy / deploy-itch (push) Has been cancelled
Build and Deploy / deploy-gitea (push) Has been cancelled
Build and Deploy / build-linux (push) Has been cancelled
2.7 KiB
2.7 KiB
Seif Handshake Examples
This directory contains examples demonstrating the Seif Protocol handshake implementation in Prosperon.
Files
seif_simple.js- A standalone demonstration of the Seif handshake cryptographic operationsseif_server.js- A server that accepts Seif handshake connectionsseif_client.js- A client that initiates Seif handshake with a server
Running the Examples
Simple Demo
To see the cryptographic operations in action:
./prosperon examples/seif_simple.js
Client-Server Demo
- First, start the server:
./prosperon examples/seif_server.js
-
Note the server's public key that is printed
-
Create a file
bob_public.keywith the server's public key:
echo "SERVER_PUBLIC_KEY_HERE" > bob_public.key
- In another terminal, run the client:
./prosperon examples/seif_client.js
The Seif Protocol
The Seif handshake establishes a secure session in one round trip:
-
Alice's Message:
- Generates random
handshake_key - Sends:
{seif: 1, handshake: encrypt_pk(bob_public, handshake_key), payload: encrypt(handshake_key, alice_public)}
- Generates random
-
Bob's Response:
- Decrypts
handshake_keyusing his private key - Decrypts Alice's public key from payload
- Generates
session_key - Sends:
encrypt(handshake_key, {session: encrypt_pk(alice_public, session_key)})
- Decrypts
-
Result: Both parties share
session_keyfor symmetric encryption
Actor System Integration
In Prosperon's actor system:
- Actor objects can serve as public key identifiers (they contain unique IDs)
- The
$_.portal()function creates a listening endpoint - The
$_.contact()function initiates connections - Messages are automatically routed through the actor system
Security Properties
- Authentication: Both parties prove possession of their private keys
- Forward Secrecy: Session keys are ephemeral
- Man-in-the-Middle Protection: Requires knowledge of both private keys
- One Round Trip: Efficient session establishment
Notes on Implementation
The current implementation uses the actor object's ID as part of the identity system. In a production system, you might want to:
- Store the public key as part of the actor's data
- Use a proper key derivation function for session keys
- Add additional metadata in the handshake (timestamps, nonces, etc.)
- Implement key rotation and session management
The crypto module provides:
crypto.keypair()- Generate X25519 key pairscrypto.encrypt_pk(public_key, data)- Public key encryptioncrypto.decrypt_pk(private_key, data)- Public key decryptioncrypto.encrypt(key, data)- Symmetric encryptioncrypto.decrypt(key, data)- Symmetric decryption