#
# spec file for package openfhe
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

%define libsover 1
%define libsoname lib%{name}%{libsover}
Name:           openfhe
Version:        1.2.3
Release:        0
Summary:        Fully Homomorphic Encryption Library
License:        BSD-2-Clause
Group:          Development/Libraries/C and C++
URL:            https://openfhe.org/
Source0:        https://github.com/openfheorg/openfhe-development/archive/refs/tags/v%{version}.tar.gz#/%{name}-development-%{version}.tar.gz
BuildRequires:  cmake >= 3.10
BuildRequires:  gcc-c++

%description
Fully Homomorphic Encryption (FHE) is a cryptographic primitive that
performs computations over encrypted data without having access to
the secret key.

%package -n %{libsoname}
Summary:        Fully Homomorphic Encryption Library
Group:          System/Libraries

%description -n %{libsoname}
Fully Homomorphic Encryption (FHE) is a cryptographic primitive that
performs computations over encrypted data without having access to
the secret key. OpenFHE includes implementations of all common FHE
schemes:

* 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
  (includes approximate bootstrapping)
* Ducas-Micciancio (DM/FHEW), Chillotti-Gama-Georgieva-Izabachene
  (CGGI/TFHE), and Lee-Micciancio-Kim-Choi-Deryabin-Eom-Yoo (LMKCDEY)
  schemes for evaluating Boolean circuits and arbitrary functions
  over larger plaintext spaces using lookup tables

%package devel
Summary:        Headers for the Fully Homomorphic Encryption Library
Group:          Development/Libraries/C and C++
Requires:       %{libsoname} == %{version}
BuildArch:      noarch

%description devel
Fully Homomorphic Encryption (FHE) is a cryptographic primitive that
performs computations over encrypted data without having access to
the secret key.

This subpackage contains the headers for the C API.

%prep
%setup -n  openfhe-development-%{version}

%build
export CXXFLAGS+="-DGIT_SUBMOD_AUTO=OFF -DBUILD_BENCHMARKS=OFF"
%cmake
%cmake_build 

%install
%cmake_install

%check
cd build
%make_build testall

%post -n %{libsoname} -p /sbin/ldconfig
%postun -n %{libsoname} -p /sbin/ldconfig

%files -n %{libsoname}
%license LICENSE 
%doc README.md
/usr/lib/libOPENFHEpke.so.%{version}
/usr/lib/libOPENFHEbinfhe.so.%{version}
/usr/lib/libOPENFHEcore.so.%{version}

%files devel
%dir %{_includedir}/%{name}/
%{_includedir}/%{name}/*
%dir /usr/lib/OpenFHE
/usr/lib/OpenFHE/*.cmake
/usr/lib/libOPENFHEpke.so
/usr/lib/libOPENFHEbinfhe.so
/usr/lib/libOPENFHEcore.so
/usr/lib/libOPENFHEpke.so.1
/usr/lib/libOPENFHEbinfhe.so.1
/usr/lib/libOPENFHEcore.so.1

