Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
bin/*
build/*
lib/*

# Created by http://www.gitignore.io

### C++ ###
# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app


### Windows ###
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp


### Linux ###
*~

# KDE directory preferences
.directory


### vim ###
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~

### KDevelop4 ###
*.kdev4
.kdev4/
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The source code is published under a MIT license:

Copyright (c) 2011, 2014

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
CC = gcc

SRCDIR = src
BINDIR = bin
BUILDDIR = build

PREFIX_LIB = /usr/local/lib

TARGET = $(BINDIR)/integer-fhe

LIBRARY_FILENAME = libscarab.so
LIBRARY = $(BUILDDIR)/$(LIBRARY_FILENAME)


CFLAGS = -Wall -g3 -ggdb -std=c99 -I/usr/local/include -I/usr/local/include/libflint -L/usr/local/lib
LDFLAGS += -lgmp -lflint
SOURCES = $(shell find $(SRCDIR) -name '*.c')
OBJECTS = $(SOURCES:.c=.o)
.PHONY: clean

all: $(TARGET) $(LIBRARY)

$(TARGET): $(OBJECTS)
mkdir -p $(BINDIR)
$(CC) -o $(TARGET) $(SOURCES) $(CFLAGS) $(LDFLAGS)

clean:
rm -r $(BINDIR) $(BUILDDIR)

$(LIBRARY):
mkdir -p $(BUILDDIR)
$(CC) -fPIC -shared -o $(LIBRARY) $(SOURCES) $(CFLAGS) $(LDFLAGS)

install:
cp $(LIBRARY) $(PREFIX_LIB)/
ldconfig

uninstall:
rm $(PREFIX_LIB)/$(LIBRARY_FILENAME)
ldconfig
156 changes: 51 additions & 105 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,153 +1,99 @@
Quick Action
============
# Introduction

To get started quickly, do the following:

1: Install Ubuntu 12.04 32 bit on a clean box, just to have a common ground (it should come with the default installation but make sure that gcc is installed)

2: Download libScarab-1.0.0.zip, gmp-5.1.1.tar.lz, flint-1.6.tgz, mpir-2.6.0.tar.bz2, mpfr-3.1.1.tar.bz2 from hcrypt.com and the linked web pages

3: Install m4 and lzip

3.1. sudo apt-get install m4

3.2. sudo apt-get install lzip

4: Install gmp

4.1. lzip -d gmp-5.1.1.tar.lz

4.2. tar xf gmp-5.1.1.tar

4.3. cd gmp-5.1.1

4.4. ./configure

4.5. make

4.6. make check #(never ever skip the checks!)

4.7. sudo make install

5: Install mpfr

5.1. tar xjf mpfr-3.1.1.tar.bz2

5.2. cd mpfr-3.1.1

5.3. make

5.4. make check

5.5. sudo make install

6: Install mpir

6.1. tar xjf mpir-2.6.0.tar.bz2

6.2. cd mpir-2.6.0

6.3. ./configure

6.4. make
This is an implementation of a fully homomorphic encryption scheme using large integers. The mathematical foundation is based on work by C. Gentry [1] for the initial concept as well as N. Smart and F. Vercauteren [2] for the integer-based approach used in this implementation.

6.5. make check
The library presented here is beta software and should not be used for any mission critical applications. No warranty expressed or implied is given.

6.6. sudo make install

7: Install flint (ok, this is perhaps quite a bit strange)
# Installation and usage

7.1. tar xf flint-1.6.tgz
First, clone this repository on your machine: <code>git clone https://github.com/blindstore/libScarab.git</code>.

7.2. cd flint-1.6
## Prerequisites

7.3. source flint_env
The library depends on the following libraries:

7.4. make library
* GMP https://gmplib.org Version 6.0.0 https://gmplib.org/download/gmp/gmp-6.0.0a.tar.lz
* MPFR http://www.mpfr.org Version 3.1.1 https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.1.tar.bz2
* MPIR http://www.mpir.org Version 2.6.0 http://www.mpir.org/mpir-2.6.0.tar.bz2
* Flint http://www.flintlib.org Version 1.6 http://www.flintlib.org/flint-1.6.tgz

7.5. sudo cp libflint.so /usr/local/lib
### For Debian-based systems

7.6. sudo cp *.h /usr/local/include
* <code>sudo apt-get install build-essential m4 lzip unzip</code>
* Use <code>./scripts/install-dependencies.sh</code> from this repository to install the dependencies.

7.7. sudo mkdir -p /usr/local/include/zn_poly/src
### For Arch Linux

7.8. sudo cp zn_poly/include/*.h /usr/local/include/zn_poly/src/
* Install <code>base-devel m4 unzip gmp mpfr</code> from official repositories.
* Install <code>mpir</code> from AUR. Install version 2.6.0 and pay attention to the comment made by Fincer on 2014-06-20 18:32.
* Install Flint manually: Execute the according part at the bottom of <code>./scripts/install-dependencies.sh</code>, but before create <code>/etc/ld.so.conf.d/locallib.conf</code> with just one line of content: <code>/usr/local/lib</code>.

8: Run libscarab test
### For Mac OS

8.1. mkdir libscarab
* You can install <code>lzip gmp</code> with <code>brew</code>
* Install the other dependencies using <code>./scripts/install-dependencies.sh</code>

8.2. cd libscarab
## Build

8.3. unzip ../libScarab-1.0.0.zip
The compilation is done using make.

8.4. make
$ make

8.5. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
This builds an executable <code>bin/integer-fhe</code> that runs a test of the library and a shared library file in <code>build/libscarab.so</code>.

8.6. ./integer-fhe

ta-daaa!
## Install

Introduction
============
$ sudo make install

This is an implementation of a fully homomorphic encryption scheme using large integers. The mathematical foundation is based on work by C. Gentry [1] for the initial concept as well as N. Smart and F. Vercauteren [2] for the integer-based approach used in this implementation.
will place <code>./build/libscarab.so</code> in <code>/usr/local/lib</code> and run <code>ldconfig</code>.

The library presented here is beta software and should not be used for any mission critical applications. No warranty expressed or implied is given.

Installation and usage
======================
## Usage

Requirements
------------
You can use the library as demonstrated in <code>test.c</code>. The following methods are exposed:

The following libraries are required for building hcrypt:
```
fhe_keygen(fhe_pk_t pk, fhe_sk_t sk); // Generate a keypair
fhe_encrypt(mpz_t c, fhe_pk_t pk, int m); // Encrypt a message (0 or 1)
fhe_decrypt(mpz_t c, fhe_sk_t sk); // Decrypt a cyphertext
fhe_recrypt(mpz_t c, fhe_pk_t pk, fhe_sk_t sk); // Recrypt a cyphertext (“refreshing” it)
fhe_add(mpz_t res, mpz_t a, mpz_t b, fhe_pk_t pk); // Add cyphertexts (= XOR)
fhe_mul(mpz_t res, mpz_t a, mpz_t b, fhe_pk_t pk); // Multiply cyphertexts (= AND)
fhe_fulladd(mpz_t sum, mpz_t c_out, mpz_t a, mpz_t b, mpz_t c_in, fhe_pk_t pk); // Add with carry in and carry out
fhe_halfadd(mpz_t sum, mpz_t c_out, mpz_t a, mpz_t b, fhe_pk_t pk); // Add with carry out
```

GMP: GNU Multiple Precision Arithmetic Library — http://gmplib.org/
FLINT: Fast Library for Number Theory version 1.6 — http://flintlib.org/flint-1.6.tgz
MPIR: Multiple Precision Integers and Rationals — http://mpir.org/ (required by FLINT)
MPFR — http://www.mpfr.org/ (required by FLINT)
## Uninstall

The library expects the flint headers under in your include directory. Also, copy zn_poly/include/*.h to ./zn_poly/src/ relative to your include path.
$ sudo make uninstall

Building
--------
will remove the library from <code>/usr/local/lib</code>.

The compilation is done using make.
### Uninstall dependencies

$ make
If you used <code>./scripts/install-dependencies</code>, you can uninstall them using

This builds an integer-fhe executeable in the current directory that runs a test of the library.
Usage
$ ./scripts/uninstall-dependencies

You can use the library as demonstrated in test.c. The following methods are exposed:
function prototype meaning
This will basically call <code>sudo make uninstall</code> for each of GMP, MPFR and MPIR and undo the commands executed for the installation of Flint.

fhe_keygen(fhe_pk_t pk, fhe_sk_t sk); Generate a keypair
fhe_encrypt(mpz_t c, fhe_pk_t pk, int m); Encrypt a message (0 or 1)
fhe_decrypt(mpz_t c, fhe_sk_t sk); Decrypt a cyphertext
fhe_recrypt(mpz_t c, fhe_pk_t pk, fhe_sk_t sk); Recrypt a cyphertext (“refreshing” it)
fhe_add(mpz_t res, mpz_t a, mpz_t b, fhe_pk_t pk); Add cyphertexts (= XOR)
fhe_mul(mpz_t res, mpz_t a, mpz_t b, fhe_pk_t pk); Multiply cyphertexts (= AND)
fhe_fulladd(mpz_t sum, mpz_t c_out, mpz_t a, mpz_t b, mpz_t c_in, fhe_pk_t pk); Add with carry in and carry out
fhe_halfadd(mpz_t sum, mpz_t c_out, mpz_t a, mpz_t b, fhe_pk_t pk); Add with carry out

References
==========
# References

[1] C. Gentry, A fully homomorphic encryption scheme

[2] N. Smart and F. Vercauteren, Fully Homomorphic Encryption with Relatively Small Key and Ciphertext Sizes

[3] H. Perl, M. Brenner and M. Smith, POSTER: An Implementation of the Fully Homomorphic Smart-Vercauteren Crypto-System

License
=======

# License

The source code is published under a MIT license:

Copyright © 2011
Copyright © 2011, 2014

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.1
15 changes: 0 additions & 15 deletions libScarab1.0.0/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion libScarab1.0.0/VERSION

This file was deleted.

Binary file removed libScarab1.0.0/integer-fhe.o
Binary file not shown.
Binary file removed libScarab1.0.0/main.o
Binary file not shown.
Binary file removed libScarab1.0.0/test.o
Binary file not shown.
Binary file removed libScarab1.0.0/types.o
Binary file not shown.
Binary file removed libScarab1.0.0/util.o
Binary file not shown.
Loading