Build system setup
This commit is contained in:
parent
36c9ab36cf
commit
ff8386e903
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
build/
|
||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "SEAL"]
|
||||
path = SEAL
|
||||
url = https://github.com/microsoft/SEAL.git
|
||||
40
CMakeLists.txt
Normal file
40
CMakeLists.txt
Normal file
@ -0,0 +1,40 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(homcert LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Allow customizing what components to build
|
||||
option(HOMCERT_BUILD_TESTS "Build homcert tests" OFF)
|
||||
option(HOMCERT_BFV_SEAL "Provide BFV implementation using Microsoft SEAL" ON)
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
set(HOMCERT_BUILD_TESTS ON CACHE BOOL "Enable homcert tests" FORCE)
|
||||
endif()
|
||||
|
||||
# Include lib crypto
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
# Make homcert main library
|
||||
add_library(homcert "")
|
||||
target_link_libraries(homcert PRIVATE OpenSSL::Crypto)
|
||||
target_include_directories(homcert PUBLIC include)
|
||||
|
||||
target_compile_definitions(homcert PRIVATE
|
||||
$<$<BOOL:${HOMCERT_BFV_SEAL}>:HOMCERT_BFV_SEAL>
|
||||
)
|
||||
|
||||
if (HOMCERT_BFV_SEAL)
|
||||
set(SEAL_BUILD_TESTS OFF CACHE BOOL "Disable SEAL tests" FORCE)
|
||||
set(SEAL_BUILD_BENCH OFF CACHE BOOL "Disable SEAL benchmarks" FORCE)
|
||||
set(SEAL_BUILD_EXAMPLES OFF CACHE BOOL "Disable SEAL examples" FORCE)
|
||||
add_subdirectory(SEAL)
|
||||
|
||||
target_link_libraries(homcert PRIVATE SEAL::seal)
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
if (HOMCERT_BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
1
SEAL
Submodule
1
SEAL
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 7a931d55ba84a40b85938f6ca3ac206f18654093
|
||||
@ -3,6 +3,10 @@
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
#include <bit>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
||||
namespace homcert::bfv {
|
||||
|
||||
@ -42,7 +46,26 @@ struct plaintext {
|
||||
|
||||
using ciphertext = int;
|
||||
|
||||
// TODO -> Exception with enum that differentiates reason (e.g. CONTEXT_NO_PRIVATE)
|
||||
// Exception for BFV errors in context
|
||||
|
||||
class bfv_exception : public std::exception {
|
||||
public:
|
||||
enum class REASON {
|
||||
CTX_NO_PRIVATE,
|
||||
CTX_NO_PUBLIC,
|
||||
CTX_ARITHMETIC,
|
||||
CTX_MEMORY,
|
||||
CTX_INVALID_ARGUMENT,
|
||||
CTX_COMPONENT
|
||||
};
|
||||
private:
|
||||
REASON m_reason;
|
||||
std::string m_message;
|
||||
public:
|
||||
bfv_exception(REASON reason, std::string message);
|
||||
REASON reason() const noexcept;
|
||||
const char* what() const noexcept override;
|
||||
};
|
||||
|
||||
// Inheriting from context class allows pluggability of implementations (e.g. SEAL vs. GPU)
|
||||
|
||||
@ -50,7 +73,7 @@ struct context {
|
||||
static constexpr int PUBLIC_COMPONENT = 1;
|
||||
static constexpr int PRIVATE_COMPONENT = 2;
|
||||
|
||||
virtual ~context();
|
||||
virtual ~context() = default;
|
||||
|
||||
virtual void new_components(int components) = 0; // context default constructs empty
|
||||
virtual void has_components(int components) const = 0;
|
||||
|
||||
1
src/CMakeLists.txt
Normal file
1
src/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
target_sources(homcert PRIVATE bfv.cpp)
|
||||
16
src/bfv.cpp
Normal file
16
src/bfv.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "bfv.hpp"
|
||||
|
||||
namespace homcert::bfv {
|
||||
|
||||
bfv_exception::bfv_exception(REASON reason, std::string message)
|
||||
: m_reason(reason), m_message(std::move(message)) {}
|
||||
|
||||
bfv_exception::REASON bfv_exception::reason() const noexcept {
|
||||
return m_reason;
|
||||
}
|
||||
|
||||
const char* bfv_exception::what() const noexcept {
|
||||
return m_message.c_str();
|
||||
}
|
||||
|
||||
};
|
||||
6
test/CMakeLists.txt
Normal file
6
test/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
find_package(GTest REQUIRED)
|
||||
|
||||
if (HOMCERT_BFV_SEAL)
|
||||
add_executable(test_bfv bfv/main.cpp)
|
||||
target_link_libraries(test_bfv PRIVATE homcert GTest::GTest)
|
||||
endif()
|
||||
31
test/bfv/main.cpp
Normal file
31
test/bfv/main.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include <iostream>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <bfv.hpp>
|
||||
|
||||
using namespace homcert;
|
||||
|
||||
class BFV : public ::testing::Test {
|
||||
protected:
|
||||
std::shared_ptr<bfv::context> m_context;
|
||||
};
|
||||
|
||||
class BFV_SEAL : public BFV {
|
||||
protected:
|
||||
static void SetUpTestSuite() {
|
||||
// GTEST_SKIP() << "Test environment not available";
|
||||
}
|
||||
|
||||
static void TearDownTestSuite() {}
|
||||
};
|
||||
|
||||
TEST_F(BFV_SEAL, XXX) {
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user