Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ~~~
# Copyright 2025 CryptoLab, Inc.
# Copyright 2026 CryptoLab, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -73,6 +73,8 @@ jobs:
preset: ci
- os: macos-latest
preset: ci-mac
- os: windows-latest
preset: ci-win

steps:
- uses: actions/checkout@v3
Expand All @@ -87,6 +89,7 @@ jobs:
run: ctest --preset all-test --output-on-failure

- name: Test Custom Params
if: matrix.preset != 'ci-win'
run: |
rm -rf build/CMakeCache.txt
cmake --preset ${{ matrix.preset }}-custom-param
Expand Down
71 changes: 51 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ~~~
# Copyright 2025 CryptoLab, Inc.
# Copyright 2026 CryptoLab, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@
cmake_minimum_required(VERSION 3.21)
project(
deb
VERSION 0.2.1
VERSION 0.3.0
LANGUAGES CXX
DESCRIPTION "CryptoLab's official cryptosystem library for FHE.")

Expand All @@ -40,9 +40,16 @@ set(CMAKE_INSTALL_PREFIX

set(DEB_MEMORY_ALIGN_SIZE
"0"
CACHE STRING
"Memory alignment size in bytes (default: 256). 0 means no alignment."
CACHE STRING "Memory alignment size in bytes. 0 means no alignment.")
set(DEB_EXT_LIB_FOR_SECURE_ZERO
"NONE"
CACHE
STRING
"External library for secure zeroing of memory. Options: NATIVE, LIBSODIUM, OPENSSL, NONE."
)
message(STATUS "Memory alignment size: ${DEB_MEMORY_ALIGN_SIZE} bytes")
message(
STATUS "External library for secure zeroing: ${DEB_EXT_LIB_FOR_SECURE_ZERO}")

set(PRE_BUILD_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/prebuild)
set(PRE_BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/generated)
Expand All @@ -52,7 +59,6 @@ message(STATUS "Generate pre-build directory: ${PRE_BUILD_DIR}")

include(cmake/CPM.cmake)
include(cmake/warnings.cmake)
include(cmake/bundling.cmake)

option(BUILD_SHARED_LIBS "Build a shared library instead of a static one." OFF)
option(DEB_BUILD_BENCHMARK "Build the benchmark suite." OFF)
Expand Down Expand Up @@ -84,22 +90,25 @@ add_subdirectory(external)
add_subdirectory(prebuild)

set(DEB_SRC
src/ModArith.cpp
src/Context.cpp
src/AleaRandomGenerator.cpp
src/CKKSTypes.cpp
src/NTT.cpp
src/Decryptor.cpp
src/Encryptor.cpp
src/FFT.cpp
src/SeedGenerator.cpp
src/Serialize.cpp
src/SecretKeyGenerator.cpp
src/KeyGenerator.cpp
src/Encryptor.cpp
src/Decryptor.cpp)
src/ModArith.cpp
src/NTT.cpp
src/OmpUtils.cpp
src/Preset.cpp
src/RandomGenerator.cpp
src/SecretKeyGenerator.cpp
src/SeedGenerator.cpp
src/Serialize.cpp)

add_library(${PROJECT_NAME}_obj OBJECT ${DEB_SRC})
add_dependencies(${PROJECT_NAME}_obj generate_flatbuffers
generated_param_header)
set_my_project_warnings(${PROJECT_NAME}_obj)
set_deb_warnings(${PROJECT_NAME}_obj)
set_property(TARGET ${PROJECT_NAME}_obj PROPERTY POSITION_INDEPENDENT_CODE ON)

if(NOT MSVC)
Expand All @@ -110,6 +119,19 @@ target_link_libraries(
${PROJECT_NAME}_obj PRIVATE $<BUILD_INTERFACE:alea>
$<BUILD_INTERFACE:flatbuffers>)

string(TOUPPER "${DEB_EXT_LIB_FOR_SECURE_ZERO}" _deb_secure_zero_backend)
if(_deb_secure_zero_backend STREQUAL "LIBSODIUM")
target_compile_definitions(${PROJECT_NAME}_obj
PUBLIC DEB_SECURE_ZERO_LIBSODIUM)
target_link_libraries(${PROJECT_NAME}_obj PRIVATE sodium)
elseif(_deb_secure_zero_backend STREQUAL "OPENSSL")
target_compile_definitions(${PROJECT_NAME}_obj PUBLIC DEB_SECURE_ZERO_OPENSSL)
target_link_libraries(${PROJECT_NAME}_obj PRIVATE OpenSSL::Crypto)
elseif(_deb_secure_zero_backend STREQUAL "NATIVE")
target_compile_definitions(${PROJECT_NAME}_obj PUBLIC DEB_SECURE_ZERO_NATIVE)
endif()
unset(_deb_secure_zero_backend)

target_include_directories(
${PROJECT_NAME}_obj
PRIVATE $<BUILD_INTERFACE:${PRE_BUILD_DIR}>
Expand All @@ -122,7 +144,9 @@ endif()
target_compile_definitions(${PROJECT_NAME}_obj
PUBLIC DEB_ALINAS_LEN=${DEB_MEMORY_ALIGN_SIZE})

add_library(${PROJECT_NAME})
add_library(${PROJECT_NAME} STATIC $<TARGET_OBJECTS:alea>
$<TARGET_OBJECTS:flatbuffers>)

add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} PUBLIC ${PROJECT_NAME}_obj)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
Expand Down Expand Up @@ -160,8 +184,18 @@ if(DEB_BUILD_DOXYGEN)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE ${CMAKE_CURRENT_SOURCE_DIR}/README.md)

doxygen_add_docs(
deb_doc ${CMAKE_CURRENT_SOURCE_DIR}/include/cdeb/deb.h
${CMAKE_CURRENT_SOURCE_DIR}/README.md ALL
deb_doc
${CMAKE_CURRENT_SOURCE_DIR}/include/deb/CKKSTypes.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/deb/Constant.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/deb/Context.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/deb/Decryptor.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/deb/Encryptor.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/deb/KeyGenerator.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/deb/SecretKeyGenerator.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/deb/Serialize.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/deb/Types.hpp
${CMAKE_CURRENT_SOURCE_DIR}/README.md
ALL
COMMENT "Generate documentation with Doxygen")
else()
message(STATUS "Doxygen not found, documentation will not be generated.")
Expand All @@ -181,9 +215,6 @@ if(DEB_BUILD_TEST)
add_subdirectory(test)
endif()

merge_archive_if_static(${PROJECT_NAME} alea)
merge_archive_if_static(${PROJECT_NAME} flatbuffers)

if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_RPATH "@loader_path"
BUILD_RPATH "@loader_path")
Expand Down
21 changes: 19 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"installDir": "${sourceDir}/build/install",
"cacheVariables": {
"DEB_BUILD_TEST": "ON",
"DEB_BUILD_BENCHMARK": "ON",
"DEB_BUILD_EXAMPLES": "OFF",
"DEB_BUILD_BENCHMARK": "OFF",
"DEB_BUILD_WITH_OMP": "ON"
}
},
Expand All @@ -36,6 +37,14 @@
"DEB_BUILD_WITH_OMP": "OFF"
}
},
{
"name": "ci-win",
"inherits": "ci",
"generator": "Ninja",
"cacheVariables": {
"DEB_BUILD_WITH_OMP": "OFF"
}
},
{
"name": "ci-custom-param",
"inherits": "ci",
Expand Down Expand Up @@ -66,6 +75,8 @@
"inherits": "release",
"cacheVariables": {
"DEB_RUNTIME_RESOURCE_CHECK": "OFF",
"DEB_BUILD_EXAMPLES": "OFF",
"DEB_BUILD_TEST": "OFF",
"DEB_BUILD_BENCHMARK": "ON",
"DEB_BUILD_WITH_OMP": "ON"
}
Expand Down Expand Up @@ -94,6 +105,12 @@
"configuration": "release",
"jobs": 4
},
{
"name": "ci-win",
"configurePreset": "ci-win",
"configuration": "release",
"jobs": 4
},
{
"name": "ci-custom-param",
"configurePreset": "ci-custom-param",
Expand Down Expand Up @@ -124,7 +141,7 @@
"noTestsAction": "error"
},
"environment": {
"OMP_NUM_THREADS": "8"
"OMP_NUM_THREADS": "1"
}
},
{
Expand Down
Loading
Loading