From 0c87da71421390b34be6906b9c371afb4312ee14 Mon Sep 17 00:00:00 2001 From: gitee-bot Date: Wed, 28 Oct 2026 23:38:47 +0000 Subject: [PATCH] Add README.md --- README.en.md | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 220 insertions(+) create mode 100644 README.en.md create mode 100644 README.md diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..7823722 --- /dev/null +++ b/README.en.md @@ -0,0 +1,110 @@ +# Encrypted Chat App + +An Android instant messaging application based on end-to-end encryption, supporting private chat and group chat features. + +## Features + +- **End-to-End Encryption**: Uses X25519 key exchange + AES-256-GCM encryption to ensure message security +- **Private & Group Chat**: Supports one-on-one encrypted private chats and multi-person encrypted groups +- **Key Management**: Session keys derived based on HKDF, supports group key wrapping +- **Real-time Communication**: WebSocket long connection, supports real-time message push +- **Contact Management**: Search, add, delete contacts +- **Group Management**: Create groups, invite members, review join requests +- **Burn After Reading**: Supports self-destructing message feature + +## Technical Architecture + +- **Language**: Kotlin +- **UI Framework**: Jetpack Compose + Material Design 3 +- **Network**: OkHttp + Kotlinx Serialization +- **Encryption Library**: BouncyCastle (X25519, AES-GCM) +- **Local Storage**: SharedPreferences + Android Keystore + +## Project Structure + +``` +app/src/main/java/com/talk/app/ +├── crypto/ # Core encryption logic +│ ├── Crypto.kt # Cryptographic primitives (key generation, encryption, decryption) +│ └── ChatCipher.kt # Chat encryption layer +├── data/ # Data layer +│ ├── ApiClient.kt # REST API client +│ ├── AppRepository.kt # Data repository (core state management) +│ ├── Models.kt # Data models +│ ├── RealtimeClient.kt # WebSocket real-time communication +│ └── SessionStore.kt # Session and key storage +├── ui/ +│ ├── components/ # Common UI components +│ ├── screens/ # Various pages +│ │ ├── AuthScreen.kt # Login/Register +│ │ ├── ChatScreen.kt # Chat window +│ │ ├── MainScreen.kt # Main interface (Contacts/Session list) +│ │ ├── AddContactScreen.kt # Add contact +│ │ ├── GroupCreateScreen.kt# Create group +│ │ ├── GroupInfoScreen.kt # Group info +│ │ └── SettingsScreen.kt # Settings +│ └── theme/ # Theme configuration +├── MainActivity.kt +└── TalkApp.kt +``` + +## Encryption Principles + +### Key Exchange (X25519) +- Generate X25519 key pair for each user +- Use ECDH algorithm to calculate shared secret + +### Message Encryption (AES-256-GCM) +- Derive AES key from shared secret using HKDF-SHA256 +- Encrypt with AES-GCM mode, ensuring confidentiality and integrity + +### Group Keys +- Group uses independent AES-256 key +- Group owner wraps the group key using each member's public key before distribution + +## Build and Run + +### Environment Requirements +- JDK 17+ +- Android SDK 34+ +- Gradle 8.4+ + +### Build Steps + +```bash +# Clone project +git clone https://gitee.com/qingxiamingjian/encrypted-chat-app.git +cd encrypted-chat-app + +# Build Debug APK +./gradlew assembleDebug + +# Build Release APK +./gradlew assembleRelease +``` + +### Run +Install the generated APK to Android device or emulator: + +```bash +adb install app/build/outputs/apk/debug/app-debug.apk +``` + +## Usage Instructions + +1. **Register/Login**: Create an account or log in after starting the app +2. **Add Contacts**: Search and add friends via username +3. **Initiate Chat**: Click contact to enter encrypted chat +4. **Create Group**: Select multiple contacts to create an encrypted group +5. **Manage Group**: Group owner can invite members, review join requests, remove members +6. **Burn Messages**: Select burn after reading when sending messages + +## Security Notes + +- Private keys are stored in Android Keystore, secured by the system +- All messages are end-to-end encrypted, server cannot view content +- Group keys are managed by the group owner, encrypted with member public keys during distribution + +## License & Disclaimer + +This project is for learning and reference purposes only; please use it in compliance with relevant laws and regulations. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..bf9f5e3 --- /dev/null +++ b/README.md @@ -0,0 +1,110 @@ +# 加密聊天应用 (Encrypted Chat App) + +一款基于端到端加密的 Android 即时通讯应用,支持私聊和群聊功能。 + +## 功能特性 + +- **端到端加密**:采用 X25519 密钥交换 + AES-256-GCM 加密,确保消息安全 +- **私聊与群聊**:支持一对一加密私聊和多人加密群组 +- **密钥管理**:基于 HKDF 派生会话密钥,支持群组密钥包装 +- **实时通讯**:WebSocket 长连接,支持消息实时推送 +- **联系人管理**:搜索、添加、删除联系人 +- **群组管理**:创建群组、邀请成员、审核入群申请 +- **阅读即焚**:支持焚毁消息功能 + +## 技术架构 + +- **语言**:Kotlin +- **UI 框架**:Jetpack Compose + Material Design 3 +- **网络**:OkHttp + Kotlinx Serialization +- **加密库**:BouncyCastle (X25519, AES-GCM) +- **本地存储**:SharedPreferences + Android Keystore + +## 项目结构 + +``` +app/src/main/java/com/talk/app/ +├── crypto/ # 加密相关核心逻辑 +│ ├── Crypto.kt # 密码学原语 (密钥生成、加密、解密) +│ └── ChatCipher.kt # 聊天加密层 +├── data/ # 数据层 +│ ├── ApiClient.kt # REST API 客户端 +│ ├── AppRepository.kt # 数据仓库 (核心状态管理) +│ ├── Models.kt # 数据模型 +│ ├── RealtimeClient.kt # WebSocket 实时通讯 +│ └── SessionStore.kt # 会话与密钥存储 +├── ui/ +│ ├── components/ # 通用 UI 组件 +│ ├── screens/ # 各个页面 +│ │ ├── AuthScreen.kt # 登录/注册 +│ │ ├── ChatScreen.kt # 聊天窗口 +│ │ ├── MainScreen.kt # 主界面 (联系人/会话列表) +│ │ ├── AddContactScreen.kt # 添加联系人 +│ │ ├── GroupCreateScreen.kt# 创建群组 +│ │ ├── GroupInfoScreen.kt # 群组信息 +│ │ └── SettingsScreen.kt # 设置 +│ └── theme/ # 主题配置 +├── MainActivity.kt +└── TalkApp.kt +``` + +## 加密原理 + +### 密钥交换 (X25519) +- 每用户生成 X25519 密钥对 +- 使用 ECDH 算法计算共享密钥 + +### 消息加密 (AES-256-GCM) +- 使用 HKDF-SHA256 从共享密钥派生 AES 密钥 +- AES-GCM 模式加密,保证机密性和完整性 + +### 群组密钥 +- 群组使用独立的 AES-256 密钥 +- 群主用各成员公钥包装群密钥后分发 + +## 编译运行 + +### 环境要求 +- JDK 17+ +- Android SDK 34+ +- Gradle 8.4+ + +### 构建步骤 + +```bash +# 克隆项目 +git clone https://gitee.com/qingxiamingjian/encrypted-chat-app.git +cd encrypted-chat-app + +# 构建 Debug APK +./gradlew assembleDebug + +# 构建 Release APK +./gradlew assembleRelease +``` + +### 运行 +安装生成的 APK 到 Android 设备或模拟器: + +```bash +adb install app/build/outputs/apk/debug/app-debug.apk +``` + +## 使用说明 + +1. **注册/登录**:启动应用后创建账户或登录已有账户 +2. **添加联系人**:通过用户名搜索并添加好友 +3. **发起聊天**:点击联系人进入加密聊天 +4. **创建群组**:选择多个联系人创建加密群组 +5. **管理群组**:群主可邀请成员、审核入群申请、移除成员 +6. **焚毁消息**:发送消息时可选择阅后即焚 + +## 安全说明 + +- 私钥存储在 Android Keystore 中,安全性由系统保护 +- 所有消息均为端到端加密,服务器无法查看内容 +- 群组密钥由群主管理,分发时用成员公钥加密 + +## 开源协议 + +本项目仅供学习参考,请遵守相关法律法规使用。 \ No newline at end of file -- Gitee