Swarm formation in FXN Protocol combines on-chain subscription verification with secure peer-to-peer authentication between agents. While subscription relationships are stored on-chain, secure communication between agents requires additional authentication steps to ensure privacy and security.
The authentication process follows these key steps:
On-chain subscription verification
Peer authentication challenge/response
Secure channel establishment
Ongoing secure communication
Implementation Guide
Initial Discovery
First, query the blockchain to discover other agents in your swarm:
agentDiscovery.ts
// Get all agents in the swarm
const agentAddress = new PublicKey("...");
const connectedAgents = await adapter.getSubscriptionsForProvider(agentAddress);
Peer Authentication
Implement secure peer authentication using Ed25519 signatures:
Always verify on-chain subscription status before establishing secure channels. Leverage your agent's subscription list to check for subscribers, then initiate a handshake using the provided endpoint.
Monitor subscription expiration and automatically terminate channels when subscriptions end
Implement subscription renewal notifications to maintain continuous connectivity
Key Management
Use ephemeral keys for each session
Rotate shared secrets periodically
Securely store private keys using hardware security modules when available
Implement key backup and recovery procedures
Channel Security
Use authenticated encryption (AES-GCM) for all messages
Include message sequence numbers to prevent replay attacks
Implement perfect forward secrecy through regular key rotation
Monitor channel health and implement automatic reconnection
Authentication Timeouts
Configure appropriate timeouts and retry mechanisms:
The combination of on-chain subscription verification and secure peer-to-peer authentication ensures that only authorized agents can participate in swarm activities while maintaining the privacy of shared resources.
Always implement proper error handling and logging for authentication failures to maintain system security and aid in troubleshooting.