From 0f1c04ed7eda3cd7d3a784ba048ba69658829cf0 Mon Sep 17 00:00:00 2001 From: John Wohlbier Date: Tue, 23 Nov 2021 18:11:37 -0500 Subject: Add encryption library packages: helib, palisade-development, and seal (#27495) Add packages for three common homomorphic encryption libraries. HElib, Palisade, and Seal. Also add package for number theoretic library NTL. --- var/spack/repos/builtin/packages/helib/package.py | 51 ++++++++++++++++ var/spack/repos/builtin/packages/ntl/package.py | 62 +++++++++++++++++++ .../packages/palisade-development/package.py | 70 ++++++++++++++++++++++ var/spack/repos/builtin/packages/seal/package.py | 30 ++++++++++ 4 files changed, 213 insertions(+) create mode 100644 var/spack/repos/builtin/packages/helib/package.py create mode 100644 var/spack/repos/builtin/packages/ntl/package.py create mode 100644 var/spack/repos/builtin/packages/palisade-development/package.py create mode 100644 var/spack/repos/builtin/packages/seal/package.py (limited to 'var') diff --git a/var/spack/repos/builtin/packages/helib/package.py b/var/spack/repos/builtin/packages/helib/package.py new file mode 100644 index 0000000000..07d141ff54 --- /dev/null +++ b/var/spack/repos/builtin/packages/helib/package.py @@ -0,0 +1,51 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack import * + + +class Helib(CMakePackage): + """HElib is an open-source (Apache License v2.0) software library that + implements homomorphic encryption (HE). + + Currently available schemes are the implementations of the + Brakerski-Gentry-Vaikuntanathan (BGV) scheme + with bootstrapping and the Approximate Number scheme of Cheon-Kim-Kim-Song + (CKKS), along with many optimizations to make homomorphic evaluation run + faster, focusing mostly on effective use of the Smart-Vercauteren + ciphertext packing techniques and the Gentry-Halevi-Smart optimizations. + """ + + homepage = "https://github.com/homenc/HElib" + url = "https://github.com/homenc/HElib/archive/refs/tags/v2.2.1.tar.gz" + + maintainers = ['wohlbier'] + + version('2.2.1', sha256='cbe030c752c915f1ece09681cadfbe4f140f6752414ab000b4cf076b6c3019e4') + version('2.2.0', sha256='e5f82fb0520a76eafdf5044a1f17f512999479d899da8c34335da5e193699b94') + version('2.1.0', sha256='641af0f602cfc7f5f5b1cfde0652252def2dfaf5f7962c2595cf598663637951') + version('2.0.0', sha256='4e371807fe052ca27dce708ea302495a8dae8d1196e16e86df424fb5b0e40524') + version('1.3.1', sha256='8ef47092f6b15fbb484a21f9184e7d936c360198515b6efb9a55d3dfbc2ea4be') + version('1.3.0', sha256='9f69dc5be9197f9ab8cdd81af9a59c12968a0ee11d595b1b1438707ff5405694') + version('1.2.0', sha256='17e0448a3255ab01a1ebd8382f9d08a318e3d192b56d062a1fd65fbb0aadaf67') + version('1.1.0-beta.0', sha256='6a454b029f3805101f714f50ae5199e2b2b86c1e520a659f130837810eabe4b5') + version('1.1.0', sha256='77a912ed3c86f8bde31b7d476321d0c2d810570c04a60fa95c4bd32a1955b5cf') + version('1.0.2', sha256='b907eaa8381af3d001d7fb8383273f4c652415b3320c11d5be2ad8f19757c998') + + variant('shared', default=False, description='Build shared library.') + depends_on('gmp@6.2.1:') + depends_on('ntl@11.5.1:') + depends_on('ntl+shared', when='+shared') + + def cmake_args(self): + spec = self.spec + args = [ + self.define('ENABLE_TEST', 'ON'), + self.define('GMP_DIR', spec['gmp'].prefix), + self.define('NTL_DIR', spec['ntl'].prefix), + self.define_from_variant('BUILD_SHARED', 'shared') + ] + + return args diff --git a/var/spack/repos/builtin/packages/ntl/package.py b/var/spack/repos/builtin/packages/ntl/package.py new file mode 100644 index 0000000000..7313e1884d --- /dev/null +++ b/var/spack/repos/builtin/packages/ntl/package.py @@ -0,0 +1,62 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack import * + + +class Ntl(Package): + """ + NTL -- a library for doing number theory + + NTL is open-source software distributed under the terms of the GNU Lesser + General Public License (LGPL) version 2.1 or later. See the file + doc/copying.txt for complete details on the licensing of NTL. + + Documentation is available in the file doc/tour.html, which can be viewed + with a web browser. + + """ + + homepage = "https://libntl.org" + url = "https://github.com/libntl/ntl/archive/refs/tags/v11.5.1.tar.gz" + + maintainers = ['wohlbier'] + + version('11.5.1', sha256='ef578fa8b6c0c64edd1183c4c303b534468b58dd3eb8df8c9a5633f984888de5') + version('11.5.0', sha256='9e1e6488b177c3e5d772fdd6279c890937a9d1c3b694a904ac1cfbe9cab836db') + version('11.4.4', sha256='2ce7a10fadbed6c3859d72c859612a4ca0dbdf6a9db99db4261422b7f0804bfa') + + variant('shared', default=False, description='Build shared library.') + + depends_on('gmp') + + phases = ['configure', 'build', 'install'] + + def configure_args(self): + spec = self.spec + prefix = self.prefix + + config_args = [ + 'CXX={0}'.format(self.compiler.cxx), + 'DEF_PREFIX={0}'.format(prefix), + 'GMP_PREFIX={0}'.format(spec['gmp'].prefix) # gmp dependency + ] + if '+shared' in spec: + config_args.append('SHARED=on') + + return config_args + + def configure(self, spec, prefix): + with working_dir('src'): + configure = Executable('./configure') + configure(*self.configure_args()) + + def build(self, spec, prefix): + with working_dir('src'): + make() + + def install(self, spec, prefix): + with working_dir('src'): + make('install') diff --git a/var/spack/repos/builtin/packages/palisade-development/package.py b/var/spack/repos/builtin/packages/palisade-development/package.py new file mode 100644 index 0000000000..f32d521741 --- /dev/null +++ b/var/spack/repos/builtin/packages/palisade-development/package.py @@ -0,0 +1,70 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack import * + + +class PalisadeDevelopment(CMakePackage): + """ + PALISADE is a general lattice cryptography library that currently + includes efficient implementations of the following lattice cryptography + capabilities: + + Fully Homomorphic Encryption (FHE): + - Brakerski/Fan-Vercauteren (BFV) scheme for integer arithmetic + - Brakerski-Gentry-Vaikuntanathan (BGV) scheme for integer arithmetic + - Cheon-Kim-Kim-Song (CKKS) scheme for real-number arithmetic + - Ducas-Micciancio (FHEW) and Chillotti-Gama-Georgieva-Izabachene + (TFHE) schemes for Boolean circuit evaluation + + Multi-Party Extensions of FHE (to support multi-key FHE): + - Threshold FHE for BGV, BFV, and CKKS schemes + - Proxy Re-Encryption for BGV, BFV, and CKKS schemes + """ + + homepage = "https://gitlab.com/palisade/palisade-development" + git = "https://gitlab.com/palisade/palisade-development.git" + maintainers = ['wohlbier'] + + version('feature-fixed-point-encoding', + branch='feature-fixed-point-encoding') + version('master', branch='master', preferred=True) + + variant('shared', default=True, description='Build shared library.') + variant('static', default=True, description='Build static library.') + variant('with_be2', default=True, description='Build with backend 2.') + variant('with_be4', default=True, description='Build with backend 4.') + variant('with_intel_hexl', default=False, description='Use Intel HEXL.') + variant('with_ntl', default=False, description='Build NTL.') + + depends_on('autoconf') + depends_on('hwloc', when='%clang') + depends_on('ntl', when='+with_ntl') + depends_on('ntl+shared', when='+with_ntl +shared') + + def cmake_args(self): + args = [ + self.define_from_variant('BUILD_SHARED', 'shared'), + self.define_from_variant('BUILD_STATIC', 'static'), + self.define_from_variant('WITH_BE2', 'with_be2'), + self.define_from_variant('WITH_BE4', 'with_be4'), + self.define_from_variant('WITH_INTEL_HEXL', 'with_intel_hexl'), + self.define_from_variant('WITH_NTL', 'with_ntl') + ] + if self.spec.satisfies('%clang'): + OpenMP_C_FLAGS = "-fopenmp=libomp" + OpenMP_C_LIB_NAMES = "libomp" + args += [ + self.define('OpenMP_C', 'clang'), + self.define('OpenMP_C_FLAGS', OpenMP_C_FLAGS), + self.define('OpenMP_C_LIB_NAMES', OpenMP_C_LIB_NAMES), + self.define('OpenMP_CXX', 'clang++'), + self.define('OpenMP_CXX_FLAGS', OpenMP_C_FLAGS), + self.define('OpenMP_CXX_LIB_NAMES', OpenMP_C_LIB_NAMES), + self.define('OpenMP_libomp_LIBRARY', 'libomp'), + self.define('OpenMP_libgomp_LIBRARY', 'libgomp'), + self.define('OpenMP_libiomp5_LIBRARY', 'libiomp5') + ] + return args diff --git a/var/spack/repos/builtin/packages/seal/package.py b/var/spack/repos/builtin/packages/seal/package.py new file mode 100644 index 0000000000..3fa81bba0b --- /dev/null +++ b/var/spack/repos/builtin/packages/seal/package.py @@ -0,0 +1,30 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack import * + + +class Seal(CMakePackage): + """Microsoft SEAL is an easy-to-use open-source (MIT licensed) + homomorphic encryption library developed by the Cryptography and Privacy + Research Group at Microsoft. Microsoft SEAL is written in modern standard + C++ and is easy to compile and run in many different environments. For + more information about the Microsoft SEAL project, see sealcrypto.org.""" + + homepage = "https://github.com/microsoft/SEAL" + url = "https://github.com/microsoft/SEAL/archive/refs/tags/v3.7.1.tar.gz" + + maintainers = ['wohlbier'] + + version('3.7.1', sha256='6737177bfb582cc1a2863ef1e96cc6c39b119257e7192981a3190eb79e0fcfd3') + version('3.7.0', sha256='06ea835d6c9cdbbc4edb72a8db4bd4b1115995f075774043b9f31938d0624543') + version('3.6.6', sha256='85a63188a5ccc8d61b0adbb92e84af9b7223fc494d33260fa17a121433790a0e') + version('3.6.5', sha256='77bfcb4a8b785206c419cdf7aff8c200250691518eeddc958f874d1f567b2872') + version('3.6.4', sha256='7392574fe3b757d5ced8cc973b23a7b69be0cd35b6e778b3c2447598e9ece5b3') + version('3.6.3', sha256='aeecdf79afba5f83d1828b3525760c04e52928614038e9a860773943d5d14558') + version('3.6.2', sha256='1e2a97deb1f5b543640fc37d7b4737cab2a9849f616c13ff40ad3be4cf29fb9c') + version('3.6.1', sha256='e399c0df7fb60ad450a0ccfdc81b99d19308d0fc1f730d4cad4748dfb2fdb516') + version('3.6.0', sha256='79c0e45bf301f4577a7633b14e8b26e37eefc89fd4f6a29d13f87e5f22a372ad') + version('3.5.9', sha256='23bf3bf7ae1dae5dae271244a5baa66fa01856c52e263fe8368c3a40f2399fc7') -- cgit v1.2.3-60-g2f50