A decentralized emergency contact system with blockchain-like features for trustless verification of emergency services contact information.
This project implements a distributed protocol for emergency services discovery and verification:
- Emergency Server: Authoritative source for emergency contact numbers (police, ambulance, etc.)
- Emergency Client: Discovers servers and peer clients, verifies contact information cryptographically
- Peer-to-Peer Exchange: Clients can share verified information with other clients
The system uses UDP broadcasting for discovery and TCP for data transfer. All information is cryptographically signed using RSA, ensuring authenticity regardless of source.
- Decentralized Architecture: Information can flow from server-to-client or client-to-client
- Cryptographic Verification: All data is signed using RSA signatures, making it verifiable regardless of source
- Trustless Protocol: Clients verify information authenticity without trusting the information provider
- Local Caching with Time-Based Expiry: Verified information is temporarily stored in an expiring map
- Distributed Redundancy: Multiple clients can serve as information providers
- Cryptographic Signatures: Similar to blockchain transactions, all information is cryptographically signed
- Distributed Ledger Concept: Contact information can be verified and distributed across peers
- Decentralized Trust: No need to trust individual nodes, only the cryptographic verification
- Network Resilience: System can function even if the main server is unavailable, using peer information
- Broadcasts discovery requests on the network
- Verifies responses using RSA signature validation
- Maintains a time-expiring cache of verified information
- Can function as a server for other clients using cached information
- Primary source for emergency contact information
- Signs all responses with its private key
- Manages multiple worker threads for handling concurrent requests
- C++ compiler with C++11 support
- OpenSSL development libraries
- POSIX-compliant operating system (Linux, macOS)
- Compile the server:
g++ -o emergencyServer emergencyServer.cpp -std=c++11 -pthread -lssl -lcrypto- Compile the client:
g++ -o emergencyClient emergencyClient.cpp -std=c++11 -pthread -lssl -lcrypto./emergencyServerThe server will start listening on port 25642 for discovery broadcasts.
./emergencyClientThe client will display a menu of available emergency services:
- Police station number
- Ambulance Number
- Fire Station Number
- Vehicle repair Number
- Food delivery
- Blood bank Number
Enter the number corresponding to the service you need, and the client will:
- Broadcast a discovery request on the network
- Receive and verify responses (either from a server or other clients)
- Store verified information for future use and sharing with other clients
- Display the authenticated contact information
Enter 999 to quit the application.
The system implements a signature-based verification protocol:
- All information originates from the server and is signed with the server's private key
- Clients verify the signature using the server's public key
- Verified information is cached by clients and can be shared with other clients
- Other clients can verify the signature regardless of whether they received it from the server or another client
- The
ExpiringMapclass implements time-based expiration of cached information
public_key.pem: Used by clients to verify message signaturesprivate_key.pem: Used by the server to sign messages (must be kept secure)
- Client broadcasts a query:
"The global emergency contact Id:-X, TID:-Y" - Server (or informed client) receives the broadcast
- Responder returns a signed message with contact information
- Client verifies signature and caches the result
- Client A receives and verifies information from the server
- Client A stores verified information in its expiring map
- When Client B broadcasts a discovery request, Client A can respond with its cached information
- Client B verifies the signature (which is still the server's original signature)
- The information is trusted because the signature is valid, not because Client A is trusted
- when you are running the server and client on same machine , run server first