[go: nahoru, domu]

Skip to content

Latest commit

 

History

History
109 lines (74 loc) · 3.21 KB

README.md

File metadata and controls

109 lines (74 loc) · 3.21 KB

Examples and Tutorials

Introduction

The examples directory contains tutorials and standalone example programs expressing the various APIs as well as a simple use-case using HElib.

What is provided

The tutorials cover primarily the CKKS scheme and comprise 8 documented examples from basic operations to more complex serialization.

The example programs provided use the BGV scheme and comprise:

More examples are expected to be released at a later date.

Installation

To compile the examples, you must have HElib already installed on your system (see INSTALL.md in this distribution's root directory). The process is pure CMake. First, create a build directory and move into it. From examples/build run CMake,

cmake [-Dhelib_DIR=<directory-to-installed-HElib>/share/cmake/helib] <directory-to-examples> ..

then run make from the same directory with optional number of threads using the -j flag for example,

make [-j<number-of-threads>]

The executables for each of the example programs can be found in the bin directory.

All tests for the examples are written in bats (a test framework for bash) and require bats-core.

Running the examples

All examples have a help method by passing the -h flag, for example

./BGV_packed_arithmetic -h

The BGV_packed_arithmetic example shows some of the basic arithmetic APIs available for ciphertext and plaintext objects.

The BGV_binary_arithmetic example shows the API for performing binary arithmetic on a vector of ciphertexts where i-th ciphertext contains the i-th bit of the binary number.

The BGV_country_db_lookup example shows a use-case for performing a database lookup on countries and their capitals, more information on this can be found here.

Running the tests

All tests for the examples are written in bats (a test framework for bash) and require bats-core.

Note that the tests require that the examples have been successfully compiled in the build directory and available in build/bin. To run the tests, one can simply execute the scripts from within the examples/tests directory.

To run all tests type the command below. Optionally, the -j flag can use threads to parallelize the tests. Note, this requires GNU parallel, see the bats documentation for more information.

bats . [-j <number-of-threads>]

To run a specific test file.

bats <testfile> [-j <number-of-threads>]

or

./<testfile> [-j <number-of-threads>]

To run a specific test by name add the -f flag e.g.

bats . -f <testname> [-j <number-of-threads>]

The <testname> can be a substring of the test name and will match all valid matches.

For debugging, it is sometimes useful to view the artifacts generated by the tests. For this, set the environment variable DEBUG to true or 1 such as,

DEBUG=1 bats . [-j <number-of-threads>]