SEAL/README.md

631 строка
27 KiB
Markdown
Исходник Обычный вид История

2019-01-30 10:03:51 +03:00
# Microsoft SEAL
2018-11-09 21:39:54 +03:00
2019-10-01 06:39:21 +03:00
Microsoft SEAL is an easy-to-use open-source ([MIT licensed](LICENSE)) homomorphic
encryption library developed by the Cryptography and Privacy Research group at
Microsoft. Microsoft SEAL is written in modern standard C++ and has no external
dependencies, making it easy to compile and run in many different environments.
For more information about the Microsoft SEAL project, see
[sealcrypto.org](https://www.microsoft.com/en-us/research/project/microsoft-seal).
2018-11-09 21:39:54 +03:00
2019-10-01 06:39:21 +03:00
This document pertains to Microsoft SEAL version 3.4. Users of previous versions
of the library should look at the [list of changes](Changes.md).
2018-11-09 21:39:54 +03:00
2019-01-30 07:46:42 +03:00
# Contents
2019-07-17 02:03:28 +03:00
2019-05-24 09:00:03 +03:00
- [Introduction](#introduction)
2019-05-24 19:30:41 +03:00
- [Core Concepts](#core-concepts)
2019-05-24 09:00:03 +03:00
- [Homomorphic Encryption](#homomorphic-encryption)
2019-05-24 19:30:41 +03:00
- [Microsoft SEAL](#microsoft-seal-1)
2019-05-24 09:00:03 +03:00
- [Installing Microsoft SEAL](#installing-microsoft-seal)
2019-01-30 07:46:42 +03:00
- [Windows](#windows)
2019-01-30 19:44:19 +03:00
- [Linux and macOS](#linux-and-macos)
2019-10-01 06:39:21 +03:00
- [Optional Dependencies](#optional-dependencies)
- [Microsoft GSL](#microsoft-gsl)
- [ZLIB](#zlib)
2019-06-20 03:23:58 +03:00
- [Installing Microsoft SEAL for .NET](#installing-microsoft-seal-for-net)
2019-01-30 07:46:42 +03:00
- [Windows](#windows-1)
2019-01-30 19:44:19 +03:00
- [Linux and macOS](#linux-and-macos-1)
2019-05-31 03:24:25 +03:00
- [Getting Started](#getting-started)
- [Contributing](#contributing)
2019-02-21 03:17:53 +03:00
- [Citing Microsoft SEAL](#citing-microsoft-seal)
2019-01-30 07:46:42 +03:00
2019-05-24 09:00:03 +03:00
# Introduction
2019-07-17 02:03:28 +03:00
2019-05-24 19:30:41 +03:00
## Core Concepts
2019-07-17 02:03:28 +03:00
2019-10-01 06:39:21 +03:00
Most encryption schemes consist of three functionalities: key generation, encryption,
and decryption. Symmetric-key encryption schemes use the same secret key for both
encryption and decryption; public-key encryption schemes use separately a public
key for encryption and a secret key for decryption. Therefore, public-key encryption
schemes allow anyone who knows the public key to encrypt data, but only those who
know the secret key can decrypt and read the data. Symmetric-key encryption can be
used for efficiently encrypting very large amounts of data, and enables secure
outsourced cloud storage. Public-key encryption is a fundamental concept that
enables secure online communication today, but is typically much less efficient
than symmetric-key encryption.
While traditional symmetric- and public-key encryption can be used for secure storage
and communication, any outsourced computation will necessarily require such encryption
layers to be removed before computation can take place. Therefore, cloud services
providing outsourced computation capabilities must have access to the secret keys,
and implement access policies to prevent unauthorized employees from getting access
to these keys.
2019-05-24 19:30:41 +03:00
2019-05-24 09:00:03 +03:00
## Homomorphic Encryption
2019-07-17 02:03:28 +03:00
2019-10-01 06:39:21 +03:00
Homomorphic encryption refers to encryption schemes that allow the cloud to compute
directly on the encrypted data, without requiring the data to be decrypted first.
The results of such encrypted computations remain encrypted, and can be only decrypted
with the secret key (by the data owner). Multiple homomorphic encryption schemes
with different capabilities and trade-offs have been invented over the past decade;
most of these are public-key encryption schemes, although the public-key functionality
may not always be needed.
Homomorphic encryption is not a generic technology: only some computations on
encrypted data are possible. It also comes with a substantial performance overhead,
so computations that are already very costly to perform on unencrypted data are
likely to be infeasible on encrypted data. Moreover, data encrypted with homomorphic
encryption is many times larger than unencrypted data, so it may not make sense to
encrypt, e.g., entire large databases, with this technology. Instead, meaningful
use-cases are in scenarios where strict privacy requirements prohibit unencrypted
cloud computation altogether, but the computations themselves are fairly lightweight.
Typically, homomorphic encryption schemes have a single secret key which is held
by the data owner. For scenarios where multiple different private data owners wish
to engage in collaborative computation, homomorphic encryption is probably not
a reasonable solution.
Homomorphic encryption cannot be used to enable data scientist to circumvent GDPR.
For example, there is no way for a cloud service to use homomorphic encryption to
draw insights from encrypted customer data. Instead, results of encrypted computations
remain encrypted and can only be decrypted by the owner of the data, e.g., a cloud
service customer.
2019-05-24 09:00:03 +03:00
2019-05-24 19:30:41 +03:00
## Microsoft SEAL
2019-07-17 02:03:28 +03:00
2019-10-01 06:39:21 +03:00
Microsoft SEAL is a homomorphic encryption library that allows additions and
multiplications to be performed on encrypted integers or real numbers. Other
operations, such as encrypted comparison, sorting, or regular expressions, are
in most cases not feasible to evaluate on encrypted data using this technology.
Therefore, only specific privacy-critical cloud computation parts of programs
should be implemented with Microsoft SEAL.
It is not always easy or straightfoward to translate an unencrypted computation
into a computation on encrypted data, for example, it is not possible to branch
on encrypted data. Microsoft SEAL itself has a steep learning curve and requires
the user to understand many homomorphic encryption specific concepts, even though
in the end the API is not too complicated. Even if a user is able to program and
run a specific computation using Microsoft SEAL, the difference between efficient
and inefficient implementations can be several orders of magnitude, and it can be
hard for new users to know how to improve the performance of their computation.
Microsoft SEAL comes with two different homomorphic encryption schemes with very
different properties. The BFV scheme allows modular arithmetic to be performed on
encrypted integers. The CKKS scheme allows additions and multiplications on encrypted
real or complex numbers, but yields only approximate results. In applications such
as summing up encrypted real numbers, evaluating machine learning models on encrypted
data, or computing distances of encrypted locations CKKS is going to be by far the
best choice. For applications where exact values are necessary, the BFV scheme is
the only choice.
2019-05-24 09:00:03 +03:00
# Installing Microsoft SEAL
2018-12-01 04:41:23 +03:00
## Windows
2019-10-01 06:39:21 +03:00
Microsoft SEAL comes with a Microsoft Visual Studio 2019 solution file `SEAL.sln`
that can be used to conveniently build the library, examples, and unit tests. Visual
Studio 2017 version 15.3 or newer is required.
#### Platform
2019-10-01 06:39:21 +03:00
The Visual Studio solution `SEAL.sln` is configured to build Microsoft SEAL both
for `Win32` and `x64` platforms. Please choose the right platform before building
Microsoft SEAL. The `SEALNetNative` project or the .NET wrapper library `SEALNet`
can only be built for `x64`.
2018-12-01 04:41:23 +03:00
2019-01-30 03:12:43 +03:00
#### Debug and Release builds
2018-12-01 04:41:23 +03:00
2019-10-01 06:39:21 +03:00
You can easily switch from Visual Studio build configuration menu whether Microsoft
SEAL should be built in `Debug` mode (no optimizations) or in `Release` mode. Please
note that `Debug` mode should not be used except for debugging Microsoft SEAL itself,
as the performance will be orders of magnitude worse than in `Release` mode.
2018-12-01 04:41:23 +03:00
#### Library
2019-10-01 06:39:21 +03:00
Build the SEAL project `native\src\SEAL.vcxproj` from `SEAL.sln`. This results in
the static library `seal.lib` to be created in `native\lib\$(Platform)\$(Configuration)`.
When linking with applications, you need to add `native\src\` (full path) as an
include directory for Microsoft SEAL header files.
2018-12-01 04:41:23 +03:00
#### Examples
Build the SEALExamples project `native\examples\SEALExamples.vcxproj` from `SEAL.sln`.
This results in an executable `sealexamples.exe` to be created in `native\bin\$(Platform)\$(Configuration)`.
2018-12-01 04:41:23 +03:00
#### Unit tests
2019-05-24 09:00:03 +03:00
The unit tests require the Google Test framework to be installed. The appropriate
2019-10-01 06:39:21 +03:00
NuGet package is already listed in `native\tests\packages.config`, so once you
attempt to build the SEALTest project `native\tests\SEALTest.vcxproj` from `SEAL.sln`
Visual Studio will automatically download and install it for you.
2018-12-01 04:41:23 +03:00
## Linux and macOS
2018-12-01 04:41:23 +03:00
2019-10-01 06:39:21 +03:00
Microsoft SEAL is very easy to configure and build in Linux and macOS using CMake
(>= 3.12). A modern version of GNU G++ (>= 6.0) or Clang++ (>= 5.0) is needed. In macOS the
2018-12-01 04:41:23 +03:00
Xcode toolchain (>= 9.3) will work.
2019-05-24 09:00:03 +03:00
In macOS you will need CMake with command line tools. For this, you can either
2018-12-01 04:41:23 +03:00
1. install the cmake package with [Homebrew](https://brew.sh), or
2. download CMake directly from [https://cmake.org/download](https://cmake.org/download) and [enable command line tools](https://stackoverflow.com/questions/30668601/installing-cmake-command-line-tools-on-a-mac).
Below we give instructions for how to configure, build, and install Microsoft SEAL either
2018-12-01 04:41:23 +03:00
system-wide (global install), or for a single user (local install). A system-wide
install requires elevated (root) privileges.
2019-01-30 03:12:43 +03:00
#### Debug and Release builds
2018-12-01 04:41:23 +03:00
2019-05-24 09:00:03 +03:00
You can easily switch from CMake configuration options whether Microsoft SEAL should be built in
`Debug` mode (no optimizations) or in `Release` mode. Please note that `Debug` mode should not
be used except for debugging Microsoft SEAL itself, as the performance will be orders of magnitude
worse than in `Release` mode.
2018-12-01 04:41:23 +03:00
### Global install
#### Library
2019-01-30 03:12:43 +03:00
If you have root access to the system you can install Microsoft SEAL system-wide as follows:
2018-12-01 04:46:17 +03:00
````
cd native/src
2018-12-01 04:46:17 +03:00
cmake .
make
sudo make install
cd ../..
2018-12-01 04:46:17 +03:00
````
2018-12-01 04:41:23 +03:00
#### Examples
To build the examples do:
2018-12-01 04:46:17 +03:00
````
cd native/examples
2018-12-01 04:46:17 +03:00
cmake .
make
cd ../..
2018-12-01 04:46:17 +03:00
````
2018-12-01 04:41:23 +03:00
2019-05-24 09:00:03 +03:00
After completing the above steps the `sealexamples` executable can be found in `native/bin/`.
See `native/examples/CMakeLists.txt` for how to link Microsoft SEAL with your own project using CMake.
2018-12-01 04:41:23 +03:00
#### Unit tests
To build the unit tests you will need the [GoogleTest](https://github.com/google/googletest) framework, which is included in Microsoft SEAL as a git submodule. To download the GoogleTest source files, do:
````
git submodule update --init
````
This needs to be executed only once, and can be skipped if Microsoft SEAL was cloned with `git --recurse-submodules`. To build the tests, do:
2018-12-01 04:46:17 +03:00
````
cd native/tests
2018-12-01 04:46:17 +03:00
cmake .
make
cd ../..
2018-12-01 04:46:17 +03:00
````
2018-12-01 04:41:23 +03:00
2019-05-24 09:00:03 +03:00
After completing these steps the `sealtest` executable can be found in `native/bin/`. All unit
2018-12-01 04:41:23 +03:00
tests should pass successfully.
### Local install
#### Library
To install Microsoft SEAL locally, e.g., to `~/mylibs/`, do the following:
2018-12-01 04:46:17 +03:00
````
cd native/src
2018-12-01 04:46:17 +03:00
cmake -DCMAKE_INSTALL_PREFIX=~/mylibs .
make
make install
cd ../..
2018-12-01 04:46:17 +03:00
````
2018-12-01 04:41:23 +03:00
2019-05-24 09:00:03 +03:00
#### Examples
2018-12-01 04:41:23 +03:00
To build the examples do:
2018-12-01 04:46:17 +03:00
````
cd native/examples
2018-12-01 04:46:17 +03:00
cmake -DCMAKE_PREFIX_PATH=~/mylibs .
make
cd ../..
2018-12-01 04:46:17 +03:00
````
2018-12-01 04:41:23 +03:00
2019-05-24 09:00:03 +03:00
After completing the above steps the `sealexamples` executable can be found in `native/bin/`.
See `native/examples/CMakeLists.txt` for how to link Microsoft SEAL with your own project using CMake.
2018-12-01 04:41:23 +03:00
#### Unit tests
To build the unit tests you will need the [GoogleTest](https://github.com/google/googletest) framework, which is included in Microsoft SEAL as a git submodule. To download the GoogleTest source files, do:
````
git submodule update --init
````
2019-10-01 06:39:21 +03:00
This needs to be executed only once, and can be skipped if Microsoft SEAL was cloned with `git --recurse-submodules`. Then build the tests, do:
2018-12-01 04:46:17 +03:00
````
cd native/tests
2018-12-01 04:46:17 +03:00
cmake -DCMAKE_PREFIX_PATH=~/mylibs .
make
cd ../..
2018-12-01 04:46:17 +03:00
````
2018-12-01 04:41:23 +03:00
2019-05-24 09:00:03 +03:00
After completing these steps the `sealtest` executable can be found in `native/bin/`. All unit
2018-12-01 04:41:23 +03:00
tests should pass successfully.
2019-05-24 09:00:03 +03:00
# Installing Microsoft SEAL for .NET
2019-01-30 03:12:43 +03:00
Microsoft SEAL provides a .NET Standard library that wraps the functionality in Microsoft SEAL
for use in .NET development.
## Windows
The Microsoft Visual Studio 2019 solution file `SEAL.sln` contains the projects necessary
to build the .NET assembly, a backing native shared library, .NET examples, and unit tests.
#### Native library
2019-01-30 03:12:43 +03:00
Microsoft SEAL for .NET requires a native library that is invoked by the managed .NET library.
2019-05-24 09:00:03 +03:00
Build the SEALNetNative project `dotnet\native\SEALNetNative.vcxproj` from `SEAL.sln`.
Building SEALNetNative results in the dynamic library `sealnetnative.dll` to be created
in `dotnet\lib\$(Platform)\$(Configuration)`. This library is meant to be used only by the
.NET library, not by end users, and needs to be present in the same directory as your
executable when developing a .NET application.
2019-01-30 03:12:43 +03:00
#### .NET library
2019-05-24 09:00:03 +03:00
Once you have built the shared native library (see above), build the SEALNet project
`dotnet\src\SEALNet.csproj` from `SEAL.sln`. Building SEALNet results in the assembly
`SEALNet.dll` to be created in `dotnet\lib\$(Configuration)\netstandard2.0`. This
is the assembly you can reference in your application.
2019-01-30 03:12:43 +03:00
#### .NET examples
Build the SEALNetExamples project `dotnet\examples\SEALNetExamples.csproj` from `SEAL.sln`.
This results in the assembly `SEALNetExamples.dll` to be created in
`dotnet\bin\$(Configuration)\netcoreapp2.1`. The project takes care of copying the
native SEALNetNative library to the output directory.
2019-01-30 03:12:43 +03:00
#### .NET unit tests
Build the SEALNet Test project `dotnet\tests\SEALNetTest.csproj` from `SEAL.sln`. This results
in the `SEALNetTest.dll` assembly to be created in `dotnet\lib\$(Configuration)\netcoreapp2.1`.
The project takes care of copying the native SEALNetNative library to the output directory.
2019-01-30 03:12:43 +03:00
### Using Microsoft SEAL for .NET in your own application
2019-01-30 03:12:43 +03:00
To use Microsoft SEAL for .NET in your own application you need to:
1. add a reference in your project to `SEALNet.dll`;
2. ensure `sealnetnative.dll` is available for your application when run. The easiest way to ensure
this is to copy `sealnetnative.dll` to the same directory where your application's executable
is located.
Alternatively, you can build and use a NuGet package; see instructions in [NUGET.md](dotnet/nuget/NUGET.md).
2019-01-31 01:42:46 +03:00
## Linux and macOS
2019-01-30 03:12:43 +03:00
Microsoft SEAL for .NET relies on a native shared library that can be easily configured and built
2019-09-30 21:50:42 +03:00
using CMake (>= 3.12) and a modern version of GNU G++ (>= 6.0) or Clang++ (>= 5.0). In macOS
the Xcode toolchain (>= 9.3) will work.
2019-01-30 03:12:43 +03:00
For compiling .NET code you will need to install a .NET Core SDK (>= 2.1). You can follow
these [instructions for installing in Linux](https://dotnet.microsoft.com/download?initial-os=linux),
or for [installing in macOS](https://dotnet.microsoft.com/download?initial-os=macos).
### Local use of shared native library
2019-05-24 09:00:03 +03:00
If you only intend to run the examples and unit tests provided with Microsoft SEAL,
you do not need to install the native shared library, you only need to compile it.
The SEALNetExamples and SEALNetTest projects take care of copying the native shared
library to the appropriate assembly output directory.
To compile the native shared library you will need to:
1. Compile Microsoft SEAL as a static or shared library with Position-Independent Code (PIC);
2. Compile native shared library.
2019-05-24 09:00:03 +03:00
The instructions for compiling Microsoft SEAL are similar to the instructions described
[above](#linux-and-macos) for a global or local install. Make sure the CMake configuration
option `SEAL_LIB_BUILD_TYPE` is set to either `Static_PIC` (default) or `Shared`. Assuming
Microsoft SEAL was built and installed globally using the default CMake configuration
options, we can immediately use it to compile the shared native library required for .NET:
````
cd dotnet/native
cmake .
make
cd ../..
````
If Microsoft SEAL was installed locally instead, use:
````
cd dotnet/native
cmake -DCMAKE_PREFIX_PATH=~/mylibs .
make
cd ../..
````
2019-01-30 03:12:43 +03:00
#### .NET library
To build the .NET Standard library, do the following:
````
cd dotnet/src
dotnet build
cd ../..
````
2019-05-31 03:24:25 +03:00
You can use the `dotnet` parameter `--configuration <Debug|Release>` to build either
a `Debug` or `Release` version of the assembly. This will result in a `SEALNet.dll`
assembly to be created in `dotnet/lib/$(Configuration)/netstandard2.0`. This assembly
is the one you will want to reference in your own projects.
#### Examples
To build and run the .NET examples, do:
````
cd dotnet/examples
dotnet run
cd ../..
````
2019-05-24 09:00:03 +03:00
As mentioned before, the .NET project will copy the shared native library to the assembly
output directory. You can use the `dotnet` parameter `--configuration <Debug|Release>` to
run either `Debug` or `Release` versions of the examples.
#### Unit tests
To build and run the .NET unit tests, do:
````
cd dotnet/tests
dotnet test
cd ../..
````
2019-05-31 03:24:25 +03:00
All unit tests should pass. You can use the `dotnet` parameter `--configuration <Debug|Release>`
to run `Debug` or `Relase` unit tests, and you can use `--verbosity detailed` to print the list
of unit tests that are being run.
2019-10-01 06:39:21 +03:00
## Optional Dependencies
Microsoft SEAL has no required dependencies, but certain optional features can be
enabled if it is compiled with support for specific third-party libraries.
### Microsoft GSL
Microsoft GSL (Guidelines Support Library) is a header-only library that implements
two convenient (templated) data types: `gsl::span` and `gsl::multi_span`. These
are *view types* that provide safe (bounds-checked) array access to memory. For
example, if Microsoft GSL is available, Microsoft SEAL can allows `BatchEncoder`
and `CKKSEncoder` to encode from and decode to a `gsl::span` instead of `std::vector`,
which can have significant performance benefits. Additionally, `BatchEncoder` allows
access to the slot data alternatively through a two-dimensional `gsl::multi_span`,
reflecting the batching slot structure. Also the `Ciphertext` class allows the
ciphertext data to be accessed hierarchically through a `gsl::multi_span`.
#### Microsoft GSL in Windows
To build Microsoft SEAL with support for Microsoft GSL, clone first the Microsoft GSL
library from [https://github.com/Microsoft/GSL](GitHub.com/Microsoft/GSL) to some
2019-10-01 08:25:11 +03:00
convenient directory, e.g., `native\GSL` in this example. Then open the Microsoft
SEAL solution file in Visual Studio, right-click on the project SEAL in the *Solution
Explorer*, click *Properties*, and add (for all configurations and all platforms)
the following directory to the list of *Include Directories* on the *VC++ Directories*
tab:
2019-10-01 06:39:21 +03:00
````
2019-10-01 08:25:11 +03:00
$(SolutionDir)native\GSL\include
2019-10-01 06:39:21 +03:00
````
Rebuilding Microsoft SEAL should now automatically detect that Microsoft GSL is
available, and enable both `gsl::span` and `gsl::multi_span` support. Note that
any programs or libraries consuming Microsoft SEAL will now also need access to
2019-10-01 08:25:11 +03:00
the Microsoft GSL header files, so you might need to add the `native\GSL\include`
directory to *Include Directories* in your other projects as well.
2019-10-01 06:39:21 +03:00
#### Microsoft GSL in Linux and macOS
2019-10-01 08:25:11 +03:00
On Linux and macOS Microsoft GSL can be most conveniently obtained through a package
manager such as APT on Linux (package `libmsgsl-dev`) or Homebrew on macOS (package
`cpp-gsl`). Alternatively, you can simply clone it from
[https://github.com/Microsoft/GSL](GitHub.com/Microsoft/GSL). When installed using
a package manager, CMake will likely detect the Microsoft GSL header file location
automatically. Alternatively, if Microsoft GSL is cloned to `~/mylibs/GSL`, you may
provide CMake with this location for building Microsoft SEAL as follows:
````
cd native/src
cmake . -DMSGSL_ROOT=~/mylibs/GSL/include
make
````
2019-10-01 06:39:21 +03:00
### ZLIB
2019-10-01 08:25:11 +03:00
ZLIB is a widely used compression library that implements the *DEFLATE* compression
algorithm. If present, Microsoft SEAL can use ZLIB to automatically compress data
that is serialized. For example, in some cases `Ciphertext` objects consist of a large
number of integers modulo specific prime numbers. When using the CKKS scheme these
prime numbers can often be quite small (e.g., 30 bits), but the numbers will always
be serialized as 64-bit integers. Thus, in this case more than half of the ciphertext
data consists of zeros, which a compression library, such as ZLIB, can compress away.
The BFV scheme benefits typically less from this technique, because the prime numbers
tend to be larger and integers modulo these prime numbers fill more of each 64-bit
word. The compression is not only applied to `Ciphertext` objects, but to every
serializable Microsoft SEAL object.
**WARNING: The compression rate for a `SecretKey` can reveal information about the
key. In most common applications of Microsoft SEAL the size of a `SecretKey` would
not be deliberately revealed to untrusted parties, but if this is a concern we
recommend saving the `SecretKey` in an uncompressed form by passing
`compr_mode_type::none` to `SecretKey::save`.**
2019-10-01 06:39:21 +03:00
#### ZLIB in Windows
2019-10-01 08:25:11 +03:00
ZLIB is usually not found on a typical Windows system, but you can clone it from
[https://github.com/madler/zlib](GitHub.com/madler/zlib) to some convenient
directory, e.g., `native\zlib` in this example. To build ZLIB on Windows, open the
*Developer Command Prompt for VS 2019*, switch to `native\zlib`, and do:
````
cmake .
cmake --build . --config Release
copy Release\zlib.dll ..\bin
````
Then open the Microsoft SEAL solution file in Visual Studio, right-click on the
project SEAL in the *Solution Explorer*, click *Properties*, and add (for all
configurations and all platforms) on the *VC++ Directories* tab the following
directory to the list of *Include Directories*:
````
$(SolutionDir)native\zlib
````
and the following directory to the list of *Library Directories*:
````
$(SolutionDir)native\zlib\Release
````
Next, open the *Librarian* tab and add `zlib.lib` to *Additional Dependencies*.
Rebuilding Microsoft SEAL should now automatically detect that ZLIB is available,
and enable support for using `compr_mode_type::deflate` in serialization.
When running applications built against a ZLIB-enabled Microsoft SEAL you will
need to ensure that a copy of `native\zlib\Release\zlib.dll` resides in the same
directory where the application executable is.
2019-10-01 06:39:21 +03:00
#### ZLIB in Linux and macOS
2019-10-01 08:25:11 +03:00
On Ubuntu Linux ZLIB can be most conveniently obtained through APT:
````
sudo apt install zlib1g-dev
````
On macOS ... **TODO TODO TODO**
Alternatively, on either Linux or macOS, you can simply clone it from
[https://github.com/madler/zlib](GitHub.com/madler/zlib). For example, you can clone
it to `~/mylibs/zlib` and do:
````
cd ~/mylibs/zlib
cmake .
make
````
When building Microsoft SEAL you may provide CMake with this location as follows:
````
cd native/src
cmake . -DZLIB_ROOT=~/mylibs/zlib
make
```
### Using Microsoft SEAL for .NET in your own application
2019-01-30 03:12:43 +03:00
To use Microsoft SEAL for .NET in your own application you need to:
1. add a reference in your project to `SEALNet.dll`;
2. ensure the native shared library is available for your application when run. The easiest way to ensure this is to copy `libsealnetnative.so` to the same directory where your application's executable is located.
2019-05-24 09:00:03 +03:00
In Linux or macOS, if you have root access to the system, you have the option to install the
native shared library globally. Then your application will always be able to find and load it.
2019-05-24 09:00:03 +03:00
Assuming Microsoft SEAL is build and installed globally, you can install the shared native
library globally as follows:
````
cd dotnet/native
cmake .
make
sudo make install
cd ../..
````
2019-05-31 03:24:25 +03:00
# Getting Started
2019-10-01 06:39:21 +03:00
2019-05-31 03:24:25 +03:00
Using Microsoft SEAL will require the user to invest some time in learning fundamental
concepts in homomorphic encryption. The code comes with heavily commented examples that
2019-05-31 03:57:50 +03:00
are designed to gradually teach such concepts as well as to demonstrate much of the API.
2019-05-31 03:24:25 +03:00
The code examples are available (and identical) in C++ and C#, and are divided into
several source files in `native/examples/` (C++) and `dotnet/examples/` (C#), as follows:
|C++ |C# |Description |
|-------------------|------------------|----------------------------------------------------------------------------|
|`examples.cpp` |`Examples.cs` |The example runner application |
|`1_bfv_basics.cpp` |`1_BFV_Basics.cs` |Encrypted modular arithmetic using the BFV scheme |
|`2_encoders.cpp` |`2_Encoders.cs` |Encoding more complex data into Microsoft SEAL plaintext objects |
|`3_levels.cpp` |`3_Levels.cs` |Introduces the concept of levels; prerequisite for using the CKKS scheme |
|`4_ckks_basics.cpp`|`4_CKKS_Basics.cs`|Encrypted real number arithmetic using the CKKS scheme |
|`5_rotation.cpp` |`5_Rotation.cs` |Performing cyclic rotations on encrypted vectors in the BFV and CKKS schemes|
|`6_performance.cpp`|`6_Performance.cs`|Performance tests for Microsoft SEAL |
It is recommeded to read the comments and the code snippets along with command line printout
from running an example. For easier navigation, command line printout provides the line number
in the associated source file where the associated code snippets start.
2019-05-31 03:57:50 +03:00
**WARNING: It is impossible to use Microsoft SEAL correctly without reading all examples
or by simply re-using the code from examples. Any developer attempting to do so
will inevitably produce code that is *vulnerable*, *malfunctioning*, or *extremely slow*.**
2019-06-11 03:01:17 +03:00
# Contributing
2019-05-24 09:00:03 +03:00
This project welcomes contributions and suggestions. Most contributions require you
2019-02-08 05:54:40 +03:00
to agree to a Contributor License Agreement (CLA) declaring that you have the right to,
2019-05-24 09:00:03 +03:00
and actually do, grant us the rights to use your contribution. For details, visit
2019-02-08 05:54:40 +03:00
https://cla.microsoft.com.
2019-05-24 09:00:03 +03:00
When you submit a pull request, a CLA-bot will automatically determine whether you need
to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow
the instructions provided by the bot. You will only need to do this once across all
2019-02-08 05:54:40 +03:00
repos using our CLA.
Pull requests must be submitted to the branch called `contrib`.
2019-05-24 09:00:03 +03:00
This project has adopted the
2019-02-08 05:54:40 +03:00
[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
2019-05-24 09:00:03 +03:00
For more information see the
[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional
2019-02-08 05:54:40 +03:00
questions or comments.
2019-02-21 03:17:53 +03:00
# Citing Microsoft SEAL
To cite Microsoft SEAL in academic papers, please use the following BibTeX entries.
### Version 3.4
@misc{sealcrypto,
title = {{M}icrosoft {SEAL} (release 3.4)},
howpublished = {\url{https://github.com/Microsoft/SEAL}},
month = oct,
year = 2019,
note = {Microsoft Research, Redmond, WA.},
key = {SEAL}
}
### Version 3.3
2019-06-11 03:01:17 +03:00
@misc{sealcrypto,
title = {{M}icrosoft {SEAL} (release 3.3)},
2019-06-11 03:01:17 +03:00
howpublished = {\url{https://github.com/Microsoft/SEAL}},
month = june,
year = 2019,
note = {Microsoft Research, Redmond, WA.},
key = {SEAL}
}
2019-02-21 03:17:53 +03:00
### Version 3.2
2019-06-11 03:01:17 +03:00
@misc{sealcrypto,
2019-02-21 03:17:53 +03:00
title = {{M}icrosoft {SEAL} (release 3.2)},
2019-06-11 03:01:17 +03:00
howpublished = {\url{https://github.com/Microsoft/SEAL}},
month = feb,
year = 2019,
note = {Microsoft Research, Redmond, WA.},
key = {SEAL}
}
2019-02-21 03:17:53 +03:00
### Version 3.1
2019-06-11 03:01:17 +03:00
@misc{sealcrypto,
2019-02-21 03:17:53 +03:00
title = {{M}icrosoft {SEAL} (release 3.1)},
2019-06-11 03:01:17 +03:00
howpublished = {\url{https://github.com/Microsoft/SEAL}},
month = dec,
year = 2018,
note = {Microsoft Research, Redmond, WA.},
key = {SEAL}
}
2019-02-21 03:17:53 +03:00
### Version 3.0
2019-06-11 03:01:17 +03:00
2019-02-21 03:17:53 +03:00
@misc{sealcrypto,
2019-06-11 03:01:17 +03:00
title = {{M}icrosoft {SEAL} (release 3.0)},
howpublished = {\url{http://sealcrypto.org}},
month = oct,
year = 2018,
note = {Microsoft Research, Redmond, WA.},
key = {SEAL}
2019-06-07 03:08:06 +03:00
}