` page.
7 |
8 | .. toctree::
9 | :maxdepth: 1
10 | :caption: Contents:
11 |
12 | directory_structure.rst
13 | security.rst
14 | installation/installation.rst
15 | using_the_library.rst
16 | building_user_applications.rst
17 | editor_setup.rst
18 | exceptions_in_openfhe.rst
19 |
--------------------------------------------------------------------------------
/cicd/github-runner/user-data.txt:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | update
4 | sudo apt update
5 |
6 | # install cmake
7 | sudo apt install cmake=3.16.3-1ubuntu1
8 |
9 | # install clagn
10 | sudo apt-get install clang-10
11 |
12 | # install required packages
13 | sudo apt-get install build-essential
14 | sudo apt-get install autoconf -y
15 | sudo apt-get install -y libntl-dev -y
16 | sudo apt-get install -y libgmp-dev -y
17 | sudo apt-get install libtool -y
18 |
19 | # for documen
20 | sudo apt-get install doxygen -y
21 | sudo apt-get install graphviz -y
22 |
--------------------------------------------------------------------------------
/src/core/include/lattice/hal/README.md:
--------------------------------------------------------------------------------
1 | # Hardware Abstraction Layer (HAL)
2 |
3 | ```mermaid
4 | graph BT
5 | a[DCRTPolyInterface] --> |Inherited by|b[DCRTPoly - HAL Default];
6 | ```
7 |
8 | This hardware abstraction layer allows OpenFHE to use a variety of device backends while still allowing for high performance. As of March 31st 2022, we have the default backend, and the [Intel HEXL](https://github.com/intel/hexl) backend.
9 |
10 | ## Note:
11 |
12 | Follow the convention set by the [hexl](hexl) implementation to extend the supported backends.
13 |
--------------------------------------------------------------------------------
/CPPLINT.cfg:
--------------------------------------------------------------------------------
1 | # Ignore all filters:
2 | #filter=-whitespace
3 | filter=-whitespace/line_length
4 | filter=-whitespace/newline
5 | filter=-whitespace/indent
6 |
7 | #filter=-build
8 | filter=-build/include_subdir
9 | filter=-build/include_order
10 | filter=-build/header_guard
11 | filter=-build/c++11
12 | filter=-build/namespaces
13 |
14 | #filter=-readability
15 | filter=-readability/braces
16 | filter=-readability/todo
17 | filter=-readability/fn_size
18 |
19 | #filter=-runtime
20 | filter=-runtime/references
21 | filter=-runtime/string
22 |
23 | #filter=-legal
24 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # Documentation
2 |
3 | ## Local Builds
4 |
5 | - This is meant for testing locally, particularly if you do not have admin access on the [readthedocs](https://readthedocs.org/)
6 |
7 | - Building: run `make html` while in this directory.
8 |
9 | ## Testing Changes
10 |
11 | 1) run `pip install restview`
12 |
13 | 2) run `restivew X.rst` which will render that file.
14 |
15 |
16 | ## Remote Builds
17 |
18 | - Specifically for readthedocs, the system will automatically handle the builds for the `main` and `latest` branches. For anything else, reach
19 | out to the admins for permissions.
20 |
21 |
--------------------------------------------------------------------------------
/docker/benchmark.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Pablo Echegorri
4 | # 5-3-2020
5 | # pabloechegorri@gmail.com
6 |
7 | ##
8 | ## Copy disclaimer here below
9 |
10 | # benchmark examples extras
11 |
12 | BENCHMARKS=/openfhe-development/build/bin/benchmark/*
13 | RESULTS=/var/www/html/benchmark.html
14 |
15 | echo "" >> $RESULTS
16 | echo "" >> $RESULTS
17 | for benchmark in $BENCHMARKS
18 | do
19 | echo "Running $benchmark"
20 | echo "" >> $RESULTS
21 | $benchmark > >(tee -a $RESULTS) 2> >(tee -a $RESULTS >&2)
22 | echo -e "\n
" >> $RESULTS
23 |
24 | done
25 | echo "" >> $RESULTS
26 |
27 |
--------------------------------------------------------------------------------
/docs/conf_theme.rst:
--------------------------------------------------------------------------------
1 | .. code-block:: py
2 |
3 | # The name of the Pygments (syntax highlighting) style to use.
4 | # `sphinx` works very well with the RTD theme, but you can always change it
5 | pygments_style = 'sphinx'
6 |
7 | # on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
8 | on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
9 |
10 | if not on_rtd: # only import and set the theme if we're building docs locally
11 | import sphinx_rtd_theme
12 | html_theme = 'sphinx_rtd_theme'
13 | html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
14 |
15 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Set the default behavior, in case people don't have core.autocrlf set.
2 | * text=auto
3 |
4 | # Explicitly declare text files you want to always be normalized and converted
5 | # to native line endings on checkout.
6 | *.c text
7 | *.cc text
8 | *.cpp text
9 | *.h text
10 | *.y text
11 | *.l text
12 | *.java text
13 | *.mac text
14 | *.txt text
15 | *.sh text
16 | *.py text
17 | Makefile* text
18 |
19 | # Declare files that will always have CRLF line endings on checkout.
20 | *.sln text eol=crlf
21 |
22 | # Denote all files that are truly binary and should not be modified.
23 | *.png binary
24 | *.jpg binary
25 | *.xlsx binary
26 | *.lz binary
27 | *.gz binary
28 |
--------------------------------------------------------------------------------
/docs/sphinx_rsts/modules/core/utils/core_utils.rst:
--------------------------------------------------------------------------------
1 | Core Utils Documentation
2 | ====================================
3 |
4 | Documentation for `core/include/utils/ `_
5 |
6 | .. toctree::
7 | :maxdepth: 3
8 | :caption: Sub-Contents:
9 |
10 | block_allocator.rst
11 | prng.rst
12 |
13 | .. contents:: Page Contents
14 | :local:
15 |
16 |
17 | Core Utils
18 | ------------------------
19 |
20 | Contains utils for the underlying math layer including the following capabilities:
21 |
22 | - debugging utilities
23 |
24 | - memory management utilities
25 |
26 | - parallel operations
27 |
28 | - serialization
29 |
--------------------------------------------------------------------------------
/.readthedocs.yaml:
--------------------------------------------------------------------------------
1 | # .readthedocs.yaml
2 | # Read the Docs configuration file
3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4 |
5 | # Required
6 | version: 2
7 |
8 | # Set the version of Python and other tools you might need
9 | build:
10 | os: ubuntu-22.04
11 | tools:
12 | python: "3.11"
13 | apt_packages:
14 | - graphviz
15 |
16 | # Build documentation in the docs/ directory with Sphinx
17 | sphinx:
18 | configuration: docs/conf.py
19 |
20 | # We recommend specifying your dependencies to enable reproducible builds:
21 | # https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
22 | python:
23 | install:
24 | - requirements: docs/requirements.txt
25 |
--------------------------------------------------------------------------------
/src/core/include/utils/README.md:
--------------------------------------------------------------------------------
1 | # Misc. Utils
2 |
3 | ## Block Allocator
4 |
5 | - Utility for allocating and freeing fixed blocks of memory memory.
6 |
7 | - Prevents memory faults by using a heap
8 |
9 | - Basically a custom memory management system.
10 |
11 | ## PRNG
12 |
13 | - Our cryptographic hash function is based off of [Blake2b](https://blake2.net), which allows fast hashing.
14 |
15 | - To define new `PRNG` engines, refer to [blake2engine.h](prng/blake2engine.h).
16 |
17 | - Additionally, we refer users to [sampling-readme](https://openfhe-development.readthedocs.io/en/latest/assets/sphinx_rsts/modules/core/math/sampling.html) for more information about sampling in OpenFHE, as well as how to use these samplers.
--------------------------------------------------------------------------------
/src/core/include/utils/prng/README.md:
--------------------------------------------------------------------------------
1 | # PRNG Engine(s)
2 |
3 | Refer to our [readthedocs - PRNG Engine(s)](https://openfhe-development.readthedocs.io/en/latest/sphinx_rsts/modules/core/utils/prng.html) for more information.
4 |
5 | Additionally, we refer users to [sampling documentation](https://openfhe-development.readthedocs.io/en/latest/sphinx_rsts/modules/core/math/sampling.html) for
6 | more information about sampling in OpenFHE, as well as how to use these samplers.
7 |
8 | ## Blake2
9 |
10 | - Our cryptographic hash function is based off of [Blake2b](https://blake2.net), which allows fast hashing.
11 |
12 | ## Using a custom PRNG Engine
13 |
14 | To define new `PRNG` engines, refer to [blake2engine.h](blake2engine.h).
15 |
--------------------------------------------------------------------------------
/docs/requirements.txt:
--------------------------------------------------------------------------------
1 | alabaster==0.7.12
2 | Babel==2.9.1
3 | breathe==4.33.1
4 | certifi>=2023.7.22
5 | charset-normalizer==2.0.12
6 | docutils==0.17.1
7 | exhale>=0.3.0
8 | idna>=3.7
9 | imagesize==1.3.0
10 | importlib-metadata>=4.0.0
11 | jinja2>=3.1.3
12 | MarkupSafe>=2.0.0
13 | packaging==21.3
14 | Pygments>=2.15.0
15 | pyparsing==3.0.7
16 | pytz==2021.3
17 | requests>=2.31.0
18 | snowballstemmer==2.2.0
19 | Sphinx==4.4.0
20 | sphinx-rtd-theme==1.0.0
21 | sphinxcontrib-applehelp==1.0.2
22 | sphinxcontrib-devhelp==1.0.2
23 | sphinxcontrib-htmlhelp==2.0.0
24 | sphinxcontrib-jsmath==1.0.1
25 | sphinxcontrib-mermaid==0.7.1
26 | sphinxcontrib-qthelp==1.0.3
27 | sphinxcontrib-serializinghtml==1.1.5
28 | urllib3>=1.26.18
29 | zipp>=3.19.1
30 |
--------------------------------------------------------------------------------
/configure/config_core.in:
--------------------------------------------------------------------------------
1 | //==================================================
2 | // DO NOT TOUCH THIS FILE! It is generated by cmake
3 | //==================================================
4 | #ifndef __CMAKE_GENERATED_CONFIG_CORE_H__
5 | #define __CMAKE_GENERATED_CONFIG_CORE_H__
6 |
7 | #cmakedefine WITH_BE2
8 | #cmakedefine WITH_BE4
9 | #cmakedefine WITH_NOISE_DEBUG
10 | #cmakedefine WITH_REDUCED_NOISE
11 | #cmakedefine WITH_NTL
12 | #cmakedefine WITH_TCM
13 | #cmakedefine WITH_OPENMP
14 | #cmakedefine WITH_NATIVEOPT
15 |
16 | #cmakedefine CKKS_M_FACTOR @CKKS_M_FACTOR@
17 | #cmakedefine HAVE_INT128 @HAVE_INT128@
18 | #cmakedefine HAVE_INT64 @HAVE_INT64@
19 | #cmakedefine MATHBACKEND @MATHBACKEND@
20 | #cmakedefine NATIVEINT @NATIVEINT@
21 |
22 | #endif // __CMAKE_GENERATED_CONFIG_CORE_H__
23 |
--------------------------------------------------------------------------------
/docker/upload-tagged-docker.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | while getopts ":r:j:t:" OPTION
3 | do
4 | case $OPTION in
5 | t)
6 | TAG=$OPTARG;;
7 | j)
8 | THREADS=$OPTARG;;
9 | r)
10 | REPOSITORY=$OPTARG;;
11 |
12 | \?)
13 | echo "Please use the -r tag to set a repository, -j tag to set the number of threads for make and -t flag to set a tag"
14 | exit
15 | ;;
16 | esac
17 | done
18 |
19 | docker build -t $REPOSITORY . --build-arg no_threads=$THREADS --build-arg repository=$REPOSITORY --build-arg tag=$TAG
20 | docker run -dit --name openfhe -p 80:80 $REPOSITORY
21 | docker commit openfhe openfhe:$TAG
22 | docker login registry.github.com
23 | docker image tag openfhe:$TAG registry.github.com/openfheorg/$REPOSITORY/$TAG:$TAG
24 | docker push registry.github.com/openfheorg/$REPOSITORY/$TAG:$TAG
25 |
--------------------------------------------------------------------------------
/docs/sphinx_rsts/modules/core/core.rst:
--------------------------------------------------------------------------------
1 | Core Library Documentation
2 | ====================================
3 |
4 | `Github Src `_
5 |
6 | File Listings
7 | -----------------------
8 |
9 | `OpenFHE Core Top-Level Include (openfhecore.h) `_
10 |
11 | - Top-level ``#include`` for access to all capabilities
12 |
13 | `Unit Test Definitions (testdefs.h) `_
14 |
15 | - Defines various macros for unit testing
16 |
17 | `Version (version.h) `_
18 |
19 | - Get the current `OpenFHE` version by parsing the `CMAKE` version
20 |
--------------------------------------------------------------------------------
/docs/the_requirements.rst:
--------------------------------------------------------------------------------
1 | .. code-block:: nginx
2 |
3 | alabaster==0.7.12
4 | Babel==2.9.1
5 | breathe==4.33.1
6 | certifi==2021.10.8
7 | charset-normalizer==2.0.12
8 | docutils==0.17.1
9 | exhale>=0.3.0
10 | idna==3.3
11 | imagesize==1.3.0
12 | importlib-metadata>=4.0.0
13 | Jinja2==3.0.3
14 | MarkupSafe>=2.0.0
15 | packaging==21.3
16 | Pygments==2.11.2
17 | pyparsing==3.0.7
18 | pytz==2021.3
19 | requests==2.27.1
20 | snowballstemmer==2.2.0
21 | Sphinx==4.4.0
22 | sphinx-rtd-theme==1.0.0
23 | sphinxcontrib-applehelp==1.0.2
24 | sphinxcontrib-devhelp==1.0.2
25 | sphinxcontrib-htmlhelp==2.0.0
26 | sphinxcontrib-jsmath==1.0.1
27 | sphinxcontrib-mermaid==0.7.1
28 | sphinxcontrib-qthelp==1.0.3
29 | sphinxcontrib-serializinghtml==1.1.5
30 | urllib3==1.26.9
31 | zipp==3.7.0
32 |
33 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | # To check files before committing them:
2 | # pre-commit run --files [file1] [file2] ...
3 | repos:
4 | - repo: https://github.com/pre-commit/pre-commit-hooks
5 | rev: v2.5.0
6 | hooks:
7 | - id: trailing-whitespace
8 | - id: end-of-file-fixer
9 | - id: check-merge-conflict
10 | - id: mixed-line-ending
11 | - id: check-byte-order-marker
12 | - repo: local
13 | hooks:
14 | - id: clang-format
15 | name: clang-format
16 | entry: clang-format
17 | language: system
18 | files: \.(c|cc|cxx|cpp|h|hpp|hxx|js|proto)$
19 | args: ["-i"]
20 | - id: cpplint
21 | name: cpplint
22 | entry: cpplint
23 | language: system
24 | files: \.(c|cc|cxx|cpp|h|hpp|hxx)$
25 | args: ["--recursive"]
26 |
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | SPHINXPROJ = ExhaleCompanion
8 | SOURCEDIR = .
9 | BUILDDIR = _build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile clean
16 |
17 | clean:
18 | rm -rf doxyoutput/ api/
19 | # these are specific to the companion site, ignore this rm
20 | rm -f conf_extensions.rst conf_theme.rst
21 | @$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
22 |
23 | # Catch-all target: route all unknown targets to Sphinx using the new
24 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
25 | %: Makefile
26 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
27 |
28 |
--------------------------------------------------------------------------------
/scripts/setup/NTL_and_GMP_install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # required tools curl, tar, lzip
4 | #
5 | # sudo apt-get install -y curl tar lzip
6 |
7 | ## GMP AND NTL INSTALL
8 | ### GMP
9 | curl -O https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.lz
10 | tar --lzip -xvf gmp-6.1.2.tar.lz
11 | ( \
12 | pushd ./gmp-6.1.2 || exit -1; \
13 | ./configure && \
14 | make -j `nproc` && \
15 | make check && \
16 | sudo make install || exit -1 \
17 | popd; \
18 | )
19 |
20 | rm gmp-6.1.2.tar.lz
21 | rm -rf gmp-6.1.2
22 |
23 | ### NTL
24 | curl -O https://libntl.org/ntl-10.5.0.tar.gz
25 | tar -xvf ntl-10.5.0.tar.gz
26 | ( \
27 | pushd ./ntl-10.5.0/src || exit -1; \
28 | ./configure NTL_THREADS=on NTL_THREAD_BOOST=on NTL_EXCEPTIONS=on SHARED=on NTL_STD_CXX11=on NTL_SAFE_VECTORS=off TUNE=generic && \
29 | make -j `nproc` && \
30 | make check && \
31 | sudo make install || exit -1; \
32 | popd; \
33 | )
34 |
35 | rm ntl-10.5.0.tar.gz
36 | rm -rf ntl-10.5.0
37 |
--------------------------------------------------------------------------------
/src/binfhe/README.md:
--------------------------------------------------------------------------------
1 | # Directory Structure
2 |
3 | ## Examples:
4 |
5 | We provide the following classes of examples for symmetric encryption and public-key encryption:
6 |
7 | ### Simple Boolean
8 |
9 | - evaluation of binary gates and multi-input gates
10 | - bootstrapping for `AP` (DM) and `GINX` (CGGI) and `LMKCDEY`
11 | - serialization to binary and json formats
12 |
13 | ### Evaluation of functions
14 |
15 | The supported function evaluations are based on the functionalities described
16 | in [Large-Precision Homomorphic Sign Evaluation using FHEW/TFHE Bootstrapping](https://eprint.iacr.org/2021/1337).
17 |
18 | - digit decomposition
19 | - floor function (reduce by a certain number of bits)
20 | - arbitrary function(lookup table) _f: Zp -> Zp_ on the input ciphertext
21 | - sign function to get the MSB of an input
22 |
23 | ## include
24 |
25 | - Header files
26 |
27 | ## lib
28 |
29 | - implementation of the header files
30 |
--------------------------------------------------------------------------------
/docs/sphinx_rsts/modules/pke/pke_scheme.rst:
--------------------------------------------------------------------------------
1 | PKE Scheme documentation
2 | ====================================
3 |
4 | This is comprised of 3 folders:
5 |
6 | - `scheme `_, which contains the specifications of the different RNS implementations
7 |
8 | - `schemebase `_, which contains the base implementations of various functionalities
9 |
10 | - `schemerns `_, which contains the base RNS scheme implementation.
11 |
12 | At a high level, this can be thought of as:
13 |
14 | .. mermaid::
15 |
16 | graph BT
17 | A[Scheme Base] --> |Inherited by|B[Scheme RNS];
18 | B[Scheme RNS] --> |Inherited by|D[Scheme: CKKS-RNS];
19 | B[Scheme RNS] --> |Inherited by|E[Scheme: BGV-RNS];
20 | B[Scheme RNS] --> |Inherited by|F[Scheme: BFV-RNS];
21 |
--------------------------------------------------------------------------------
/docs/sphinx_rsts/modules/modules.rst:
--------------------------------------------------------------------------------
1 | OpenFHE Modules
2 | =================================================
3 |
4 | Understanding the various Modules
5 | ------------------------------------
6 |
7 | .. mermaid::
8 |
9 | graph BT
10 | A[CORE
- math implementation
- lattice implementation
- serialization] --> B[PKE
-generalized FHE];
11 | A --> C[BINFHE
- boolean FHE];
12 | B --> D[Application
- encrypted data analysis
- privacy-compliant data sharing];
13 | C --> D;
14 |
15 | Boolean FHE
16 | ----------------------------
17 | .. toctree::
18 | :maxdepth: 2
19 |
20 | binfhe.rst
21 |
22 |
23 | Core
24 | ----------------------------
25 | .. toctree::
26 | :maxdepth: 2
27 |
28 | core/core.rst
29 | core/lattice/core_lattice.rst
30 | core/lattice/hal.rst
31 | core/math/core_math.rst
32 | core/utils/core_utils.rst
33 |
34 |
35 | Public-Key Encryption (PKE)
36 | ----------------------------
37 | .. toctree::
38 | :maxdepth: 2
39 |
40 | pke/pke.rst
41 | pke/pke_encoding.rst
42 | pke/pke_keys.rst
43 | pke/pke_keyswitch.rst
44 | pke/pke_scheme.rst
45 |
--------------------------------------------------------------------------------
/docs/sphinx_rsts/intro/tutorials.rst:
--------------------------------------------------------------------------------
1 | Tutorials on Cryptographic Capabilities
2 | ====================================
3 |
4 | - `Description of the CryptoContext parameters for BGV, BFV, and CKKS `_
5 |
6 | - `CKKS Noise Flooding `_
7 |
8 | - `Smooth Arbitrary Function Evaluation in CKKS `_
9 |
10 | - `Scheme Switching between CKKS and FHEW/TFHE `_
11 |
12 | - `Threshold FHE for BGV, BFV, and CKKS `_
13 |
14 | - `Interactive CKKS Bootstrapping `_
15 |
16 | - `CKKS Composite Scaling `_
17 |
--------------------------------------------------------------------------------
/src/README.md:
--------------------------------------------------------------------------------
1 | # OpenFHE Code Components
2 |
3 | ```mermaid
4 | flowchart BT
5 | A[CORE
- math implementation
- lattice implementation
- serialization] --> B[PKE
-SIMD FHE];
6 | A --> C[BINFHE
- binary FHE];
7 | B --> D[Application
- encrypted data analysis
- privacy-compliant data sharing];
8 | C --> D;
9 | ```
10 |
11 | # binFHE
12 |
13 | - Boolean arithmetic, comparisons, and aribtrary function evaluation based on DM and CGGI schemes
14 |
15 | # core
16 |
17 | - underlying implementation providing the base that `binFHE` and `pke` are built off of
18 |
19 | # pke
20 |
21 | - integer and real-number arithmetic based on BGV, BFV, and CKKS schemes
22 |
23 | ## Warning
24 |
25 | Although the OpenFHE team has provided various utility functions to make OpenFHE accessible to
26 | non-cryptographers, it is still necessary for the end-users to carefully consider how they are using the code. Improper
27 | use can result in leaked information.
28 | Use of OpenFHE in production environments should be reviewed by homomorphic encryption experts.
29 |
30 | Additionally, see our [Security Considerations](../docs/static_docs/Security.md) for considerations that should be taken into account
31 | in your work.
32 |
--------------------------------------------------------------------------------
/src/core/include/utils/blockAllocator/README.md:
--------------------------------------------------------------------------------
1 | # Block Allocator
2 |
3 | ## Motivation
4 |
5 | We create stl-compatible custom block allocators for various types which allows for fast allocation and free-ing.
6 |
7 | **Note**: the `xY.h` is such that the `x` describes that we are using the custom allocator class, and the `Y` describes the underlying type e.g: `list` or `map`, etc.
8 |
9 | ## References
10 |
11 | For more context, read:
12 |
13 | 1) [An Efficient C++ Fixed Block Memory Allocator]( http://www.codeproject.com/Articles/1083210/An-efficient-Cplusplus-fixed-block-memory-allocato)
14 |
15 | TL;DR global heap allocation can be slow and nondeterministic. Also, this eliminates the possibility of memory allocation fault caused by a fragmented heap.
16 |
17 | 2) [Replace malloc/free with a Fast Fixed Block Memory Allocator](https://www.codeproject.com/Articles/1084801/Replace-malloc-free-with-a-fast-fixed-block-memory)
18 |
19 | TL;DR replaces `malloc` and `free` with `xmalloc` and `xfree` which take advantage of the `Allocator` from above
20 |
21 | 3) [A Custom STL std::allocator Replacement Improves Performance](https://www.codeproject.com/Articles/1089905/A-Custom-STL-std-allocator-Replacement-Improves-Pe)
22 |
23 | TL;DR describes how to create a STL-compatible version of the above code.
--------------------------------------------------------------------------------
/scripts/setup/linux_platform_packages.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # This script can be used to install all of the requistes for the Linux Platform
4 | #
5 |
6 | # run update before installing every package
7 |
8 | # install cmake
9 | sudo apt-get update
10 | sudo apt-get install -y cmake
11 |
12 | # install required packages
13 | sudo apt-get update
14 | sudo apt-get install -y build-essential
15 | sudo apt-get update
16 | sudo apt-get install -y autoconf
17 | sudo apt-get update
18 | sudo apt-get install -y libtool
19 | sudo apt-get update
20 | sudo apt-get install -y libgmp-dev
21 | sudo apt-get update
22 | sudo apt-get install -y libntl-dev
23 |
24 | # install all necessary and additional compilers
25 | sudo apt-get update
26 | sudo apt-get install -y g++-9 g++-10 g++-11 g++-12
27 | sudo apt-get update
28 | sudo apt-get install -y clang-12 clang-13 clang-14 clang-15
29 |
30 | # for documentation
31 | sudo apt-get update
32 | sudo apt-get install -y doxygen
33 | sudo apt-get update
34 | sudo apt-get install -y graphviz
35 |
36 | # python packages
37 | sudo apt-get update
38 | sudo apt-get install -y python3-pip
39 | sudo apt-get update
40 | sudo pip install pybind11[global]
41 | sudo apt-get update
42 | sudo apt-get install -y python3-pytest
43 | # to verify pytest installation: python3 -m pip show pytest
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory
2 | *~
3 | *.o
4 | *.o.d
5 | *.gcov
6 | bin/
7 | build*/
8 | cmake-build-debug
9 | docs/doxygen
10 | docs/sphinx
11 | _build/
12 | embuild
13 | api/
14 | doxyoutput/
15 |
16 |
17 | .ipynb_checkpoints
18 |
19 | test/build
20 | test/bin
21 | output.txt
22 | Doxyfile
23 | apidoc_warning_logfile.txt
24 | third-party/distros/gmp-6.1.1
25 | third-party/distros/gmp-6.1.2
26 | third-party/distros/ntl-10.3.0
27 | third-party/distros/ntl-10.5.0
28 | third-party/include/NTL
29 | third-party/include/gmp.h
30 | third-party/lib
31 | third-party/share
32 | **/gmp-*
33 | **/ntl-*
34 | timing/
35 | gmon.out
36 | ## .gitattributes
37 | # Except this file
38 | !.gitignore
39 |
40 | .idea
41 | */**/*.gch
42 | *.a
43 | *.class
44 |
45 | ## for the moment
46 | .cproject
47 | .metadata/
48 | .project
49 | .settings/
50 | RemoteSystemTempFiles/
51 | .classpath
52 | .externalToolBuilders/
53 | /Default/
54 |
55 | .DS_Store
56 |
57 | # Ignore intellij project files/cmake files
58 | # CMakeLists.txt
59 | .idea/
60 |
61 | src/circuit/lib/scan.cpp
62 | src/circuit/lib/parse.cpp
63 | src/circuit/lib/parse.hpp
64 | src/circuit/lib/*.hh
65 |
66 | # vagrant output
67 | .vagrant/
68 | *.log
69 |
70 | # gtest output files
71 | test_detail.xml
72 |
73 | # Visual Studio Code
74 | .vscode
75 |
--------------------------------------------------------------------------------
/.clang-format:
--------------------------------------------------------------------------------
1 | # https://clang.llvm.org/docs/ClangFormatStyleOptions.html
2 | # Manual run to reformat a file "foo.cpp": clang-format -i --style=file foo.cpp
3 | #######################################################################
4 | BasedOnStyle: Google
5 | #######################################################################
6 | Language: Cpp
7 | # DisableFormat: true
8 | AccessModifierOffset: -4
9 | # AlignArrayOfStructures: Right (enable this if clang-format-13 or newer is installed)
10 | AlignConsecutiveMacros: true
11 | AlignConsecutiveAssignments: true
12 | #AlignConsecutiveDeclarations: true
13 | AlignEscapedNewlines: Left
14 | AlignOperands: true
15 | AllowShortFunctionsOnASingleLine: Empty
16 | AllowShortIfStatementsOnASingleLine: Never
17 | AllowShortLambdasOnASingleLine: Inline
18 | AllowShortLoopsOnASingleLine: false
19 | BreakBeforeBraces: Custom
20 | BraceWrapping:
21 | BeforeCatch: true
22 | BeforeElse: true
23 | BreakBeforeTernaryOperators: false
24 | BreakStringLiterals: false
25 | ColumnLimit: 120
26 | DerivePointerAlignment: false
27 | #EmptyLineBeforeAccessModifier: true (enable this if clang-format-13 or newer is installed)
28 | IndentPPDirectives: BeforeHash
29 | IndentWidth: 4
30 | PointerAlignment: Left
31 | ReflowComments: false
32 | SortIncludes: false
33 | UseTab: Never
34 |
--------------------------------------------------------------------------------
/src/pke/include/key/README.md:
--------------------------------------------------------------------------------
1 | # Keys
2 |
3 | This folder contains the header files of the various keys that are defined within `Open-FHE`. Refer to [OpenFHE PKE Keys](https://openfhe-development.readthedocs.io/en/latest/assets/sphinx_rsts/modules/pke/pke_keys.html)
4 |
5 | ## Key Class Inheritance
6 | ```mermaid
7 | graph TD
8 | Key[Key: Base Class] --> |Inherits|EvalKeyImpl
9 | EvalKeyImpl --> |Inherits|EvalKeyRelinImpl
10 | ```
11 |
12 | ## KeyPair
13 |
14 | ```mermaid
15 | graph TD
16 | PrivKey[Private Key] --> |container|KP[Key Pair]
17 | PubKey[Public Key] --> |container|KP[Key Pair]
18 | ```
19 |
20 | [All Key](allkey.h)
21 | - Top-level `#include` for access to all capabilities
22 |
23 | [Eval Key](evalkey.h)
24 | - Inherits from the base [Key](key.h) class.
25 | - Serves as base class for [Eval Key Relin](evalkeyrelin.h)
26 |
27 | [Eval Key Relin](evalkeyrelin.h)
28 | - Get and set relinearization elements
29 | - Inherits from [Eval Key](evalkey.h)
30 |
31 | [Key](key.h)
32 | - Base Key class
33 |
34 |
35 | [Key Serialization](key-ser.h)
36 | - Capabilities for serializing the keys using [Cereal](https://github.com/USCiLab/cereal)
37 |
38 | [Key Pair](keypair.h)
39 | - Container for the [private key](privatekey.h) and [public key](publickey.h)
40 |
41 | [Private Key](privatekey.h)
42 |
43 |
44 | [Public Key](publickey.h)
45 |
--------------------------------------------------------------------------------
/src/core/include/README.md:
--------------------------------------------------------------------------------
1 | # Core Library Implementation
2 |
3 | ```mermaid
4 | flowchart BT
5 | A[Math
- Provides base math operations - Supports various math backends] --> B[Lattice
- Represent polynomial rings - support operations over polynomial rings. - calls math layer for lower-level math ops];
6 | B[Lattice
- Represent polynomial rings - support operations over polynomial rings. - calls math layer for lower-level math ops] --> C[Core Layer];
7 | ```
8 |
9 | Contains the underlying primitives that are used in both `pke` and `binfhe`.
10 |
11 | ## [Lattice](lattice)
12 |
13 | - Contains files that support lattice/polynomial-layer operations in OpenFHE. This layer is used to represent polynomial rings and support operations over those rings.
14 |
15 | - As can be seen above, this is the "middle" layer between higher-level lattice cryptography elements, and the lower level math operations.
16 |
17 |
18 | ## [Math](math)
19 |
20 | Contains various files describing the mathematical functionality supported in OpenFHE. For example:
21 |
22 | - modular arithmeric
23 | - sampling functions
24 |
25 | In addition, the hardware abstraction layer (HAL) is defined here.
26 |
27 |
28 | ## [Utils](utils)
29 |
30 | Contains various utilities:
31 |
32 | - debugging utilities
33 | - memory management utilities
34 | - parallel operations
35 | - serialization
36 |
--------------------------------------------------------------------------------
/docs/sphinx_rsts/intro/directory_structure.rst:
--------------------------------------------------------------------------------
1 | Directory Structure
2 | ====================================
3 |
4 | The high-level structure of the OpenFHE library is as follows.
5 |
6 | Several of these directories may contain a README file with more specific information about the files in the directory.
7 |
8 | ::
9 |
10 | .
11 | ├── benchmark
12 | ├── build
13 | ├── doc
14 | ├── src
15 | ├────── binfhe
16 | ├────── core
17 | ├────── pke
18 | ├── test
19 | └── third-party
20 |
21 | The descriptions of library components are as follows:
22 |
23 | .. csv-table:: components
24 | :header: "Directory", "Description"
25 |
26 | "benchmark","Code for benchmarking OpenFHE library components, using the Google Benchmark frameworks"
27 | "build","Binaries and build scripts (this folder is created by the user)"
28 | "doc","Documentation of library components."
29 | "docker","Docker file and documentation."
30 | "src","Library source code. Each subcomponent has four or five subdirectories: include (for library header files), lib (for library source files), unittest (for google test cases), examples (for code samples), and optionally extras (for additional code samples)."
31 | "third-party","Code for distributions from third parties (includes NTL/GMP + git submodules for tcmalloc, cereal, google test, and google benchmark)"
32 | "test","Google unit test code"
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 2-Clause License
2 |
3 | Copyright (c) 2022, OpenFHE
4 |
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are met:
9 |
10 | 1. Redistributions of source code must retain the above copyright notice, this
11 | list of conditions and the following disclaimer.
12 |
13 | 2. Redistributions in binary form must reproduce the above copyright notice,
14 | this list of conditions and the following disclaimer in the documentation
15 | and/or other materials provided with the distribution.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
--------------------------------------------------------------------------------
/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:20.04
2 |
3 | ARG repository="openfhe-development"
4 | ARG branch=main
5 | ARG tag=v0.9.1
6 | ARG CC_param=/usr/bin/gcc-10
7 | ARG CXX_param=/usr/bin/g++-10
8 | ARG no_threads=1
9 |
10 | ENV DEBIAN_FRONTEND=noninteractive
11 | ENV CC $CC_param
12 | ENV CXX $CXX_param
13 |
14 | #install pre-requisites for OpenFHE
15 | RUN apt update && apt install -y git \
16 | build-essential \
17 | gcc-10 \
18 | g++-10 \
19 | cmake \
20 | autoconf \
21 | clang-10 \
22 | libomp5 \
23 | libomp-dev \
24 | doxygen \
25 | graphviz \
26 | libboost-all-dev=1.71.0.0ubuntu2
27 |
28 | RUN apt-get clean && rm -rf /var/lib/apt/lists/*
29 |
30 | #git clone the openfhe-development repository and its submodules (this always clones the most latest commit)
31 | RUN git clone https://github.com/openfheorg/$repository.git && cd $repository && git checkout $branch && git checkout $tag && git submodule sync --recursive && git submodule update --init --recursive
32 |
33 | #installing OpenFHE and running tests
34 | RUN mkdir /$repository/build && cd /$repository/build && cmake .. && make -j $no_threads && make install && make testall
35 |
--------------------------------------------------------------------------------
/docs/sphinx_rsts/misc/license.rst:
--------------------------------------------------------------------------------
1 | OpenFHE License
2 | ================
3 |
4 | BSD 2-Clause License
5 |
6 | Copyright (c) 2022, OpenFHE
7 |
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without
11 | modification, are permitted provided that the following conditions are met:
12 |
13 | 1. Redistributions of source code must retain the above copyright notice, this
14 | list of conditions and the following disclaimer.
15 |
16 | 2. Redistributions in binary form must reproduce the above copyright notice,
17 | this list of conditions and the following disclaimer in the documentation
18 | and/or other materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/.github/workflows/pull-request.yml:
--------------------------------------------------------------------------------
1 | name: Pull-Request
2 |
3 | on:
4 | pull_request:
5 | branches:
6 | - main
7 | - dev
8 |
9 | jobs:
10 | call:
11 | uses: openfheorg/openfhe-development/.github/workflows/generic_workflow.yml@github-ci
12 | with:
13 | runner: ${{ vars.RUNNER }}
14 | compiler: "GCC-14"
15 | native_backend: "all"
16 | mb2_jobs: "mb2"
17 | mb4_jobs: "mb4_tcm"
18 | mb6_jobs: "mb6"
19 | # cmake_args_map holds job specific additional cmake options. compiler flags, native_backend flag and
20 | # OpenMP flag are set in generic_workflow.yml
21 | cmake_args_map: '{
22 | "default" : "-DBUILD_EXTRAS=ON",
23 | "mb2" : "-DBUILD_EXTRAS=ON -DMATHBACKEND=2",
24 | "mb2_tcm" : "-DBUILD_EXTRAS=ON -DMATHBACKEND=2 -DWITH_TCM=ON",
25 | "mb2_debug" : "-DBUILD_EXTRAS=ON -DMATHBACKEND=2 -DCMAKE_BUILD_TYPE=Debug",
26 | "mb4" : "-DBUILD_EXTRAS=ON -DMATHBACKEND=4",
27 | "mb4_tcm" : "-DBUILD_EXTRAS=ON -DMATHBACKEND=4 -DWITH_TCM=ON",
28 | "mb4_debug" : "-DBUILD_EXTRAS=ON -DMATHBACKEND=4 -DCMAKE_BUILD_TYPE=Debug",
29 | "mb6_ntl" : "-DBUILD_EXTRAS=ON -DMATHBACKEND=6 -DWITH_NTL=ON",
30 | "mb6_ntl_tcm" : "-DBUILD_EXTRAS=ON -DMATHBACKEND=6 -DWITH_NTL=ON -DWITH_TCM=ON",
31 | "mb6_ntl_debug_tcm" : "-DBUILD_EXTRAS=ON -DMATHBACKEND=6 -DWITH_NTL=ON -DWITH_TCM=ON -DCMAKE_BUILD_TYPE=Debug",
32 | }'
33 |
--------------------------------------------------------------------------------
/docs/sphinx_rsts/intro/exceptions_in_openfhe.rst:
--------------------------------------------------------------------------------
1 | Throwing Exceptions in OpenFHE
2 | ===============================
3 |
4 | The OpenFHE library will throw an OpenFHEException exception in the event of an unrecoverable error. A openfhe_error is a subclass of ``std::exception``.
5 |
6 |
7 | Programmers use the OPENFHE_THROW macro in exception.h to generate an exception. Each exception includes the filename, the function name and line number at which the exception was thrown as well as a programmer-defined message.
8 |
9 |
10 | OpenFHEException is defined in ``src/core/include/utils/exception.h``.
11 |
12 |
13 | Exceptions in critical regions and OMP threads
14 | -----------------------------------------------
15 |
16 | An exception that is thrown in a critical region, or that is thrown within an OMP thread, must be caught in the same region where it is thrown. The program will abort if this is not done.
17 |
18 | If an exception must be thrown in a critical region or OMP thread, but must be caught in another thread, then it is necessary to catch the exception and re-throw it. Classes and sample code is provided in ``src/core/include/utils/exception.h`` to show how this is done.
19 |
20 | For example, the following code will catch and rethrow an exception thrown inside of a thread
21 |
22 | .. code-block:: c++
23 | :linenos:
24 |
25 | ThreadException e;
26 | #pragma omp parallel for
27 | for(unsigned i=0; i`_
5 |
6 | .. contents:: Page Contents
7 | :local:
8 | :backlinks: none
9 |
10 | Motivation
11 | ----------
12 |
13 | We create stl-compatible custom block allocators for various types which allows for fast allocation and free-ing.
14 |
15 | .. note:: ``xY.h`` is such that the ``x`` describes that we are using the custom allocator class, and the ``Y`` describes the underlying type e.g: ``list`` or ``map``, etc.
16 |
17 | References
18 | -------------
19 |
20 | For more context, read:
21 |
22 | 1) `An Efficient C++ Fixed Block Memory Allocator `_
23 |
24 | TL;DR global heap allocation can be slow and nondeterministic. Also, this eliminates the possibility of memory allocation fault caused by a fragmented heap.
25 |
26 | 2) `Replace malloc/free with a Fast Fixed Block Memory Allocator `_
27 |
28 | TL;DR replaces `malloc` and `free` with `xmalloc` and `xfree` which take advantage of the `Allocator` from above
29 |
30 | 3) `A Custom STL std::allocator Replacement Improves Performance `_
31 |
32 | TL;DR describes how to create a STL-compatible version of the above code.
33 |
--------------------------------------------------------------------------------
/docs/sphinx_rsts/modules/core/lattice/hal.rst:
--------------------------------------------------------------------------------
1 | .. _hal:
2 |
3 | Core Lattice Hardware Abstraction Layer Documentation
4 | ======================================================
5 |
6 |
7 | .. contents:: Page Contents
8 | :local:
9 | :backlinks: none
10 |
11 | Lattice HAL Introduction
12 | ----------------------------
13 |
14 | .. mermaid::
15 |
16 | graph BT
17 | a[DCRTPolyInterface] --> |Inherited by|b[DCRTPoly - HAL Default];
18 |
19 | This hardware abstraction layer allows OpenFHE to use a variety of hardware-integrated backends while still allowing for high performance. As of March 31st 2022, we have the:
20 |
21 | - default backend
22 |
23 | - `Intel Hexl `_ backend
24 |
25 | .. note:: Follow the convention set by the the `OpenFHE HEXL code `_ to extend the supported backends.
26 |
27 | File Listing
28 | ---------------
29 |
30 | `DCRTPolyInterface (dcrtpoly-interface.h) `_
31 |
32 | - Base class for ``DCRTPoly``
33 |
34 | `DCRTPoly Interface Aliases (lat-backend-default.h) `_
35 |
36 | - Defines aliases for the lattice default backend
37 |
38 | `Integer Lattice Double CRT Params (ildcrtparams.h) `_
39 |
40 | - Inherits from ``DCRTPolyInterface`` and provides a public-facing interface used downstream by the various schemes.
41 |
--------------------------------------------------------------------------------
/docs/static_docs/Webinars.md:
--------------------------------------------------------------------------------
1 | OpenFHE Webinars
2 | =================
3 |
4 | The OpenFHE library has a YouTube channel! Full of rich detailed content on repository, examples, and general homomorphic encryption! Please visit [OpenFHE/PALISADE Homomorphic Encryption Library](https://www.youtube.com/channel/UC1qByOsQina1rpZ8AGl5TZw) and subscribe for the latest videos!
5 |
6 | Webinar List
7 | ------------
8 |
9 | - [OpenFHE/PALISADE Webinar #1 - Introducing OpenFHE/PALISADE](https://youtu.be/FLGeMd3eiQY)
10 | - [OpenFHE/PALISADE Webinar #2 A - HE Tutorial Series Part 1: Introduction to Homomorphic Encryption](https://youtu.be/rMDoZdH53ZM)
11 | - [OpenFHE/PALISADE Webinar #2 B - HE Tutorial Series Part 2: Boolean Arithmetic with Applications](https://youtu.be/aKcf5vd8lLs)
12 | - [OpenFHE/PALISADE Webinar #3 A - HE Tutorial Series Part 3: Integer Arithmetic](https://youtu.be/1a7yxnLj4PE)
13 | - [OpenFHE/PALISADE Webinar #3 B - HE Tutorial Series Part 4: Integer Applications](https://youtu.be/7Rpeb1YNSRs)
14 | - [OpenFHE/PALISADE Webinar #4 - HE Tutorial Series Part 5: Introduction to Multiparty Homomorphic Encryption](https://youtu.be/9Fa6rFUyQ_w)
15 | - [OpenFHE/PALISADE Webinar #5 - HE Serialization for Applications](https://youtu.be/-2zaJ2C4Guo)
16 | - [OpenFHE/PALISADE Webinar #6 - HE Tutorial Series Part 6: Introduction to Approximate Homomorphic Encryption](https://youtu.be/_s1B128sqaI)
17 | - [OpenFHE/PALISADE Webinar #7 A - Secure Large-Scale Genome-Wide Association Studies using Homomorphic Encryption](https://youtu.be/rTmL1Iaoslo)
18 | - [OpenFHE/PALISADE Webinar #7 B - Best Practices for Building Efficient Homomorphic Encryption Solutions](https://youtu.be/oxJGOhqLd-E)
19 |
--------------------------------------------------------------------------------
/benchmark/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include_directories( ../src/core/include )
2 | include_directories( ../src/core/lib )
3 | include_directories( ../src/pke/include )
4 | include_directories( ../src/binfhe/include )
5 |
6 | set( REGEX_FLAG -DHAVE_STD_REGEX )
7 |
8 | if ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
9 | set( WARNING_FLAG "" )
10 | else()
11 | set( WARNING_FLAG -Wno-unused-but-set-variable )
12 | endif()
13 |
14 | if( BUILD_SHARED )
15 | set (BMLIBS PUBLIC OPENFHEpke PUBLIC OPENFHEbinfhe PUBLIC OPENFHEcore ${THIRDPARTYLIBS} PUBLIC benchmark ${OpenMP_CXX_FLAGS})
16 | endif()
17 |
18 | if( BUILD_STATIC )
19 | set (BMLIBS ${BMLIBS} PUBLIC OPENFHEpke_static PUBLIC OPENFHEbinfhe_static PUBLIC OPENFHEcore_static ${THIRDPARTYSTATICLIBS} PUBLIC benchmark ${OpenMP_CXX_FLAGS})
20 | endif()
21 |
22 | set (BMAPPS "")
23 | file (GLOB BMARK_SRC_FILES CONFIGURE_DEPENDS src/*.cpp)
24 | foreach (app ${BMARK_SRC_FILES})
25 | get_filename_component ( exe ${app} NAME_WE )
26 | add_executable ( ${exe} ${app} )
27 | set_property(TARGET ${exe} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/benchmark)
28 | target_include_directories( ${exe} PUBLIC ../third-party/google-benchmark/include )
29 | set_target_properties( ${exe} PROPERTIES COMPILE_FLAGS
30 | "${REGEX_FLAG} -DHAVE_STEADY_CLOCK -DNDEBUG ${WARNING_FLAG}" )
31 | target_link_libraries ( ${exe} ${BMLIBS} ${ADDITIONAL_LIBS})
32 | set (BMAPPS ${BMAPPS} ${exe})
33 | endforeach()
34 |
35 | add_custom_target( allbenchmark )
36 | add_dependencies( allbenchmark ${BMAPPS} )
37 |
38 | add_custom_command( OUTPUT benchmarkinfocmd COMMAND echo Builds benchmark lib and these apps: ${BMAPPS} )
39 | add_custom_target( benchmarkinfo DEPENDS benchmarkinfocmd )
40 |
--------------------------------------------------------------------------------
/src/pke/examples/INTERACTIVE_BOOTSTRAPPING.md:
--------------------------------------------------------------------------------
1 | OpenFHE Library - Interactive Bootstrapping
2 | =====================================================================================================
3 |
4 | OpenFHE provides two methods for interactive CKKS bootstrapping:
5 | * The $n$-party method described in Appendix E of https://eprint.iacr.org/2023/1203. This method is an optimized version of the method originally proposed in https://eprint.iacr.org/2020/304 and https://arxiv.org/abs/2009.00349.
6 | * The 2-party method proposed in Appendix D of https://eprint.iacr.org/2023/1203, which is based on the idea of distributed rounding.
7 |
8 | The 2-party method is more efficient than the $n$-party method for the case when $n=2$. It requires only one extra RNS limb in contrast to 2-3 extra RNS limbs for the $n$-party bootstrapping for the FIXED* modes, and an exra RNS limb for both methods for the FLEXIBLE* modes of CKKS. Moreover, the computational and communication complexity of the $2$-party interactive bootstrapping is smaller than for the $n$-party method.
9 |
10 | ## Examples for the $2$-party interactive bootstrapping
11 |
12 | - [interactive-bootstrapping.cpp](interactive-bootstrapping.cpp) shows two examples of $2$-party interactive bootstrapping: interactive bootstrapping without a computation and interactive bootstrapping together with a Chebyshev interpolation
13 |
14 | ## Examples for the $n$-party interactive bootstrapping
15 |
16 | - [tckks-interactive-mp-bootstrapping.cpp](tckks-interactive-mp-bootstrapping.cpp): An example of $n$-party interactive bootstrapping by itself
17 | - [tckks-interactive-mp-bootstrapping-Chebyshev.cpp](tckks-interactive-mp-bootstrapping-Chebyshev.cpp): An example of $n$-party interactive bootstrapping together with Chebyshev interpolation
18 |
--------------------------------------------------------------------------------
/src/pke/include/encoding/README.md:
--------------------------------------------------------------------------------
1 | # Encodings
2 |
3 | This folder contains the header files of the various encoding formats. Broadly speaking, an encoding is the intermediate transformation between a plaintext and a ciphertext.
4 |
5 | ```mermaid
6 | flowchart BT
7 | A[Input Plaintext] --> |"1) Encode"| B(Encoded Plaintext);
8 | B(Encoded Plaintext) --> |"2) Encrypt"| C(Ciphertext);
9 | C(Ciphertext) --> |"3) Decrypt"| B(Encoded Plaintext);
10 | B(Encoded Plaintext) --> |"4) SetLength"| D(Homomorphically Transformed Plaintext);
11 | ```
12 |
13 | We provide a brief overview of the files below. However, we recommend referring to our [ReadTheDocs - PKE/Encoding Headers](https://openfhe-development.readthedocs.io/en/latest/assets/sphinx_rsts/modules/pke/pke_encoding.html) for more in-depth information.
14 |
15 | [CKKS Packed Encoding](ckkspackedencoding.h)
16 | - Describes the CKKS packing. Accepts a `std::vector` unlike the other schemes.
17 |
18 | [Coef Packed Encoding](coefpackedencoding.h)
19 | - Accepts plaintext data and packs the data into coefficients of a polynomial.
20 | - Note: is rarely used
21 | - Note: only supports element-wise addition, so ensure that you need this before using
22 |
23 | [Encoding Params](encodingparams.h)
24 | - The object containing the parameters for encoding. These parameters are kept and continually reused (can be modified) during the encoding of new values
25 |
26 | [Encodings](encodings.h)
27 | - "import" file which can be used for a single `#include`
28 |
29 | [Packed Encoding](packedencoding.h)
30 | - Packs integers into a vector
31 | - Note: is almost always what you want to use (other than if you want to deal with floating numbers)
32 |
33 | [Plaintext](plaintext.h)
34 | - The base plaintext implementation
35 |
36 | [Plaintext Factory](plaintextfactory.h)
37 | - Factory class that instantiates plaintexts
38 |
39 | [String Encoding](stringencoding.h)
40 | - Encodes strings
--------------------------------------------------------------------------------
/src/core/include/lattice/lat-hal.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2023, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | #ifndef LBCRYPTO_INC_LATTICE_LAT_HAL_H
33 | #define LBCRYPTO_INC_LATTICE_LAT_HAL_H
34 |
35 | #include "lattice/hal/lat-backend.h"
36 |
37 | #endif // __LAT_HAL_H__
38 |
--------------------------------------------------------------------------------
/src/core/include/utils/demangle.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #ifndef __DEMANGLE_H__
32 | #define __DEMANGLE_H__
33 |
34 | #include
35 |
36 | std::string demangle(const char* name) noexcept;
37 |
38 | #endif // __DEMANGLE_H__
39 |
--------------------------------------------------------------------------------
/src/pke/lib/schemebase/base-fhe.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | #include "cryptocontext.h"
33 | #include "schemebase/base-fhe.h"
34 |
35 | namespace lbcrypto {
36 |
37 | template class FHEBase;
38 |
39 | } // namespace lbcrypto
40 |
--------------------------------------------------------------------------------
/src/pke/lib/key/evalkey.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #include "cryptocontext.h"
32 | #include "key/evalkey.h"
33 |
34 | // the code below is from evalkey-impl.cpp
35 | namespace lbcrypto {
36 | template class EvalKeyImpl;
37 | } // namespace lbcrypto
38 |
--------------------------------------------------------------------------------
/src/pke/lib/key/publickey.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #include "cryptocontext.h"
32 | #include "key/publickey.h"
33 |
34 | // the code below is from publickey-impl.cpp
35 | namespace lbcrypto {
36 | template class PublicKeyImpl;
37 | } // namespace lbcrypto
38 |
--------------------------------------------------------------------------------
/src/pke/lib/key/privatekey.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #include "cryptocontext.h"
32 | #include "key/privatekey.h"
33 |
34 | // the code below is from privatekey-impl.cpp
35 | namespace lbcrypto {
36 | template class PrivateKeyImpl;
37 | } // namespace lbcrypto
38 |
--------------------------------------------------------------------------------
/src/core/lib/utils/parallel.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | /*
33 | This file contains the functionality for parallel operation
34 | */
35 |
36 | #include "utils/parallel.h"
37 |
38 | namespace lbcrypto {
39 |
40 | ParallelControls OpenFHEParallelControls;
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/pke/lib/key/evalkeyrelin.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #include "cryptocontext.h"
32 | #include "key/evalkeyrelin.h"
33 |
34 | // the code below is from evalkeyrelin-impl.cpp
35 | namespace lbcrypto {
36 | template class EvalKeyRelinImpl;
37 | } // namespace lbcrypto
38 |
--------------------------------------------------------------------------------
/docs/static_docs/Security.md:
--------------------------------------------------------------------------------
1 | # General Notes on Homomorphic Encryption
2 |
3 | All homomorphic encryption schemes implemented in OpenFHE are IND-CPA secure, and hence are expected to be used under the honest-but-curios (a.k.a., semi-honest) model. In this model, the adversary cannot corrupt/tamper with ciphertexts (and perform related active attacks) but can only use the API of OpenFHE to perform valid operations.
4 |
5 | # Notes specific to the CKKS scheme
6 |
7 | Li and Micciancio recently showed that the IND-CPA model may not be sufficient for the CKKS scheme in some scenarios because a decryption result can be used to perform a key recovery attack. This attack applies to the setting where decryption results need to be shared between multiple parties, e.g., in the the threshold FHE setting. To mitigate the Li-Micciancio attack, we extended the original CKKS (starting with v1.10.6) to a stronger adversarial model where decryption results may still be shared between multiple parties. By default, OpenFHE chooses a configuration where a relatively large number of decryption queries of the same or related ciphertexts can be tolerated. The lower bound for the tolerated number of such decryption queries is N_d = 128 (but in practical computations, N_d is at least 10,000). We consider this default setting sufficient to prevent passive attacks (where a normal homomorphic encryption computation protocol is followed).
8 |
9 | In scenarios where an even stronger adversarial model is needed (uncommon scenarios), the user can increase the number of shared decryptions of the same or related ciphertexts to a higher number by increasing the `CKKS_M_FACTOR` CMake parameter (a compile-level flag). The minimum number of decryption results in this case becomes N_d x (`CKKS_M_FACTOR` + 1) / 2. Please note that increasing `CKKS_M_FACTOR` from the default value of 1 will decrease the precision of CKKS ciphertexts by 0.5 x (log2(`CKKS_M_FACTOR` + 1) - 1) bits. Hence increasing `CKKS_M_FACTOR` is only suggested when a stronger adversarial model is needed.
--------------------------------------------------------------------------------
/src/core/include/utils/blockAllocator/xlist.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | #ifndef _XLIST_H
33 | #define _XLIST_H
34 |
35 | #include
36 | #include "stl_allocator.h"
37 |
38 | template >
39 | class xlist : public std::list<_Ty, _Ax> {};
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/src/pke/lib/encoding/encodingparams.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | /*
33 | Represents and defines parameters for plaintext encoding
34 | */
35 |
36 | #include "encoding/encodingparams.h"
37 |
38 | CEREAL_CLASS_VERSION(lbcrypto::EncodingParamsImpl, lbcrypto::EncodingParamsImpl::SerializedVersion());
39 |
--------------------------------------------------------------------------------
/src/core/lib/utils/openfhebase64.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | /*
33 | OpenFHE native base 64 utlities
34 | */
35 |
36 | #include "utils/openfhebase64.h"
37 |
38 | namespace lbcrypto {
39 |
40 | const char to_base64_char[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
41 |
42 | } /* namespace lbcrypto */
43 |
--------------------------------------------------------------------------------
/src/pke/lib/schemebase/base-parametergeneration.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #include "cryptocontext.h"
32 | #include "schemebase/base-parametergeneration.h"
33 |
34 | // the code below is from base-parametergeneration-impl.cpp
35 | namespace lbcrypto {
36 | template class ParameterGenerationBase;
37 | } // namespace lbcrypto
38 |
--------------------------------------------------------------------------------
/src/pke/include/keyswitch/README.md:
--------------------------------------------------------------------------------
1 | # Key Switching
2 |
3 | This folder contains the header files of the various key-switchung capabilities that are defined within `Open-FHE`.
4 | Refer
5 | to [OpenFHE PKE Keys](https://openfhe-development.readthedocs.io/en/latest/assets/sphinx_rsts/modules/pke/pke_keyswitch.html)
6 |
7 | The documentation here is based off
8 | of [Revisiting Homomorphic Encryption Schemes for Finite Fields](https://eprint.iacr.org/2021/204.pdf)
9 |
10 | At a high level, key switching allows transforming a given ciphertext into another ciphertext that can be decrypted with
11 | a separate secret key. This is necessary for computing automorphisms and for relinearizing ciphertexts.
12 |
13 | ## Key Class Inheritance
14 |
15 | ```mermaid
16 | graph BT
17 | Key[Keyswitch: Base Class] --> |Inherited by|KeyRNS[Keyswitch: RNS];
18 | KeyRNS[Keyswitch: RNS] --> |Inherited by|KeyBV[Keyswitch: BV];
19 | KeyRNS[Keyswitch: RNS] --> |Inherited by|KeyHybrid[Keyswitch: Hybrid];
20 | ```
21 |
22 | [Key-switch Base](keyswitch-base.h)
23 |
24 | - Base class for key switching algorithms.
25 |
26 | [Key-switch RNS](keyswitch-rns.h)
27 |
28 | - Abstract interface class for RNS variants of key switching algorithms
29 |
30 | [Key-switch BV](keyswitch-bv.h)
31 |
32 | - Inherits from [key-switch base](keyswitch-base.h)
33 | - Implements BV key switching method from [Fully Homomorphic Encryption from
34 | Ring-LWE and Security for Key Dependent Messages (BVScheme)](
35 | https://www.wisdom.weizmann.ac.il/~zvikab/localpapers/IdealHom.pdf
36 | )
37 | - See the Appendix of https://eprint.iacr.org/2021/204 for more detailed description.
38 | - Requires the computation of a quadratic number of NTTs.
39 |
40 | [Key-switch Hybrid](keyswitch-hybrid.h)
41 |
42 | - Inherits from [key-switch base](keyswitch-base.h)
43 | - Hybrid key switching method first introduced in https://eprint.iacr.org/2012/099.pdf
44 | - RNS version was introduced in https://eprint.iacr.org/2019/688.
45 | - See the Appendix of https://eprint.iacr.org/2021/204 for more detailed description.
46 |
--------------------------------------------------------------------------------
/src/core/lib/utils/memory.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2024, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #include "utils/memory.h"
32 |
33 | namespace lbcrypto {
34 |
35 | void secure_memset(volatile void* mem, uint8_t c, size_t len) {
36 | volatile uint8_t* ptr = (volatile uint8_t*)mem;
37 | for (size_t i = 0; i < len; ++i)
38 | *(ptr + i) = c;
39 | }
40 |
41 | } // namespace lbcrypto
42 |
--------------------------------------------------------------------------------
/src/core/include/utils/blockAllocator/xqueue.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | #ifndef _XQUEUE_H
33 | #define _XQUEUE_H
34 |
35 | #include
36 | #include
37 | #include "stl_allocator.h"
38 |
39 | template > >
40 | class xqueue : public std::queue<_Tp, _Sequence> {};
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/src/pke/include/metadata-ser.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | #ifndef LBCRYPTO_CRYPTO_METADATASER_H
33 | #define LBCRYPTO_CRYPTO_METADATASER_H
34 |
35 | #include "metadata.h"
36 | #include "utils/serial.h"
37 |
38 | CEREAL_CLASS_VERSION(lbcrypto::Metadata, lbcrypto::Metadata::SerializedVersion());
39 | CEREAL_REGISTER_TYPE(lbcrypto::Metadata);
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/src/pke/lib/schemebase/rlwe-cryptoparameters-impl.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | #include "cryptocontext.h"
33 | #include "schemebase/rlwe-cryptoparameters.h"
34 |
35 | namespace lbcrypto {
36 |
37 | // template class CryptoParametersRLWE;
38 | // template class CryptoParametersRLWE;
39 | template class CryptoParametersRLWE;
40 |
41 | } // namespace lbcrypto
42 |
--------------------------------------------------------------------------------
/src/core/include/utils/blockAllocator/xstring.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | #ifndef _XSTRING_H
33 | #define _XSTRING_H
34 |
35 | #include
36 | #include "stl_allocator.h"
37 |
38 | typedef std::basic_string, stl_allocator> xstring;
39 | typedef std::basic_string, stl_allocator> xwstring;
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/docs/sphinx_rsts/intro/security.rst:
--------------------------------------------------------------------------------
1 | Security Notes for Homomorphic Encryption
2 | ==================================================
3 |
4 | All homomorphic encryption schemes implemented in OpenFHE are IND-CPA secure, and hence are expected to be used under the honest-but-curios (a.k.a., semi-honest) model. In this model, the adversary cannot corrupt/tamper with ciphertexts (and perform related active attacks) but can only use the API of OpenFHE to perform valid operations.
5 |
6 | Notes specific to the CKKS scheme
7 | -----------------------------------
8 |
9 | Li and Micciancio recently showed that the IND-CPA model may not be sufficient for the CKKS scheme in some scenarios because a decryption result can be used to perform a key recovery attack. This attack applies to the setting where decryption results need to be shared between multiple parties, e.g., in the the threshold FHE setting. To mitigate the Li-Micciancio attack, we extended the original CKKS (starting with v1.10.6) to a stronger adversarial model where decryption results may still be shared between multiple parties. By default, OpenFHE chooses a configuration where a relatively large number of decryption queries of the same or related ciphertexts can be tolerated. The lower bound for the tolerated number of such decryption queries is N_d = 128 (but in practical computations, N_d is at least 10,000). We consider this default setting sufficient to prevent passive attacks (where a normal homomorphic encryption computation protocol is followed).
10 |
11 | In scenarios where an even stronger adversarial model is needed (uncommon scenarios), the user can increase the number of shared decryptions of the same or related ciphertexts to a higher number by increasing the `CKKS_M_FACTOR` CMake parameter (a compile-level flag). The minimum number of decryption results in this case becomes N_d x (`CKKS_M_FACTOR` + 1) / 2. Please note that increasing `CKKS_M_FACTOR` from the default value of 1 will decrease the precision of CKKS ciphertexts by 0.5 x (log2(`CKKS_M_FACTOR` + 1) - 1) bits. Hence increasing `CKKS_M_FACTOR` is only suggested when a stronger adversarial model is needed.
12 |
--------------------------------------------------------------------------------
/src/pke/unittest/utils/UnitTestMetadataTestSer.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #ifndef __UNITTESTMETADATATESTSER_H__
32 | #define __UNITTESTMETADATATESTSER_H__
33 |
34 | #include "UnitTestMetadataTest.h"
35 | #include "utils/serial.h"
36 |
37 | CEREAL_REGISTER_TYPE(lbcrypto::MetadataTest);
38 | CEREAL_REGISTER_POLYMORPHIC_RELATION(lbcrypto::Metadata, lbcrypto::MetadataTest);
39 |
40 | #endif // __UNITTESTMETADATATESTSER_H__
41 |
--------------------------------------------------------------------------------
/src/binfhe/include/lwe-keypair-fwd.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #ifndef __LWE_KEYPAIR_FWD_H__
32 | #define __LWE_KEYPAIR_FWD_H__
33 |
34 | #include
35 |
36 | namespace lbcrypto {
37 |
38 | class LWEKeyPairImpl;
39 |
40 | using LWEKeyPair = std::shared_ptr;
41 | using ConstLWEKeyPair = const std::shared_ptr;
42 |
43 | } // namespace lbcrypto
44 |
45 | #endif // __LWE_KEYPAIR_FWD_H__
46 |
--------------------------------------------------------------------------------
/docs/sphinx_rsts/intro/building_user_applications.rst:
--------------------------------------------------------------------------------
1 | Building User Applications
2 | ##########################
3 |
4 | How might you integrate OpenFHE into your projects?
5 |
6 |
7 | OpenFHE provides a sample CMake file for building your own C++ project that links to the OpenFHE library.
8 |
9 | The high-level instructions for building projects that use OpenFHE are as follows:
10 |
11 | 1. Build and install OpenFHE using "make install". This will copy the OpenFHE library files and header files to the directory chosen for installation.
12 |
13 | 2. Create the folder for your project on your system.
14 |
15 | 3. Copy CMakeLists.User.txt from the root directory of the git repo to the folder for your project.
16 |
17 | 4. Rename CMakeLists.User.txt to CMakeLists.txt.
18 |
19 | 5. Update CMakeLists.txt to specify the name of the executable and the source code files. For example, include the following line
20 |
21 | ::
22 |
23 | add_executable( fhe-demo simple-integers.cpp )
24 |
25 | 5. If using MinGW/Windows (skip this step for other platforms), copy PreLoad.cmake from the root directory of the git repo to the folder of your project.
26 |
27 | 6. Create the build directory and cd to it.
28 |
29 | ::
30 |
31 | mkdir build
32 | cd build
33 |
34 | 7. Run
35 |
36 | ::
37 |
38 | cmake ..
39 |
40 | If OpenFHE is installed in a different location than the default one or you have different versions of OpenFHE installed, then you should specify the path to the desired location by running cmake with an option::
41 |
42 | cmake .. -DCMAKE_PREFIX_PATH=/openfhe/location/path
43 |
44 | 8. Run "make" to build the executable.
45 |
46 | 9. In order to run the executable, add the absolute path to the location of the openfhe libraries to ``PATH``::
47 |
48 | export PATH=$PATH:/openfhe/location/path/lib
49 |
50 | To include a specific module, e.g., core or pke, in your C++ demo, use the main header file for that module, e.g., ``openfhecore.h`` or ``openfhe.h``. Please see the demos provided for that module for more examples. If your application uses serialization, additional header files will be needed (see the demos with serialization for more details).
51 |
--------------------------------------------------------------------------------
/src/pke/lib/schemebase/base-cryptoparameters.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #include "cryptocontext.h"
32 | #include "schemebase/base-cryptoparameters.h"
33 |
34 | // the code below is from base-cryptoparameters-impl.cpp
35 | namespace lbcrypto {
36 |
37 | // template class CryptoParametersBase;
38 | // template class CryptoParametersBase;
39 | template class CryptoParametersBase;
40 |
41 | } // namespace lbcrypto
42 |
--------------------------------------------------------------------------------
/src/binfhe/include/lwe-publickey-fwd.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #ifndef __LWE_PUBLICKEY_FWD_H__
32 | #define __LWE_PUBLICKEY_FWD_H__
33 |
34 | #include
35 |
36 | namespace lbcrypto {
37 |
38 | class LWEPublicKeyImpl;
39 |
40 | using LWEPublicKey = std::shared_ptr;
41 | using ConstLWEPublicKey = const std::shared_ptr;
42 |
43 | } // namespace lbcrypto
44 |
45 | #endif // __LWE_PUBLICKEY_FWD_H__
46 |
--------------------------------------------------------------------------------
/src/binfhe/include/lwe-ciphertext-fwd.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #ifndef __LWE_CIPHERTEXT_FWD_H__
32 | #define __LWE_CIPHERTEXT_FWD_H__
33 |
34 | #include
35 |
36 | namespace lbcrypto {
37 |
38 | class LWECiphertextImpl;
39 |
40 | using LWECiphertext = std::shared_ptr;
41 | using ConstLWECiphertext = const std::shared_ptr;
42 |
43 | } // namespace lbcrypto
44 |
45 | #endif // __LWE_CIPHERTEXT_FWD_H__
46 |
--------------------------------------------------------------------------------
/src/binfhe/include/lwe-privatekey-fwd.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #ifndef __LWE_PRIVATEKEY_FWD_H__
32 | #define __LWE_PRIVATEKEY_FWD_H__
33 |
34 | #include
35 |
36 | namespace lbcrypto {
37 |
38 | class LWEPrivateKeyImpl;
39 |
40 | using LWEPrivateKey = std::shared_ptr;
41 | using ConstLWEPrivateKey = const std::shared_ptr;
42 |
43 | } // namespace lbcrypto
44 |
45 | #endif // __LWE_PRIVATEKEY_FWD_H__
46 |
--------------------------------------------------------------------------------
/src/binfhe/include/lwe-keyswitchkey-fwd.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #ifndef __LWE_KEYSWITCHKEY_FWD_H__
32 | #define __LWE_KEYSWITCHKEY_FWD_H__
33 |
34 | #include
35 |
36 | namespace lbcrypto {
37 |
38 | class LWESwitchingKeyImpl;
39 |
40 | using LWESwitchingKey = std::shared_ptr;
41 | using ConstLWESwitchingKey = const std::shared_ptr;
42 |
43 | } // namespace lbcrypto
44 |
45 | #endif // __LWE_KEYSWITCHKEY_FWD_H__
46 |
--------------------------------------------------------------------------------
/src/core/include/openfhecore.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | /*
33 | OpenFHE version strings
34 | */
35 |
36 | #ifndef SRC_CORE_INCLUDE_OPENFHECORE_H_
37 | #define SRC_CORE_INCLUDE_OPENFHECORE_H_
38 |
39 | #include "lattice/lat-hal.h"
40 | #include "lattice/stdlatticeparms.h"
41 |
42 | #include "math/distrgen.h"
43 | #include "math/math-hal.h"
44 | #include "math/nbtheory.h"
45 |
46 | #include "utils/debug.h"
47 |
48 | #include "version.h"
49 |
50 | #endif /* SRC_CORE_INCLUDE_OPENFHECORE_H_ */
51 |
--------------------------------------------------------------------------------
/src/core/include/utils/get-call-stack.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2023, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #ifndef __GET_CALL_STACK_H__
32 | #define __GET_CALL_STACK_H__
33 |
34 | #include
35 | #include
36 |
37 | /**
38 | * @brief get_call_stack() is a function to get the call stack.
39 | * @attention it must not throw an exception as it is called from OpenFHEException
40 | * @return a vector with call stack (demangled function names)
41 | */
42 | std::vector get_call_stack() noexcept;
43 |
44 | #endif // __GET_CALL_STACK_H__
45 |
--------------------------------------------------------------------------------
/src/pke/include/key/evalkey-fwd.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | /*
32 | * It is a lightweight file to be included where we need the declaration of EvalKey only
33 | *
34 | */
35 | #ifndef __EVALKEY_FWD_H__
36 | #define __EVALKEY_FWD_H__
37 |
38 | #include
39 |
40 | namespace lbcrypto {
41 |
42 | template
43 | class EvalKeyImpl;
44 |
45 | template
46 | using EvalKey = std::shared_ptr>;
47 |
48 | } // namespace lbcrypto
49 |
50 | #endif // __EVALKEY_FWD_H__
51 |
--------------------------------------------------------------------------------
/src/pke/include/key/publickey-fwd.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | /*
32 | * It is a lightweight file to be included where we need the declaration of PublicKey only
33 | *
34 | */
35 | #ifndef __PUBLICKEY_FWD_H__
36 | #define __PUBLICKEY_FWD_H__
37 |
38 | #include
39 |
40 | namespace lbcrypto {
41 |
42 | template
43 | class PublicKeyImpl;
44 |
45 | template
46 | using PublicKey = std::shared_ptr>;
47 |
48 | } // namespace lbcrypto
49 |
50 | #endif // __PUBLICKEY_FWD_H__
51 |
--------------------------------------------------------------------------------
/src/core/include/utils/blockAllocator/xset.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | #ifndef _XSET_H
33 | #define _XSET_H
34 |
35 | #include
36 | #include
37 | #include "stl_allocator.h"
38 |
39 | template , class _Alloc = stl_allocator<_Kty> >
40 | class xset : public std::set<_Kty, _Pr, _Alloc> {};
41 |
42 | /// @see xset
43 | template , class _Alloc = stl_allocator<_Kty> >
44 | class xmultiset : public std::multiset<_Kty, _Pr, _Alloc> {};
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/src/pke/include/key/privatekey-fwd.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | /*
32 | * It is a lightweight file to be included where we need the declaration of PrivateKey only
33 | *
34 | */
35 | #ifndef __PRIVATEKEY_FWD_H__
36 | #define __PRIVATEKEY_FWD_H__
37 |
38 | #include
39 |
40 | namespace lbcrypto {
41 |
42 | template
43 | class PrivateKeyImpl;
44 |
45 | template
46 | using PrivateKey = std::shared_ptr>;
47 |
48 | } // namespace lbcrypto
49 |
50 | #endif // __PRIVATEKEY_FWD_H__
51 |
--------------------------------------------------------------------------------
/src/pke/include/encoding/encodings.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | /*
33 | all supported encodings of plaintext objects in OpenFHE
34 | */
35 |
36 | #ifndef SRC_CORE_LIB_ENCODING_ENCODINGS_H_
37 | #define SRC_CORE_LIB_ENCODING_ENCODINGS_H_
38 |
39 | #include "encoding/ckkspackedencoding.h"
40 | #include "encoding/coefpackedencoding.h"
41 | #include "encoding/encodingparams.h"
42 | #include "encoding/packedencoding.h"
43 | #include "encoding/plaintext.h"
44 | #include "encoding/stringencoding.h"
45 |
46 | #endif /* SRC_CORE_LIB_ENCODING_ENCODINGS_H_ */
47 |
--------------------------------------------------------------------------------
/src/pke/include/key/evalkeyrelin-fwd.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | /*
32 | * It is a lightweight file to be included where we need the declaration of EvalKeyRelin only
33 | *
34 | */
35 | #ifndef __EVALKEYRELIN_FWD_H__
36 | #define __EVALKEYRELIN_FWD_H__
37 |
38 | #include
39 |
40 | namespace lbcrypto {
41 |
42 | template
43 | class EvalKeyRelinImpl;
44 |
45 | template
46 | using EvalKeyRelin = std::shared_ptr>;
47 |
48 | } // namespace lbcrypto
49 |
50 | #endif // __EVALKEYRELIN_FWD_H__
51 |
--------------------------------------------------------------------------------
/src/core/include/utils/sertype.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | /*
33 | Definition of serialization type
34 | */
35 |
36 | #ifndef LBCRYPTO_SERTYPE_H
37 | #define LBCRYPTO_SERTYPE_H
38 |
39 | namespace lbcrypto {
40 |
41 | namespace SerType {
42 |
43 | class SERJSON {};
44 | static const SERJSON JSON; // should be const static to avoid compilation failure
45 |
46 | class SERBINARY {};
47 | static const SERBINARY BINARY; // should be const static to avoid compilation failure
48 |
49 | } // namespace SerType
50 |
51 | } // namespace lbcrypto
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/src/core/lib/utils/inttypes.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | /*
33 | This code provides basic integer types and enums
34 | */
35 |
36 | #include "utils/inttypes.h"
37 | #include
38 |
39 | std::ostream& operator<<(std::ostream& s, Format f) {
40 | switch (f) {
41 | case EVALUATION:
42 | s << "EVALUATION";
43 | break;
44 | case COEFFICIENT:
45 | s << "COEFFICIENT";
46 | break;
47 | default:
48 | s << "UNKNOWN";
49 | break;
50 | }
51 | return s;
52 | }
53 |
--------------------------------------------------------------------------------
/src/pke/include/cryptocontext-fwd.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | /*
33 | * It is a lightweight file to be included where we need the declaration of CryptoContext only
34 | *
35 | */
36 | #ifndef __CRYPTOCONTEXT_FWD_H__
37 | #define __CRYPTOCONTEXT_FWD_H__
38 |
39 | #include
40 |
41 | namespace lbcrypto {
42 |
43 | template
44 | class CryptoContextImpl;
45 |
46 | template
47 | using CryptoContext = std::shared_ptr>;
48 |
49 | } // namespace lbcrypto
50 |
51 | #endif // __CRYPTOCONTEXT_FWD_H__
52 |
53 |
--------------------------------------------------------------------------------
/src/pke/unittest/utils/UnitTestCryptoContext.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | #ifndef __UNITTESTCRYPTOCONTEXT_H__
33 | #define __UNITTESTCRYPTOCONTEXT_H__
34 |
35 | #include "BaseTestCase.h"
36 | #include "UnitTestCCParams.h"
37 | #include "cryptocontext.h"
38 | #include "schemebase/base-scheme.h"
39 |
40 | using Element = lbcrypto::DCRTPoly;
41 |
42 | lbcrypto::CryptoContext UnitTestGenerateContext(const UnitTestCCParams& testData);
43 | lbcrypto::CryptoContext UnitTestGenerateContext(const BaseTestCase& testCase);
44 |
45 | #endif // __UNITTESTCRYPTOCONTEXT_H__
46 |
--------------------------------------------------------------------------------
/src/core/lib/utils/utilities.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | /*
33 | This file contains utility functions
34 | */
35 |
36 | #include "utils/utilities.h"
37 |
38 | namespace lbcrypto {
39 |
40 | // auxiliary function to replace a specific character "in" with another character "out"
41 | std::string replaceChar(std::string str, char in, char out) {
42 | size_t found = str.find_first_of(in);
43 | while (found != std::string::npos) {
44 | str[found] = out;
45 | found = str.find_first_of(in, found + 1);
46 | }
47 | return str;
48 | }
49 |
50 | } // namespace lbcrypto
51 |
--------------------------------------------------------------------------------
/src/core/include/math/hal/nativeintbackend.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | #ifndef __NATIVEINTBACKEND_H__
33 | #define __NATIVEINTBACKEND_H__
34 |
35 | #include "math/hal/basicint.h"
36 | #include "math/hal/intnat/ubintnat.h"
37 | #include "math/hal/intnat/mubintvecnat.h"
38 | #include "math/hal/intnat/transformnat.h"
39 |
40 | namespace lbcrypto {
41 |
42 | using NativeInteger = intnat::NativeInteger;
43 | using NativeVector = intnat::NativeVector;
44 |
45 | } // namespace lbcrypto
46 |
47 | using NativeInteger = lbcrypto::NativeInteger;
48 | using NativeVector = lbcrypto::NativeVector;
49 |
50 | #endif
51 |
--------------------------------------------------------------------------------
/src/pke/include/encoding/plaintext-fwd.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | /*
32 | * It is a lightweight file to be included where we need the declaration of Plaintext only
33 | *
34 | */
35 | #ifndef __PLAINTEXT_FWD_H__
36 | #define __PLAINTEXT_FWD_H__
37 |
38 | #include
39 |
40 | namespace lbcrypto {
41 |
42 | class PlaintextImpl;
43 |
44 | using Plaintext = std::shared_ptr;
45 | using ConstPlaintext = const std::shared_ptr;
46 |
47 | using ReadOnlyPlaintext = std::shared_ptr;
48 |
49 | } // namespace lbcrypto
50 |
51 | #endif // __PLAINTEXT_FWD_H__
52 |
--------------------------------------------------------------------------------
/src/pke/lib/cryptoobject-impl.cpp:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 | #include "cryptoobject.h"
32 |
33 | #include "cryptocontext.h"
34 |
35 | namespace lbcrypto {
36 |
37 | template
38 | const std::shared_ptr> CryptoObject::GetCryptoParameters() const {
39 | return context->GetCryptoParameters();
40 | }
41 |
42 | template
43 | const EncodingParams CryptoObject::GetEncodingParameters() const {
44 | return context->GetCryptoParameters()->GetEncodingParams();
45 | }
46 |
47 | template class CryptoObject;
48 |
49 | } // namespace lbcrypto
50 |
--------------------------------------------------------------------------------
/src/core/include/utils/blockAllocator/xmap.h:
--------------------------------------------------------------------------------
1 | //==================================================================================
2 | // BSD 2-Clause License
3 | //
4 | // Copyright (c) 2014-2022, NJIT, Duality Technologies Inc. and other contributors
5 | //
6 | // All rights reserved.
7 | //
8 | // Author TPOC: contact@openfhe.org
9 | //
10 | // Redistribution and use in source and binary forms, with or without
11 | // modification, are permitted provided that the following conditions are met:
12 | //
13 | // 1. Redistributions of source code must retain the above copyright notice, this
14 | // list of conditions and the following disclaimer.
15 | //
16 | // 2. Redistributions in binary form must reproduce the above copyright notice,
17 | // this list of conditions and the following disclaimer in the documentation
18 | // and/or other materials provided with the distribution.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | //==================================================================================
31 |
32 | #ifndef _XMAP_H
33 | #define _XMAP_H
34 |
35 | #include
36 | #include