22 Commits

Author SHA1 Message Date
25675228f4 feat: remove hnsw 2025-08-27 13:13:20 +08:00
7fae6b23b7 fix: add writeup 2025-08-10 03:39:33 +08:00
c2d423445d fix: correct run.sh script parameters and disable HNSW code (v0.3.1)
- Fix syntax error in run.sh: remove extra quote and correct --log-path to --log-file
- Comment out HNSW algorithm implementation in enc.rs and algorithms.rs to simplify codebase
- Bump version to 0.3.1 in Cargo.toml
- Remove HNSW implementation guide and test files
- Add comprehensive project writeup documentation
2025-08-06 21:40:12 +08:00
46b3562de0 refactor: migrate from FheUint12 to FheInt14 for better range support
- Replace FheUint12 with FheInt14 across all encryption operations
- Update scaling to use i16 instead of u32 for signed integer support
- Fix FheInt14 max value to 8191 (correct range limit)
- Optimize distance computation with parallel processing using rayon
- Simplify bitonic sort implementation by removing depth tracking
- Update plaintext version to match encrypted scaling behavior
- Add Default trait implementation for FheHnswGraph
2025-08-06 16:26:54 +08:00
4e13fd3023 update to 0.3.0 2025-07-27 22:56:28 +08:00
6e888dacfc refactor: simplify code by removing generics and i32fhe support
- Remove generic type parameters from all structs and functions
- Unify to use only FheUint12 for all encryption operations
- Remove i32 encryption functions (encrypt_query_i32, encrypt_point_i32)
- Remove SupportedFheInt trait and implementations
- Remove data_bit_width command line parameter
- Simplify function signatures without complex trait bounds
- Clean up unused imports and variables
- Default algorithm changed to 'bitonic' for better performance
2025-07-27 22:53:25 +08:00
ef4f0021cf feat: implement parallel bitonic sort with proper power-of-2 padding (v0.2.0)
- Add rayon dependency for parallel processing
- Implement rayon::broadcast for proper TFHE server key distribution across threads
- Fix bitonic sort to handle non-power-of-2 input sizes by padding to nearest 2^k
- Add parallel execution for recursive calls and comparison operations
- Update API to accept encrypted max values for safe padding
- Add Send/Sync traits for EncryptedNeighbor to enable thread safety
- Modify perform_knn_selection to support bitonic sort requirements
- Bump version to 0.2.0

This resolves the bitonic sort correctness issue where non-power-of-2 array sizes
caused incorrect results. The algorithm now properly pads from 100 to 128 elements
and should produce deterministic, correct results.
2025-07-27 20:02:13 +08:00
8b47403cc0 add build automation and HNSW implementation guide
- Create automated build script with version extraction and Aliyun registry push
- Add comprehensive HNSW implementation guide with step-by-step instructions
- Update Dockerfile to use musl target and enc binary for deployment
- Include performance optimization strategies and debugging tips
2025-07-24 18:58:28 +08:00
e85eb8a9e8 implement HNSW FHE integration with API design and optimization framework
- Add HNSW search algorithm support with perform_hnsw_search function
- Implement optimal parameters (M=8, L=3, P=0.6) from systematic testing
- Replace broken search_layer with comprehensive TODO framework for manual implementation
- Add generic type support for both FheInt32 and FheUint12 operations
- Include debug mode, performance analysis, and implementation guide
2025-07-24 18:57:20 +08:00
2a376b920b feat: 实现明文版hnsw算法和最优参数 2025-07-24 18:45:50 +08:00
bc92fc704f remove unused dataset 2025-07-24 18:43:50 +08:00
979f6d17d7 implmented plaintext version HNSW algorithm 2025-07-18 22:16:57 +08:00
f78764da13 update log path 2025-07-18 22:16:07 +08:00
daea4f4f22 remove cache 2025-07-18 22:15:16 +08:00
0b7f7adf89 update dependency 2025-07-18 22:14:23 +08:00
fbf591ac88 Refactor codebase with modular structure and add caching system
- Restructure code into separate modules: data, algorithms, logging, cache
- Add efficient caching system for keys and encrypted distances
- Implement three sorting algorithms: selection, bitonic, heap
- Add comprehensive logging with timestamps and progress tracking
- Configure musl target for static compilation
- Support command-line algorithm selection and cache control

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-13 16:42:00 +08:00
815e213b44 test: test selection 2025-07-07 10:46:19 +08:00
5a62c6e689 Implement fully homomorphic encryption (FHE) based KNN classifier
This commit adds a complete FHE-based K-nearest neighbors implementation using TFHE:

Key Features:
- Encrypts training data and query vectors using FheInt32 and FheUint8
- Implements encrypted Euclidean distance calculation with 100x scaling for precision
- Uses bitonic sorting with encrypted conditional swaps for secure k-selection
- Includes comprehensive progress tracking and timing for long-running operations
- Memory optimizations: pre-allocated vectors and reused encrypted constants

Algorithm Implementation:
- Encrypted distance computation with homomorphic arithmetic operations
- Bitonic sort algorithm adapted for encrypted data structures
- Secure index tracking with encrypted FheUint8 values
- Select API usage for conditional swaps maintaining data privacy

Performance:
- Handles 100 training points with 10 dimensions in ~98 minutes on consumer hardware
- Includes detailed progress bars and time estimation
- Results validated against plain-text implementation (8/10 match rate)

Documentation:
- Comprehensive function documentation for all core algorithms
- Time complexity analysis and performance benchmarking notes
- Clear separation between client-side encryption/decryption and server-side computation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-07 09:16:41 +08:00
d58adda9ab Implement plain KNN classifier and testing infrastructure
- Add plain KNN implementation with JSONL data processing
- Create Docker deployment setup with python:3.13-slim base
- Add comprehensive OJ-style testing system with accuracy validation
- Update README with detailed scoring mechanism explanation
- Add run.sh script following competition manual requirements

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-05 21:11:22 +08:00
136583715e Add project documentation and training dataset
- Add manual.md documentation
- Include train.jsonl dataset for FHE-KNN training
- Update README.md with project details

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-04 16:18:29 +08:00
4c155d8bf4 Initial Rust project setup with dependencies and dataset
- Add Cargo.toml with TFHE, CSV, and Serde dependencies
- Add .gitignore for Rust target directory
- Include Iris dataset for machine learning experiments
- Add plain KNN implementation binary
- Update LICENSE to MIT and improve README

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-29 18:11:40 +08:00
e73cc21d01 Initial commit 2025-06-16 15:29:24 +08:00