Skip to content

Lucenor/encircuit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Encircuit

Zero-overhead Rust toolkit for building, encrypting & evaluating fully homomorphic (FHE) circuits

Crates.io Documentation License: Apache-2.0

Overview

Encircuit is a high-level Rust library for building and evaluating Boolean circuits using fully homomorphic encryption (FHE). It provides a clean, ergonomic API for constructing circuits, encrypting inputs, and performing computations on encrypted data without ever decrypting intermediate values.

Architecture: Encircuit focuses on Boolean circuits with an extensible trait-based architecture. While currently Boolean-only, the foundation supports future integer types through feature flags without breaking changes.

Features

  • 🛠️ Circuit Builder: Intuitive API for constructing Boolean circuits
  • 🔒 FHE Integration: Built on top of the TFHE library for secure computation
  • ⚡ Zero-Overhead: Efficient circuit representation and evaluation
  • 🔧 Flexible Parameters: Configurable security levels and operation types
  • 📦 Modular Design: Optional features for different use cases
  • 🎯 Type Safety: Rust's type system ensures correctness at compile time
  • 🚀 Extensible Architecture: Trait-based design enables future integer support

Quick Start

Add to your Cargo.toml:

[dependencies]
encircuit = "0.0.1-alpha.0"

Basic Usage

use encircuit::prelude::*;

// Generate parameters and keys
let params = Params::for_scenario(Scenario::SafeAndBalanced)?;
let keyset = Keyset::generate(&params)?;
let (client_key, server_key) = keyset.split();

// Build a circuit: (¬y ∧ x) ∨ (x ∧ y)
let mut builder = CircuitBuilder::default();
let x = builder.input();
let y = builder.input();
let not_y = builder.not(y);
let and1 = builder.and(not_y, x);
let and2 = builder.and(x, y);
let output = builder.or(and1, and2);
let circuit = builder.finish(output);

// Encrypt inputs and evaluate
let encrypted = circuit.encrypt_inputs(&[true, false], &client_key)?;
let result = encrypted.evaluate(&server_key);
let decrypted = result[0].decrypt(&client_key)?;
assert_eq!(decrypted, true); // (¬false ∧ true) ∨ (true ∧ false) = true

Workspace Structure

encircuit/
├── Cargo.toml              # Workspace root
├── encircuit/               # Core library
│   ├── src/
│   │   ├── lib.rs          # Public API
│   │   ├── prelude.rs      # Convenient imports
│   │   ├── params.rs       # Parameter configuration
│   │   ├── keys.rs         # Key management
│   │   ├── ciphertext.rs   # Ciphertext types
│   │   └── circuit/        # Circuit building & evaluation
│   └── Cargo.toml
└── encircuit_macros/        # Procedural macros (optional)
    ├── src/lib.rs
    └── Cargo.toml

Feature Flags

Feature Default Description
boolean Boolean FHE operations
parallel Parallel encryption using Rayon
serde Serialization support
macros Procedural macro support
integer8 (future) 8-bit integer ciphertext support
integer32 (future) 32-bit integer ciphertext support

Current Status

🚧 Alpha Version - This library is currently in early development.

Implemented:

  • ✅ Circuit builder API
  • ✅ Type-safe circuit representation
  • ✅ Parameter configuration
  • ✅ Key management structures
  • ✅ Ciphertext abstractions with production-ready serialization
  • ✅ Comprehensive test suite

TODO:

  • 🔄 circuit! procedural macro implementation
  • 🔄 Performance optimizations
  • 🔄 Documentation improvements

Contributing

Contributions are welcome! Please see our contribution guidelines for details.

  1. Run rustfmt and clippy --all-targets
  2. Ensure no unsafe code without thorough review
  3. Add tests for new functionality
  4. Update documentation

License

Licensed under the Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0)

Roadmap

Milestone Focus Goal
M1 Core FHE Boolean TFHE integration (< 100 µs circuits)
M2 Macros circuit! procedural macro
M3 DSL Text/JSON → Circuit parser
M4 Runtime gRPC/HTTP circuit evaluation service
M5 Extended Types Integer ciphertext types (Int8Ct, Int32Ct via feature flags)
M6 Performance GPU acceleration

About

Encircuit – Zero-overhead Rust toolkit for building, encrypting & evaluating fully homomorphic (FHE) circuits

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages