Skip to content

Commit 693e837

Browse files
committed
initial commit
0 parents  commit 693e837

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+11023
-0
lines changed

.github/workflows/Build.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Build
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- name: Build
13+
shell: bash
14+
run: |
15+
cmake . -B build
16+
cmake --build build
17+

.github/workflows/Checks.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Checks
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- name: Setup
13+
run: sudo apt-get install -y doxygen clang-format-12
14+
15+
- name: Documentation
16+
shell: bash
17+
run: ./scripts/build_documentation.sh
18+
19+
- name: Copyright
20+
run: ./scripts/check_copyright_headers.py
21+
22+
- name: Style
23+
shell: bash
24+
run: |
25+
find . -type f \( -iname "*.h" -o -iname "*.cc" \) -exec clang-format -n --style=Google {} \; &> checks.txt
26+
cat checks.txt
27+
test ! -s checks.txt

.github/workflows/Test.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Test
2+
3+
on: [push]
4+
5+
env:
6+
BUILD_TYPE: Debug
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Setup catch2
16+
run: |
17+
sudo apt-get install -y lcov
18+
curl -L https://github.com/catchorg/Catch2/archive/v2.13.0.tar.gz -o c.tar.gz
19+
tar xvf c.tar.gz
20+
cd Catch2-2.13.0/
21+
cmake -Bbuild -H. -DBUILD_TESTING=OFF
22+
sudo cmake --build build/ --target install
23+
24+
- name: Create build directory
25+
run: cmake -E make_directory ${{runner.workspace}}/build
26+
27+
- name: Configure CMake
28+
shell: bash
29+
working-directory: ${{runner.workspace}}/build
30+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
31+
32+
- name: Build
33+
working-directory: ${{runner.workspace}}/build
34+
shell: bash
35+
run: cmake --build . --config $BUILD_TYPE
36+
37+
- name: Test
38+
working-directory: ${{runner.workspace}}/build
39+
shell: bash
40+
run: ctest -C $BUILD_TYPE
41+
42+
- name: Coverage
43+
working-directory: ${{runner.workspace}}/build
44+
shell: bash
45+
run: |
46+
make coverage
47+
lcov --summary coverage.info >> summary.txt
48+
49+
- name: Check
50+
shell: bash
51+
run: ./scripts/check_coverage.py ${{runner.workspace}}/build/summary.txt

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
scutil.*
2+
build/
3+
doc/
4+
/TAGS
5+
/GPATH
6+
/GRTAGS
7+
/GTAGS
8+
/.projectile
9+
examples/build/
10+
examples/libscl.*
11+
secure-computation-library.*
12+
/.cache/
13+
/compile_commands.json
14+
/lib/
15+
/install/

CMakeLists.txt

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# SCL --- Secure Computation Library
2+
# Copyright (C) 2022 Anders Dalskov
3+
#
4+
# This program is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU Affero General Public License as published by
6+
# the Free Software Foundation, either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU Affero General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU Affero General Public License
15+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
cmake_minimum_required( VERSION 3.14 )
18+
19+
project( scl VERSION 1.0.0 DESCRIPTION "Secure Computation Library" )
20+
21+
if(NOT CMAKE_BUILD_TYPE)
22+
set(CMAKE_BUILD_TYPE Release)
23+
endif()
24+
25+
message(STATUS "CMAKE_BUILD_TYPE=" ${CMAKE_BUILD_TYPE})
26+
27+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
28+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -pedantic -Werror -std=gnu++17")
29+
30+
set(SCL_SOURCE_FILES
31+
src/scl/prg.cc
32+
src/scl/hash.cc
33+
34+
src/scl/math/str.cc
35+
src/scl/math/mersenne61.cc
36+
src/scl/math/mersenne127.cc
37+
38+
src/scl/net/config.cc
39+
src/scl/net/mem_channel.cc
40+
src/scl/net/tcp_channel.cc
41+
src/scl/net/threaded_sender.cc
42+
src/scl/net/tcp_utils.cc
43+
src/scl/net/network.cc
44+
src/scl/net/discovery/server.cc
45+
src/scl/net/discovery/client.cc)
46+
47+
set(SCL_HEADERS "${CMAKE_SOURCE_DIR}/include")
48+
49+
include_directories(${SCL_HEADERS})
50+
51+
if(CMAKE_BUILD_TYPE MATCHES "Release")
52+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
53+
add_library(scl SHARED ${SCL_SOURCE_FILES})
54+
55+
set_target_properties(scl PROPERTIES VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
56+
57+
message(STATUS "CMAKE_INSTALL_PREFIX=" ${CMAKE_INSTALL_PREFIX})
58+
59+
install(TARGETS scl
60+
ARCHIVE DESTINATION lib
61+
LIBRARY DESTINATION lib)
62+
63+
install(DIRECTORY "${SCL_HEADERS}/"
64+
DESTINATION include
65+
FILES_MATCHING PATTERN "*.h")
66+
67+
endif()
68+
69+
if(CMAKE_BUILD_TYPE MATCHES "Debug")
70+
71+
set(SCL_TEST_SOURCE_FILES
72+
test/scl/main.cc
73+
74+
test/scl/test_hash.cc
75+
test/scl/test_prg.cc
76+
77+
test/scl/math/test_mersenne61.cc
78+
test/scl/math/test_mersenne127.cc
79+
test/scl/math/test_vec.cc
80+
test/scl/math/test_mat.cc
81+
test/scl/math/test_la.cc
82+
test/scl/math/test_ff.cc
83+
test/scl/math/test_z2k.cc
84+
85+
test/scl/ss/test_additive.cc
86+
test/scl/ss/test_poly.cc
87+
test/scl/ss/test_shamir.cc
88+
89+
test/scl/net/util.cc
90+
test/scl/net/test_config.cc
91+
test/scl/net/test_mem_channel.cc
92+
test/scl/net/test_tcp_channel.cc
93+
test/scl/net/test_threaded_sender.cc
94+
test/scl/net/test_network.cc
95+
test/scl/net/test_discover.cc
96+
97+
test/scl/p/test_simple.cc)
98+
99+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
100+
find_package(Catch2 REQUIRED)
101+
include(CTest)
102+
include(Catch)
103+
include(${CMAKE_SOURCE_DIR}/cmake/CodeCoverage.cmake)
104+
105+
# Tests that check bounds for reading/writing are sped up considerably by
106+
# lowering said bounds.
107+
add_compile_definitions(MAX_VEC_READ_SIZE=1024)
108+
add_compile_definitions(MAX_MAT_READ_SIZE=1024)
109+
add_compile_definitions(SCL_TEST_DATA_DIR="${CMAKE_SOURCE_DIR}/test/data/")
110+
111+
add_executable(scl_test ${SCL_SOURCE_FILES} ${SCL_TEST_SOURCE_FILES})
112+
target_link_libraries(scl_test Catch2::Catch2 pthread)
113+
catch_discover_tests(scl_test)
114+
115+
append_coverage_compiler_flags()
116+
117+
# Tell lcov to ignore system STL headers in order to make the coverage
118+
# output more precise.
119+
setup_target_for_coverage_lcov(
120+
NAME coverage
121+
EXECUTABLE scl_test
122+
EXCLUDE "/usr/include/*" "test/*" "/usr/lib/*" "/usr/local/*")
123+
124+
endif()

0 commit comments

Comments
 (0)