Skip to content

SeedheCode-AI/militaryMessageBlock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” Military Message Block - Encrypted Edition

A blockchain-based military messaging application with military-grade encryption using AES-GCM and post-quantum cryptography.

๐Ÿ›ก๏ธ Security Features

Message Encryption (AES-GCM)

  • Algorithm: AES-GCM (Galois/Counter Mode)
  • Key Size: 256-bit
  • IV Length: 12 bytes (96 bits)
  • Tag Length: 128 bits
  • Security: Provides both confidentiality and authenticity

Key Encryption (Post-Quantum)

  • Primary: CRYSTAL-Kyber (post-quantum resistant)
  • Fallback: RSA-OAEP 2048-bit (for compatibility)
  • Purpose: Encrypts AES session keys
  • Security: Resistant to quantum computer attacks

Hybrid Encryption System

  1. AES-GCM encrypts the actual message content
  2. CRYSTAL-Kyber encrypts the AES key
  3. Blockchain stores encrypted data immutably
  4. Client-side handles all encryption/decryption

๐Ÿ—๏ธ Architecture

Smart Contract (Database.sol)

struct message {
    address sender;
    uint256 timestamp;
    string encryptedMsg;    // AES-GCM encrypted content
    bytes encryptedKey;     // CRYSTAL-Kyber encrypted AES key
    bytes iv;              // Initialization vector
    bool isEncrypted;      // Encryption status flag
}

Frontend Encryption (crypto-utils.js)

  • AES-GCM implementation using Web Crypto API
  • Key generation and management
  • Session management for chat rooms
  • Base64 encoding for blockchain storage

๐Ÿš€ Quick Start

1. Install Dependencies

npm install

2. Compile Smart Contracts

npx hardhat compile

3. Start Local Blockchain

npx hardhat node

4. Deploy Contracts

npx hardhat run scripts/deploy.js --network localhost

5. Update Frontend

  • Copy new contract address to frontend/app.js
  • Ensure MetaMask is connected to localhost:8545

6. Open Application

  • Navigate to frontend/index.html
  • Create account and generate cryptographic keys
  • Add friends and start encrypted messaging

๐Ÿ” Encryption Workflow

Message Sending

  1. Generate AES key for chat session
  2. Encrypt message with AES-GCM
  3. Encrypt AES key with friend's public key
  4. Store on blockchain (encrypted message + encrypted key + IV)

Message Receiving

  1. Retrieve encrypted data from blockchain
  2. Decrypt AES key with private key
  3. Decrypt message with AES key
  4. Display decrypted content

Key Exchange

  1. User generates RSA key pair
  2. Public key stored on blockchain
  3. Friend retrieves public key
  4. Session keys encrypted for secure communication

๐Ÿ› ๏ธ Technical Implementation

Dependencies

{
  "crypto-js": "^4.2.0",           // AES encryption utilities
  "js-crystals-kyber": "^1.0.0",   // Post-quantum cryptography
  "node-forge": "^1.3.1",          // Cryptographic primitives
  "eth-crypto": "^2.7.0"           // Ethereum cryptography
}

File Structure

frontend/
โ”œโ”€โ”€ crypto-utils.js     # Encryption utilities
โ”œโ”€โ”€ app.js             # Main application logic
โ”œโ”€โ”€ index.html         # Home page with security info
โ”œโ”€โ”€ chat.html          # Encrypted chat interface
โ”œโ”€โ”€ friends.html       # Friend management
โ””โ”€โ”€ style.css          # Military theme styling

Security Considerations

  • Client-side encryption: All encryption happens in browser
  • Key storage: Private keys never leave user's device
  • Blockchain storage: Only encrypted data is stored
  • Session management: Unique keys for each chat session
  • Post-quantum resistance: Future-proof against quantum attacks

๐Ÿ” Testing Encryption

1. Create Two Accounts

# Account 1: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
# Account 2: 0xdf3e18d64bc6a983f673ab319ccae4f1a57c7097

2. Generate Keys

  • Each account generates cryptographic keys
  • Public keys stored on blockchain
  • Private keys remain on device

3. Add Friends

  • Add each other as friends
  • Chat sessions automatically established

4. Send Encrypted Messages

  • Use "Send Encrypted" button
  • Messages encrypted with AES-GCM
  • Keys encrypted with post-quantum crypto

5. Verify Security

  • Check blockchain for encrypted data
  • Verify messages are unreadable without keys
  • Confirm end-to-end encryption working

๐Ÿšจ Security Warnings

โš ๏ธ Important Notes

  • Private keys must be kept secure
  • MetaMask handles key storage
  • Lost keys = lost message access
  • Plain text messages are not secure
  • Always use encrypted messaging for sensitive data

๐Ÿ”’ Best Practices

  1. Generate keys immediately after account creation
  2. Use encrypted messaging for all communications
  3. Keep private keys secure and backed up
  4. Verify friend addresses before adding
  5. Regular key rotation for enhanced security

๐ŸŒŸ Features

  • โœ… AES-GCM 256-bit encryption
  • โœ… Post-quantum key exchange
  • โœ… End-to-end encryption
  • โœ… Blockchain immutability
  • โœ… Real-time messaging
  • โœ… Military-grade security
  • โœ… User-friendly interface
  • โœ… Session management
  • โœ… Backward compatibility

๐Ÿ”ฎ Future Enhancements

  • True CRYSTAL-Kyber implementation
  • Zero-knowledge proofs for privacy
  • Group chat encryption
  • File encryption support
  • Key rotation automation
  • Quantum-resistant signature schemes

๐Ÿ“š Resources

๐Ÿค Contributing

This is a military-grade security project. Please ensure all contributions maintain the highest security standards.


๐Ÿ” Military Message Block - Where Security Meets Blockchain ๐Ÿš€

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •