Skip to main content

One post tagged with "SEAL"

View All Tags

· 9 min read
Abid Arcot

Background: Fully Homomorphic Encryption Unveiled

Before we embark on our comparative analysis of the SEAL and OpenFHE libraries, let's unveil the revolutionary concept of Fully Homomorphic Encryption (FHE). In the realm of cryptography, FHE stands as a beacon of innovation, allowing computations on encrypted data without the need for decryption.

Traditional encryption methods ensure the confidentiality of sensitive information during transmission or storage. However, they often hinder the ability to perform computations on this encrypted data without decrypting it first. FHE, on the other hand, transcends these limitations by enabling operations directly on encrypted data, preserving its confidentiality throughout the computational process.

Introduction

In this technical blog, we delve into the world of FHE and conduct a comparative analysis of two leading open-source libraries: Microsoft SEAL and OpenFHE. Our exploration focuses on the implementation of two widely-used FHE schemes, Brakerski-Gentry-Vaikuntanathan (BGV) and Brakerski/Fan-Vercauteren.

Understanding OpenFHE and SEAL

OpenFHE: A Glimpse into Versatility

OpenFHE, powered by Duality Technologies, emerges as a versatile open-source homomorphic encryption library. Its popularity stems from its support for a diverse range of FHE schemes, including BFV, BGV, CKKS, FHEW, and TFHE. Additionally, OpenFHE incorporates multiparty extensions for threshold FHE and proxy re-encryption, providing a comprehensive toolkit for various cryptographic applications.

Explore OpenFHE: OpenFHE GitHub Repository

To download OpenFHE binaries, visit the OpenFHE GitHub Releases section.

SEAL: Harnessing Microsoft's Expertise

SEAL, an open-source library developed by Microsoft, is designed to implement the most popular FHE schemes in use today: BGV, BFV, and CKKS. Leveraging Microsoft's expertise in cryptography, SEAL offers a robust platform for secure computations over encrypted data.

Explore SEAL: SEAL GitHub Repository

To download SEAL binaries, visit the SEAL GitHub Releases section.

Homomorphic Operations Data and Analysis

For our comparative analysis, we leverage the resources available in the GitHub repository. The repository contains C programs and binaries, facilitating a more detailed and resourceful exploration.

The provided binaries include:

  1. SEAL BGV
  2. SEAL BFV
  3. OpenFHE BGV
  4. OpenFHE BFV

Each binary executes homomorphic addition and multiplication operations on encrypted data, producing runtime and result outputs. These binaries serve as the foundation for our exploration into the efficiency and performance of FHE schemes.

Data Generation and Analysis

To initiate our analysis, we generate at least ten unique combinations of inputs for both multiplication and addition operations, taken average over ten iterations. The resulting tables showcase the runtimes of these operations for each scheme within the SEAL and OpenFHE libraries.

Pre-compiled binaries for the above libraries are provided at GitHub repository. To build you own binaries refer appendix. One can runs the binaries as follows.

./openFHE_BFV 1 1 2

example-img

Sample output when running the provided binary

Multiplication:

Input1Input2Input3OpenFHE_BFVOpenFHE_BGVSEAL_BFVSEAL_BGV
123522611843
456542611547
789552811844
101112562912146
131415562612444
161718582812050
192021572811448
222324522812046
252627552812145
282930562812045

Visualization for Enhanced Comprehension

mult graph

X-axis : Inputx, Y-axis : overhead in milliseconds

Addition:

Input1Input2Input3OpenFHE_BFVOpenFHE_BGVSEAL_BFVSEAL_BGV
1230001
4560001
7890001
1011120001
1314150001
1617180101
1920210011
2223240001
2526270001
2829300001

Visualization for Enhanced Comprehension

addition graph

X-axis : Inputx, Y-axis : overhead in milliseconds

Comparing the overheads when FHE is not used

The GitHub repository also includes C programs that perform identical multiplication and addition operations on 64-bit integer values. The execution times are compared with FHE operations, revealing the overheads associated with FHE execution.

binaries/c_program.c

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <inttypes.h>

int main(int argc, char *argv[]) {
int64_t num1, num2, num3;


if (argc >= 4) {
num1 = strtoll(argv[1], NULL, 10);
num2 = strtoll(argv[2], NULL, 10);
num3 = strtoll(argv[3], NULL, 10);
} else {
printf("usage: ./c_program <num1> <num2> <num3> \n");
return 1;
}


int64_t add, mul;
clock_t start, end;
double add_time, mul_time;


start = clock();
add = num1 + num2 + num3;
end = clock();

add_time = ((double) (end - start)) / CLOCKS_PER_SEC * 1000; //time in milliseconds.


// Perform multiplication
start = clock();
mul = num1 * num2 * num3;
end = clock();
mul_time = ((double) (end - start)) / CLOCKS_PER_SEC * 1000; //time in milliseconds


// Output results
printf("mul_time: %lf add_time%lf\n", mul_time, add_time);

return 0;
}

Multiplication:

Input1Input2Input3non_FHEOpenFHE_BFVOpenFHE_BGVSEAL_BFVSEAL_BGV
1230.0009522611843
4560.001542611547
7890.001552811844
1011120.0009562912146
1314150.001562612444
1617180.0017582812050
1920210.0005572811448
2223240.0003522812046
2526270.0006552812145
2829300.0011562812045

Average Overheads:

Overheads (ms)non-FHEOpenFHE_BFVOpenFHE_BGVSEAL_BFVSEAL_BGV
Multiplication0.000955.099127.4991119.099145.7991

Addition:

Input1Input2Input3non_FHEOpenFHE_BFVOpenFHE_BGVSEAL_BFVSEAL_BGV
1230.00140001
4560.00170001
7890.0010001
1011120.00120001
1314150.0010001
1617180.0090101
1920210.00090011
2223240.00080001
2526270.00080001
2829300.00140001

Average Overheads:

Overheads (ms)non-FHEOpenFHE_BFVOpenFHE_BGVSEAL_BFVSEAL_BGV
Addition0.001920.0019200.10.1

Conclusion

Our analysis brings forth a compelling narrative. OpenFHE demonstrates superior implementation of FHE schemes, with OpenFHE_BGV emerging as the top performer, closely followed by OpenFHE_BFV. SEAL, while robust, exhibits higher runtimes compared to OpenFHE, suggesting that OpenFHE's implementation is more efficient.

Explore Further

To delve deeper into the world of homomorphic encryption and contribute to its advancements, consider exploring the GitHub repositories for OpenFHE and SEAL:

Download the respective binaries from the library repositories and engage in the evolving landscape of homomorphic encryption.

This exploration not only enhances our understanding of FHE but also contributes valuable insights to the ongoing development of secure and privacy-preserving computational technologies.

Appendix

This section provides details on the build process for two libraries. The instructions are presented to facilitate independent experimentation with Fully Homomorphic Encryption (FHE) implementations.

Prerequisites

To execute this project, ensure that the following dependencies are installed:

  • CMake
  • G++
  • GMP
  • Clang

OpenFHE

Navigate to the openfhe directory and follow these steps to set up the project:

mkdir build
cd build
cmake ..
make
make install
make testall

After modifying the code, compile test programs using the following commands:

make added_bgv
make added_bfv

To execute the examples, run the binaries as follows:

bin/examples/pke/added_bgv
bin/examples/pke/added_bfv

Additionally, new files created will be automatically linked during the make process.

SEAL

Set up this library with the following instructions:

cmake -S . -B build -DSEAL_BUILD_EXAMPLES=ON
cmake --build build
sudo cmake --install build

To run the compiled work, locate the binary at build/bin/sealexamples.