Skip to content

chasglim/OpenHushed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OpenHushed: Quantum Security Meets Minimal Communication in Large Transformer Inference

Build Status License C++

OpenHushed is a comprehensive post-quantum privacy computing framework that integrates three core components for secure multi-party computation, homomorphic encryption, and high-performance communication. The framework is designed to provide quantum-resistant cryptographic solutions for privacy-preserving computations.

πŸ—οΈ Architecture Overview

OpenHushed consists of three main components:

πŸ” Haven - Homomorphic Encryption Library

  • Purpose: Advanced homomorphic encryption operations with post-quantum security
  • Features:
    • Microsoft SEAL-based homomorphic encryption (BGV/BFV schemes)
    • Lattice-based cryptographic primitives
    • Batch encoding and SIMD operations
    • Key generation and management
    • Polynomial arithmetic and evaluation
  • Location: Haven/

🌐 Wormhole - High-Performance Communication

  • Purpose: Secure and efficient network communication for distributed protocols
  • Features:
    • TCP/UDP transport layers with Boost.Asio
    • Message serialization with FlatBuffers
    • Batch messaging and large file transfers
    • Asynchronous communication patterns
    • Fiber-based concurrency support
  • Location: Wormhole/

🀫 OpenHushed - Secure Multi-Party Computation

  • Purpose: Privacy-preserving linear and non-linear computations
  • Features:
    • Matrix multiplication protocols (CMatMul, SMatMul)
    • Comparison protocols with millionaire's problem
    • Non-linear activation functions (GeLU, ReLU)
    • Linear layer computations for neural networks
    • OpenMP parallelization for performance
    • Integration with Haven and Wormhole
  • Location: OpenHushed/

πŸš€ Quick Start

Prerequisites

The following dependencies are required for building OpenHushed:

System Dependencies

# Ubuntu/Debian
sudo apt update
sudo apt install -y \
    build-essential cmake git pkg-config \
    libgmp-dev libmpfr-dev \
    libflint-dev \
    libfmt-dev \
    libomp-dev \
    flatbuffers-compiler libflatbuffers-dev \
    libgtest-dev

Microsoft SEAL 4.1

# Install Microsoft SEAL (required for homomorphic encryption)
wget https://github.com/microsoft/SEAL/releases/download/v4.1.1/SEAL-4.1.1.tar.gz
tar -xzf SEAL-4.1.1.tar.gz
cd SEAL-4.1.1
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel $(nproc)
sudo cmake --install build
cd ..
rm -rf SEAL-4.1.1*

HElib (Alternative HE Library)

# Install HElib for additional homomorphic encryption support
git clone https://github.com/homenc/HElib.git
cd HElib
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(nproc)
sudo make install
cd ../..
rm -rf HElib

NTL (Number Theory Library)

# Install NTL (required by HElib)
wget https://libntl.org/ntl-11.5.1.tar.gz
tar -xzf ntl-11.5.1.tar.gz
cd ntl-11.5.1/src
./configure PREFIX=/usr/local
make -j$(nproc)
sudo make install
cd ../..
rm -rf ntl-11.5.1*

Boost 1.88 (Required for Wormhole)

# Download and build Boost 1.88
wget https://boostorg.jfrog.io/artifactory/main/release/1.88.0/source/boost_1_88_0.tar.gz
tar -xzf boost_1_88_0.tar.gz
cd boost_1_88_0
./bootstrap.sh
./b2 --with-system --with-thread --with-fiber --with-context --with-log --with-filesystem
cd ..
# Move to OpenHushed third-party directory
mv boost_1_88_0 OpenHushed/third/
rm boost_1_88_0.tar.gz

Building OpenHushed

# Clone the repository
git clone <repository-url>
cd OpenHushed

# Ensure Boost is in the correct location
# (If you followed the prerequisites, boost_1_88_0 should be in third/)

# Build all components
mkdir build && cd build
cmake ..
cmake --build . --parallel $(nproc)

# Or build specific components
cmake -DBUILD_HAVEN=ON -DBUILD_WORMHOLE=OFF -DBUILD_OPENHUSHED=OFF ..
cmake --build . --parallel $(nproc)

Build Options

Option Default Description
BUILD_HAVEN ON Build Haven homomorphic encryption library
BUILD_WORMHOLE ON Build Wormhole communication library
BUILD_OPENHUSHED ON Build OpenHushed MPC library
BUILD_TESTS ON Build test suites
BUILD_DEMOS OFF Build demonstration applications
USE_SPU OFF Enable SPU integration for advanced protocols

πŸ“– Usage Examples

Haven - Homomorphic Encryption

// Parameter Setup
Params params(64);
params.ShowParams();

// Key-generation
KGC c(params, 64);

auto public_key = c.GetPk();

// 2-out-of-2 additive shares
SkShare s0(params), s1(params);
c.ShareSk(s0, s1);

// Message encryptions
uint64_t m1 = 40;
uint64_t m2 = 50;
uint64_t m3 = 20;
HSSCtxt ct1(params), ct2(params), ct3(params);
HSSEncrypt(public_key, m1, ct1);
HSSEncrypt(public_key, m2, ct2);
HSSEncrypt(public_key, m3, ct3);

// Get PRF key from kgc
std::string prf_key = c.GetPRFKey();

// Evaluator 0 operations
SkShare t0_out(params);
{
    SkShare t0(params);
    Evaluator e0(public_key, s0, params, prf_key, 0); // party_index = 0
    e0.ConvHSSCtxtToShare(ct1, t0);

    clock_t start = clock();
    e0.MultHSSCtxtAndShare(ct2, t0, t0_out);
    clock_t end = clock();
    double duration_ms = (end - start) * 1000.0 / CLOCKS_PER_SEC;
    std::cout << "ε‡½ζ•°θΏθ‘Œζ—Άι—΄: " << duration_ms << " ζ―«η§’" << std::endl;

    e0.ConvHSSCtxtToShare(ct3, t0);
    e0.AddShares(t0, t0_out);
}

// Evaluator 1 operations
SkShare t1_out(params);
{
    Evaluator e1(public_key, s1, params, prf_key, 1); // party_index = 1
    SkShare t1(params);
    e1.ConvHSSCtxtToShare(ct1, t1);
    e1.MultHSSCtxtAndShare(ct2, t1, t1_out);
    e1.ConvHSSCtxtToShare(ct3, t1);
    e1.AddShares(t1, t1_out);
}

uint64_t res;
ReconstShares(t0_out, t1_out, res);

Wormhole - Communication

#include "wormhole/communication/communication_layer.h"

// Setup communication
wormhole::CommunicationLayer comm("localhost", 8080);
comm.connect();

// Send/receive messages
comm.send_message("Hello, secure world!");
auto response = comm.receive_message();

OpenHushed - Secure Computation

#include "openhushed/linear/CMatMul.h"
#include "openhushed/nonlinear/cmp.h"

// Initialize secure matrix multiplication
CMatMul matmul(rows, cols, comm_layer);

// Preprocessing phase
matmul.PreprocessingPhase();

// Online computation
auto result = matmul.OnlinePhase(input_matrix);

// Secure comparison
ComparisonProtocol cmp(context, bit_length, secret_key);
auto comparison_result = cmp.compare_two_party(x_share, y_share, x1_share, y1_share);

πŸ§ͺ Testing

# Run all tests
cd build
ctest

# Run specific component tests
./Haven/test/test_seal_simd
./Haven/test/test_lattice
./Wormhole/demo/communication_demo
./OpenHushed/tests/test_linear
./OpenHushed/tests/test_cmp
./OpenHushed/tests/test_gelu
./OpenHushed/tests/test_smatmul
./OpenHushed/tests/test_cmatmul

πŸ”§ Development

Project Structure

OpenHushed/
β”œβ”€β”€ CMakeLists.txt          # Root build configuration
β”œβ”€β”€ README.md               # This file
β”œβ”€β”€ Haven/                  # Homomorphic secret sharing
β”‚   β”œβ”€β”€ src/crypto/         # Core crypto implementations
β”‚   β”œβ”€β”€ src/lattice/        # Lattice-based primitives
β”‚   β”œβ”€β”€ src/utils/          # Utility functions
β”‚   └── test/               # Unit tests
β”œβ”€β”€ Wormhole/               # Communication layer
β”‚   β”œβ”€β”€ src/communication/  # Network protocols
β”‚   β”œβ”€β”€ src/utility/        # Utility functions
β”‚   β”œβ”€β”€ fbs/                # FlatBuffer schemas
β”‚   └── demo/               # Example applications
β”œβ”€β”€ OpenHushed/             # Secure computation
β”‚   β”œβ”€β”€ src/linear/         # Linear algebra protocols
β”‚   β”œβ”€β”€ src/nonlinear/      # Non-linear operations
β”‚   └── tests/              # Integration tests
└── third/                  # Third-party dependencies
    β”œβ”€β”€ boost_1_88_0/       # Boost libraries
    β”œβ”€β”€ flatbuffers/        # Serialization
    β”œβ”€β”€ spu/                # SPU integration (optional)
    └── yacl/               # Yet Another Crypto Library

Key Dependencies Summary

Core Mathematical Libraries

  • GMP/GMPXX: Arbitrary precision arithmetic
  • FLINT: Fast Library for Number Theory
  • NTL: Number Theory Library

Cryptographic Libraries

  • Microsoft SEAL 4.1: Homomorphic encryption
  • HElib: Alternative homomorphic encryption

Communication & Serialization

  • Boost 1.88: System utilities, threading, fiber, context
  • FlatBuffers: Efficient serialization

Performance & Parallelization

  • OpenMP: Parallel computing
  • Threading: Multi-threading support

Development & Testing

  • GTest: Unit testing framework
  • CMake: Build system
  • pkg-config: Package configuration

Contributing

  1. Code Style: Follow the existing C++17 style with PIMPL pattern
  2. Testing: Add comprehensive tests for new features
  3. Documentation: Update relevant documentation
  4. Performance: Profile critical paths and optimize
  5. Security: Follow cryptographic best practices

Debugging

# Debug build
cmake -DCMAKE_BUILD_TYPE=Debug ..
make -j$(nproc)

# Run with debugging
gdb ./OpenHushed/tests/test_cmp

# Memory checking
valgrind --tool=memcheck ./OpenHushed/tests/test_linear

πŸ›‘οΈ Post-Quantum Security

OpenHushed is designed with post-quantum security in mind:

  • Lattice-based cryptography: Resistant to quantum attacks
  • Ring Learning With Errors (RLWE): Foundation for homomorphic encryption
  • BGV/BFV schemes: Quantum-resistant homomorphic encryption
  • Secure multi-party protocols: Information-theoretic security

πŸ“š Documentation

  • Haven: See Haven/doc/ for homomorphic encryption details
  • Wormhole: Communication protocol specifications
  • OpenHushed: MPC algorithm implementations and optimizations

🀝 Dependencies License Information

  • Microsoft SEAL: MIT License
  • HElib: Apache License 2.0
  • Boost: Boost Software License
  • FLINT: LGPL 2.1+
  • NTL: LGPL 2.1+
  • GMP: LGPL 3.0+
  • FlatBuffers: Apache License 2.0

πŸ“„ License

This project is licensed under the [Apache License 2.0] - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Microsoft SEAL team for quantum-resistant homomorphic encryption
  • HElib developers for advanced homomorphic encryption primitives
  • Boost community for high-quality C++ libraries
  • FLINT and NTL developers for number theory algorithms
  • Google FlatBuffers team for efficient serialization
  • OpenMP community for parallel computing standards

πŸ“ž Support

For questions, issues, or contributions:


OpenHushed - Post-Quantum Privacy Computing for the Future 🌌

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors