A privacy-centric, AI-enhanced messaging application built on the Internet Computer Protocol (ICP). Features end-to-end encryption, decentralized architecture, and intelligent AI assistant capabilities powered by GroqCloud.
- π End-to-End Encryption: Messages encrypted using ECDH key exchange + AES-GCM
- π€ AI Assistant: PrivateGPT powered by GroqCloud's Llama 3 models
- π Decentralized: Built on Internet Computer Protocol (ICP)
- π Internet Identity: Secure, passwordless authentication
- π± Responsive Design: Beautiful UI that works on all devices
- β‘ Real-time: Instant messaging with typing indicators
- π― Zero Knowledge: No personal data stored on servers
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PrivateICP Messenger Architecture β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββ
β Internet Identity β
β (ICP Native) β
ββββββββββββ¬ββββββββββββ
β Authentication
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend Layer β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β React β β TypeScript β β Tailwind β β
β β 18.3.1 β β 5.5.3 β β CSS β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββ
β Encrypted Messages
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Encryption Layer β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Web Crypto API (Browser Native) β β
β β β’ ECDH Key Exchange (P-256 Curve) β β
β β β’ AES-GCM Symmetric Encryption β β
β β β’ Secure Random IV Generation β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββ
β Ciphertext Only
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ICP Canister Layer β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Chat β β Storage β β User β β
β β Canister β β Canister β β Registry β β
β β (Motoko) β β (Rust) β β (Motoko) β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Enhancement Layer β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β GroqCloud API β β
β β β’ Model: llama3-8b-8192 β β
β β β’ Chat Summarization β β
β β β’ Smart Reply Suggestions β β
β β β’ Conversational AI Assistant β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
User A User B
β β
β 1. Generate Key Pair β
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ
β Private Key A β β Private Key B β
β Public Key A β β Public Key B β
βββββββββββββββββββ βββββββββββββββββββ
β β
β 2. Exchange Public Keys via ICP β
βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ICP Public Key Registry β
β store_public_key(user_a, public_key_a) β
β store_public_key(user_b, public_key_b) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β 3. Derive Shared Secret (ECDH) β
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ
β Shared Secret A β βββββββββββββββββββββββββββββββΊ β Shared Secret B β
β (Same Value) β β (Same Value) β
βββββββββββββββββββ βββββββββββββββββββ
β β
β 4. Encrypt Message with AES-GCM β
βΌ β
βββββββββββββββββββ β
β "Hello Bob" β β
β βΌ β β
β [Ciphertext] β β
βββββββββββββββββββ β
β β
β 5. Send via ICP Canister β
βΌ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Chat Canister β
β send_message(sender_id, recipient_id, ciphertext, timestamp) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β 6. Retrieve Messages β
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ
β [Ciphertext] β β [Ciphertext] β
β βΌ β β βΌ β
β "Hello Bob" β β "Hello Bob" β
βββββββββββββββββββ βββββββββββββββββββ
- Node.js 18+ and npm
- Internet connection for GroqCloud API
- Modern browser with Web Crypto API support
-
Clone the repository
git clone <repository-url> cd privateicp-messenger
-
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env
Edit
.envand add your GroqCloud API key:VITE_GROQCLOUD_API_KEY=your_groqcloud_api_key_here
-
Start the development server
npm run dev
-
Open your browser Navigate to
http://localhost:5173
- Visit GroqCloud Console
- Sign up for a free account
- Navigate to API Keys section
- Create a new API key
- Copy the key to your
.envfile (replaceyour_groqcloud_api_key_here)
src/
βββ components/ # React components
β βββ LoginScreen.tsx # Internet Identity login
β βββ Sidebar.tsx # Chat list and user profile
β βββ ChatWindow.tsx # Main chat interface
βββ hooks/ # Custom React hooks
β βββ useAuth.ts # Authentication logic
βββ services/ # External services
β βββ encryption.ts # End-to-end encryption
β βββ groqcloud.ts # AI assistant integration
βββ types/ # TypeScript definitions
β βββ index.ts # Core type definitions
βββ App.tsx # Main application component
βββ main.tsx # Application entry point
βββ index.css # Global styles
- Key Generation: Each user generates an ECDH key pair using P-256 curve
- Key Exchange: Public keys are stored in ICP canister registry
- Shared Secret: ECDH algorithm derives identical shared secrets
- Message Encryption: AES-GCM encrypts messages with derived key
- Secure Storage: Only ciphertext is stored on-chain
- Zero Knowledge: Server never sees plaintext messages
- Forward Secrecy: New keys can be generated for each session
- Authenticated Encryption: AES-GCM provides both confidentiality and integrity
- Secure Random: Cryptographically secure random number generation
- Browser Native: Uses Web Crypto API (no external crypto libraries)
- Conversational AI: Natural language conversations
- Context Awareness: Remembers conversation history
- Smart Replies: Suggests contextual responses
- Chat Summarization: Summarizes long conversations
- Privacy Focused: No data stored by AI service
// Example AI service usage
const groqService = GroqCloudService.getInstance();
// Generate AI response
const response = await groqService.generateAIResponse(
userMessage,
conversationHistory
);
// Get smart reply suggestions
const suggestions = await groqService.generateSmartReplies(
lastMessage,
context
);
// Summarize conversation
const summary = await groqService.summarizeConversation(messages);// Authentication flow
const authClient = await AuthClient.create();
await authClient.login({
identityProvider: 'https://identity.ic0.app',
onSuccess: () => {
const identity = authClient.getIdentity();
const principal = identity.getPrincipal().toString();
// User is now authenticated
}
});// Chat Canister (Motoko)
actor ChatCanister {
public func send_message(
sender: Principal,
recipient: Principal,
ciphertext: Text,
timestamp: Int
) : async MessageId;
public func get_messages(
user1: Principal,
user2: Principal
) : async [Message];
public func store_public_key(
user: Principal,
public_key: Text
) : async Bool;
}- Color Palette: Dark theme with purple/blue accents
- Typography: System fonts with proper hierarchy
- Spacing: 8px grid system
- Components: Modular, reusable components
- Animations: Smooth transitions and micro-interactions
- Mobile: 320px - 768px
- Tablet: 768px - 1024px
- Desktop: 1024px+
- WCAG 2.1 AA: Compliant color contrast ratios
- Keyboard Navigation: Full keyboard support
- Screen Readers: Proper ARIA labels
- Focus Management: Visible focus indicators
npm run test-
Authentication Flow
- Login with Internet Identity
- Session persistence
- Logout functionality
-
Messaging Flow
- Send encrypted message
- Receive and decrypt message
- Message status updates
-
AI Assistant Flow
- Send message to PrivateGPT
- Receive AI response
- Smart reply suggestions
# Build for production
npm run build
# Deploy to IC asset canister
dfx deploy --network ic frontend# Deploy all canisters
dfx deploy --network ic
# Deploy specific canister
dfx deploy --network ic chat_canisternpm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run lint- Run ESLint
# Required
VITE_GROQCLOUD_API_KEY=your_api_key
# Optional (for local development)
VITE_IC_HOST=http://localhost:4943
VITE_INTERNET_IDENTITY_URL=http://localhost:4943/?canisterId=...- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Internet Computer Protocol - Decentralized infrastructure
- GroqCloud - High-performance AI inference
- Web Crypto API - Browser-native encryption
- React Team - Frontend framework
- Tailwind CSS - Utility-first CSS framework
Built with for privacy and decentralization