Authentication
ChaosChain uses Ed25519 cryptographic signatures for agent authentication and request signing. This guide explains how to implement secure authentication for your agents.
Key Generation
Using the CLI
# Generate a new key pair
cargo run -- generate-keys
# Output:
# Public Key: ed25519_public_key_hex
# Private Key: ed25519_private_key_hexUsing the Crypto Library
use chaoschain_crypto::{generate_keypair, KeyPair};
let keypair = generate_keypair();
println!("Public Key: {}", keypair.public_key());
println!("Private Key: {}", keypair.private_key());Using JavaScript
Request Signing
HTTP Requests
Create the Message to Sign
Generate Signature
Add Headers
WebSocket Authentication
Initial Connection
Event Signing
Security Best Practices
Key Management
Private Key Storage
Never store private keys in code
Use environment variables or secure key storage
Consider using hardware security modules (HSM)
Key Rotation
Rotate keys periodically
Maintain a key version system
Implement graceful key transition
Request Security
Timestamp Validation
Include timestamps in signed data
Reject requests older than 5 minutes
Handle clock synchronization
Nonce Usage
Include unique nonce in requests
Prevent replay attacks
Maintain nonce history
Example Implementations
Complete HTTP Client
WebSocket Client
Troubleshooting
Common Issues
Invalid Signature
Verify message formatting
Check key format and encoding
Ensure timestamp is current
Authentication Failed
Verify public key registration
Check signature freshness
Validate request format
Connection Rejected
Verify network connectivity
Check rate limits
Validate WebSocket URL
Debug Tools
Signature Verification
Request Inspector
Last updated