A fork of https://github.com/fairmath/openfhe-rs to add some missing functionality

Ian Goldberg ef8e5989fb Add a function to perform EvalAutomorphism without a KeyMap (like EvalRotate) 3 weeks ago
.github 1d7d23d89f Fixed version update script. 1 year ago
crate_usage 494c11c6ba Adding crate_usage example and minor imorovements 1 year ago
docs 4a1b880722 Adaptation to OpenFHE v1.2.0 release 1 year ago
examples a60b38a101 feat: add `GaussSamp` 8 months ago
src ef8e5989fb Add a function to perform EvalAutomorphism without a KeyMap (like EvalRotate) 3 weeks ago
.gitignore ad17b4e4b9 Read the docs project 1 year ago
.readthedocs.yaml ad17b4e4b9 Read the docs project 1 year ago
Cargo.toml 6b4279ca12 Automated version change in Cargo.toml [skip actions] 1 year ago
LICENSE ef23ff8346 Repository inited. 1 year ago
README.md 4a1b880722 Adaptation to OpenFHE v1.2.0 release 1 year ago
build.rs 2aa3faed62 feat: add `DCRTPolyTrapdoorGen` 8 months ago
pyproject.toml ad17b4e4b9 Read the docs project 1 year ago

README.md

About OpenFHE-rs

☀️ OpenFHE-rs is a joint project by FairMath & OpenFHE.


Discord Twitter

🔔 Keep in mind that the library is WIP and may contain some unpolished interfaces. If you encounter any issues or have any suggestions, feel free to ping us on our Discord server or open a new issue in the GitHub repository.


OpenFHE-rs is a Rust interface for the OpenFHE library, which is renowned for its comprehensive suite of Fully Homomorphic Encryption (FHE) schemes, all implemented in C++. By providing a Rust wrapper for OpenFHE, we aim to make these advanced FHE capabilities easily accessible to Rust developers.

Whether you're developing secure data processing applications or privacy-focused tools, OpenFHE-rs enables you to leverage the powerful encryption technologies of OpenFHE seamlessly within your Rust projects.

Installation

To use OpenFHE-rs, you'll need to install several dependencies and follow the installation steps for both the core OpenFHE library and the Rust crate.

Prerequisites

Ensure you have the following dependencies installed:

  • CMake >= 3.5.1
  • G++ >= 11.4
  • Rust >= 1.78
  • Git

Installation process

Core OpenFHE library installation

To build and install the OpenFHE library, follow the steps below or refer to OpenFHE's installation documentation.

  1. Clone the repository
git clone https://github.com/openfheorg/openfhe-development.git
cd openfhe-development
  1. Configure CMake
cmake -B ./build -DBUILD_SHARED=ON .
  1. Build and install the C++ OpenFHE library
make -C ./build -j$(nproc)
make -C ./build install
  1. Update the cache for the linker
sudo ldconfig

Configuring your project to use the crate

To use the OpenFHE crate in your Rust project, add it as a dependency from crates.io:

cargo add openfhe

You also need to add a small piece of code for the core dependencies' configuration in your build.rs file:

fn main
{
    // linking openFHE
    println!("cargo::rustc-link-arg=-L/usr/local/lib");
    println!("cargo::rustc-link-arg=-lOPENFHEpke");
    println!("cargo::rustc-link-arg=-lOPENFHEbinfhe");
    println!("cargo::rustc-link-arg=-lOPENFHEcore");
    // linking OpenMP
    println!("cargo::rustc-link-arg=-fopenmp");
    // necessary to avoid LD_LIBRARY_PATH
    println!("cargo::rustc-link-arg=-Wl,-rpath=/usr/local/lib");
}

To build and run a complete working example, go to the crate_usage directory (assuming that the OpenFHE library is already installed),

  1. Build the application

    cargo build
    
    1. Run bash cargo run

Custom crate installation from the source

You can adjust the installation process by building the crate manually. In that case, you need to clone the Fair Math's openfhe-rs repo to your local machine and build it:

  1. Clone the repository

    git clone https://github.com/fairmath/openfhe-rs.git
    cd openfhe-rs
    
    1. Build the library bash cargo build
  2. Run tests

    cargo test -- --test-threads=1
    
    1. Run the examples bash cargo run --example function_evaluation cargo run --example polynomial_evaluation cargo run --example simple_integers cargo run --example simple_real_numbers

Contributing

Contributions are always welcome! If you find bugs, have feature requests, or want to contribute code, please open an issue or pull request on the GitHub repository.

License

OpenFHE-rs is licensed under the BSD 2-Clause License. See the LICENSE file for more details.