Skip to content

corelab-src/elasm

Repository files navigation

hecate-compiler

Hecate (Homomorphic Encryption Compiler for Approximate TEnsor computation) is an optimizing compiler for the CKKS FHE scheme, built by Compiler Optimization Research Laboratory (Corelab) @ Yonsei University. Hecate is built on the top of Multi-Level Intermediate Representation (MLIR) compiler framework. We aim to support privacy-preserving machine learning and deep learning applications.

Installation

Requirements

Ninja   
git  
cmake >= 3.22.1  
python >= 3.10  
clang,clang++ >= 14.0.0  

Install MLIR

git clone https://github.com/llvm/llvm-project.git
cd llvm-project
git checkout llvmorg-16.0.0
cmake -GNinja -Bbuild \
  -DCMAKE_C_COMPILER=clang \
  -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_INSTALL_UTILS=ON \
  -DLLVM_TARGETS_TO_BUILD=host \
  llvm
cmake --build build
sudo cmake --install build
cd .. 

Optional : Install Directory to maintain multiple versions or a debug build

git clone https://github.com/llvm/llvm-project.git
cd llvm-project
git checkout llvmorg-16.0.0
cmake -GNinja -Bbuild \ 
  -DCMAKE_C_COMPILER=clang \
  -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release\
  -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_INSTALL_UTILS=ON \
  -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_INSTALL_PREFIX=<MLIR_INSTALL>\
  llvm
cmake --build build
sudo cmake --install build
cd .. 

Install SEAL

git clone https://github.com/microsoft/SEAL.git
cd SEAL
git checkout 4.0.0
cmake -S . -B build
cmake --build build
sudo cmake --install build
cd .. 

Optional : Install Directory to maintain multiple versions or a debug build

git clone https://github.com/microsoft/SEAL.git
cd SEAL
git checkout 4.0.0
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=<SEAL_INSTALL>
cmake --build build
sudo cmake --install build
cd .. 

Build Hecate

git clone <this-repository>
cd <this-repository>
cmake -S . -B build 
cmake --build build 

Optional : Install Directory to maintain multiple versions or a debug build

git clone <this-repository>
cd <this-repository>
cmake -S . -B build -DMLIR_ROOT=<MLIR_INSTALL> -DSEAL_ROOT=<SEAL_INSTALL>
cmake --build build 

Configure Hecate

python3 -m venv .venv
source .venv/bin/activate
source config.sh 

Install Hecate Python Binding

pip install -r requirements.txt
./install.sh

Tutorial

Trace the example python file to Encrypted ARiTHmetic IR

hc-trace <example-name>

e.g.,

hc-trace MLP

Compile the traced Earth IR

hopts <eva|elasm> <waterline:integer> <example-name>

e.g.,

hopts elasm 30 MLP

Test the optimized code

hc-test <eva|elasm> <waterline:integer> <example-name>

e.g.,

hc-test elasm 30 MLP

This command will print like this:

1.810851535
9.63624118628367e-06

The first line shows the wall-clock time for FHE execution
The second line shows the RMS of the resulting error

One-liner for compilation and testing

hcot <eva|elasm> <waterline:integer> <example-name>

With printing pass timings :

hcott <eva|elasm> <waterline:integer> <example-name>

DaCapo Source Code

The compiler DaCapo, which supports automatic bootstrapping placement for CKKS, has been placed in a separate repository due to license issue. You can find more details in the DaCapo Repository.

Papers

DaCapo: Automatic Bootstrapping Management for Efficient Fully Homomorphic Encryption
Seonyoung Cheon, Yongwoo Lee, Ju Min Lee, Dongkwan Kim, Sunchul Jung, Taekyung Kim, Dongyoon Lee, and Hanjun Kim 33rd USENIX Security Symposium (USENIX Security), August 2024. [Prepublication]

ELASM: Error-Latency-Aware Scale Management for Fully Homomorphic Encryption [abstract]
Yongwoo Lee, Seonyoung Cheon, Dongkwan Kim, Dongyoon Lee, and Hanjun Kim
32nd USENIX Security Symposium (USENIX Security), August 2023. [Prepublication]

HECATE: Performance-Aware Scale Optimization for Homomorphic Encryption Compiler[IEEE Xplore]
Yongwoo Lee, Seonyeong Heo, Seonyoung Cheon, Shinnung Jeong, Changsu Kim, Eunkyung Kim, Dongyoon Lee, and Hanjun Kim
Proceedings of the 2022 International Symposium on Code Generation and Optimization (CGO), April 2022. [Prepublication]

Citations

@INPROCEEDINGS{lee:hecate:cgo,
  author={Lee, Yongwoo and Heo, Seonyeong and Cheon, Seonyoung and Jeong, Shinnung and Kim, Changsu and Kim, Eunkyung and Lee, Dongyoon and Kim, Hanjun},
  booktitle={2022 IEEE/ACM International Symposium on Code Generation and Optimization (CGO)}, 
  title={HECATE: Performance-Aware Scale Optimization for Homomorphic Encryption Compiler}, 
  year={2022},
  volume={},
  number={},
  pages={193-204},
  doi={10.1109/CGO53902.2022.9741265}}
@INPROCEEDINGS{lee:elasm:sec,
  title={{ELASM}: Error-Latency-Aware Scale Management for Fully Homomorphic Encryption},
  author={Lee, Yongwoo and Cheon, Seonyoung and Kim, Dongkwan and Lee, Dongyoon and Kim, Hanjun},
  booktitle={{32nd} USENIX Security Symposium (USENIX Security 23)},
 year={2023},
 address = {Anaheim, CA},
 publisher = {USENIX Association},
 month = aug
}
@INPROCEEDINGS{cheon:dacapo:sec,
  title={{DaCapo}: Automatic Bootstrapping Management for Efficient Fully Homomorphic Encryption},
  author={Cheon, Seonyoung and Lee, Yongwoo and Kim, Dongkwan and Lee, Ju Min and Jung, Sunchul and Kim, Taekyung and Lee, Dongyoon and Kim, Hanjun},
  booktitle={{33rd} USENIX Security Symposium (USENIX Security 24)},
 year={2024},
 address = {Philadelphia, CA},
 publisher = {USENIX Association},
 month = aug
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages