API of homomorphic binary operations such as binary comparisons or binary divisions using the library HElib
API of homomorphic binary operations such as binary comparison or binary Euclidian division using the library HElib
Still maintained (April 2018) by Quentin McGaw (email: quentin.mcgaw@gmail.com)
This project was developed as my Master thesis at Imperial College London.
This project concerns the research and development of a real-use application of homomorphic encryption for cloud computing. The application takes advantage of the various possibilities and limitations of present homomorphic encryption schemes and programming libraries to remain usable in terms of time. The foundations of the application rely on the design of binary operations using homomorphic encryption. All the binary logic gates and various binary blocks were developed and adapted to provide enough functionalities to the application. The project focuses on providing features to cloud computing such as calculating averages on large amounts of encrypted numbers in a relatively short and decent time. The result is an application program interface written in C++ allowing to perform various operations on integers. It thus shows homomorphic encryption can be used today for simple operations if the security is more important than the speed of execution.
Requirements:
/yourpath
in exampleEnter the following command in your terminal:
docker run -it --rm -v /yoursrcpath:/hbc qmcgaw/homomorphic-binary-circuits
This downloads the Docker image (the first time), mount the makefile and source files in the Docker container,
compile your source code and run the compiled program. You can stop the execution with CTRL+C.
Edit the makefile and/or source files on your host machine
make
in the Docker container to re-build the binary hbc./hbc
or even on your hostexit
Requirements:
C:\Program Files\Git\usr\bin
to your environment pathIn a terminal, enter
git clone https://github.com/qdm12/hbc.git
Go to the hbc directory
cd hbc
Launch the virtual machine which will setup and build everything for you with
vagrant up
This takes about 30 minutes the first time, depending on your connection speed and CPU.
It launches an Ubuntu virtual machine with only what is necessary for this project.
WARNING: If you do not have hardware virtualization, you can still run it but you have to change trusty64
to trusty32 and vb.cpus = 2 to vb.cpus = 1.
Log in the virtual machine with
vagrant ssh
The working directory hbc on your host machine is shared with the virtual machine at /vagrant
In the virtual machine, enter
cd /vagrant
make
in the virtual machinemake hbcNrun
to build and automatically run the main.cpp codeWhen you are done:
exit
in the virtual machine, bringing you back to your host machine.vagrant halt
to shutdown the machine. Or enter vagrant destroy
to delete the machine.To log back in, enter vagrant up
and it should take about 30 seconds (except if you destroy the machine)
Requirements:
For your information, software dependencies:
Program or Library | Requirement 1 | Requirement 2 | Requirement 3 | Requirement 4 | Requirement 5 | Requirement 6 |
---|---|---|---|---|---|---|
hbc | g++ | make | libboost | c++11 | HElib | |
HElib | g++ | make | git | NTL 10.5.0 | GMP 6.1.2 | |
NTL 10.5.0 | g++ | make | GMP 6.1.2 | |||
GMP 6.1.2 | g++ | make | m4 | perl |
make HElib
in a terminal in the hbc directory.xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install wget git g++ m4 perl libboost
curl https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2 > gmp-6.1.2.tar.bz2
tar -xvjf gmp-6.1.2.tar.bz2 && cd gmp-6.1.2
./configure
make
make install
make check
cd .. && rm -fr gmp-6.1.2*
curl http://www.shoup.net/ntl/ntl-10.5.0.tar.gz > ntl-10.5.0.tar.gz
tar -xvzf ntl-10.5.0.tar.gz && cd ntl-10.5.0/src
./configure NTL_GMP_LIP=on
make
make install
cd ../.. && rm -fr ntl-10.5.0*
git clone https://github.com/shaih/HElib.git
cd HElib/src
make
make check
cd ../..
sudo
maybe) apt-get install git g++ m4 perl libboost-all-dev
wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2
tar -xvjf gmp-6.1.2.tar.bz2 && cd gmp-6.1.2
./configure
make
make install
make check
cd .. && rm -fr gmp-6.1.2*
wget http://www.shoup.net/ntl/ntl-10.5.0.tar.gz
tar -xvzf ntl-10.5.0.tar.gz && cd ntl-10.5.0/src
./configure NTL_GMP_LIP=on
make
make install
cd ../.. && rm -fr ntl-10.5.0*
git clone https://github.com/shaih/HElib.git
cd HElib/src
make
make check
and test it with make test
.cd ../..
make hbc
mkdir -p objects
g++ -c src/he.cpp -I HElib/src -o objects/he.o
g++ -c src/helper_functions.cpp -o objects/helper_functions.o
g++ -c src/TEST_GATES.cpp -I HElib/src -o objects/test_gates.o
g++ -c src/TEST_CIRC_COMB.cpp -I HElib/src -o objects/test_circ_comb.o
g++ -c src/TEST_CIRC_SEQ.cpp -I HElib/src -o objects/test_circ_seq.o
g++ -c src/TEST_CIRC_ARITHM.cpp -I HElib/src -o objects/test_circ_arithm.o
g++ -c src/main.cpp -I HElib/src -o objects/main.o
g++ objects/*.o HElib/src/fhe.a -o hbc -L/usr/local/lib -lntl -lgmp -lm
./hbc
(Careful about having enough RAM)make hbcNrun
vagrant ssh -c htop
.vagrant ssh
.vagrant ssh
on differentIn a terminal on your host machine, enter:
docker image rm qmcgaw/homomorphic-binary-circuits
Then delete the hbc repository on your host machine
In a terminal on your host machine, enter:
vagrant destroy
Then delete the hbc repository on your host machine
Use the makefile and run make deepclean
which uninstalls and delete:
Credits to Shai Halevi for HElib obviously and thanks for the quick help tips in the Issues section!
Thanks to Dr. Wei Dai (Imperial College London) for introducing me to homomorphic encryption
Thanks to Christian Bodt (Coinplus) for teaching me the basics of cryptography and security, as well as useful coding skills.
Thanks to Alexandra Rouhana for her useful discussions that helped me figure out how to overcome some design restrictions.
Thanks to Wei Dai from the Vernam Group at Worcester Polytechnic Institute for keeping me updated with the status of CuHE.
Thanks to my dad, mother and step-mother for their continuous support throughout my studies.
You’re welcome to contribute to this repository if you find any better circuits or other circuits and implement them.
Just send me an email (see my address at the start) and I will add you as a contributor.
Please create an issue on the repository if you have an issue or question. Thanks !