Skip to content

Commit

Permalink
Dev (#60)
Browse files Browse the repository at this point in the history
* src: create new directory structure for system

* util: create util folder for global includes and include guards. debug asserts now work properly

* src: continue work making grpc dependency

* src: continue work making grpc dependency

* dependdencies: move location of seal download

* bin: make executables go into sensible folders

* cmake: finish grpc cmake

* cmake: revert seal cmake

* cmake: stop auto generation of dependency targets

* Update cmake.yml

* WIP: Query expander (#17)

QueryExpander separated from sealpir and can be used as a component to expand specific parts of queries.

* cmake: change names of executables in tests for usability purposes

* internals: change name of folder for restructure

* Update cmake.yml

set to ubuntu 22 for compiler puroses

* Working-Frievalds (#18)

math_utils, test, internals
create 2 dim tensor container, implement freivalds algorithm and container, freivalds mostly runs in ptext space by use of split-ptx structure.
add proto messages, not integrate with rest of project yet.
tests added for freivalds.

Co-authored-by: Jonathan Weiss <[email protected]>
Co-authored-by: Elkana Tovey <[email protected]>

* fx: wrong verify on ctx-ctx mat-mul

* Minor maintainence (#22)

* FetchDependencies.cmake: add option for precompiled libraries

* README: update readme for new compile options

* grpc: update grpc version

* .github: create caching version of test

* services-wip

* adding op order test to evaluator wrapper.

* small refactor

* adding asserts

* added comments

* fix: forgot to switch back to bgv

* associative test passing

* fix: trivial_ciphertext into const func

* transformer uses resize to ensure correct size of given matrix

* matrix multiplication using matrices

* working frievalds test

* frievald's unit-test inspect failure with C != A*B

* added benchmarks to ptx-ctx multiplication

* fx: timing function

* benchmark fix

* fx: mat-mul with ptx-ctx, frievalds with ctx-ctx.

* working on concurrent matrix-mult

* adding channel and waitgroup

* feat: threaded mat-mul for ptx-ctx

* fx: using ntt in mult ptx-ctx matrices

* refactor in mat-mult.cpp

* parallel ntt transform of matrices

* defined RPC messages. refined RPC services

* relocated manager, worker services.

* minimal working cmake to add services package. should later on split into sub packages

* wip: setting up basic worker service

* adding test/services package

* fx: including services in the cmake of test

* testing connection to basic service

* wip: worker service

* wip: worker receive stream

* wip: worker

* worker- adding distribicom message creation funcs

* wip: worker receives complicated messages. unit tests sends multi-messages

* refactoring worker.cpp

* refactoring the stream code

* fx build

* wip: worker-service receive

* rfactor

* feat: added possibility to send a galoiskey to the worker

* clang fix

* wip: understanding how to create multi-service server

* WIP

* fx

* WIP

* fx

* fx

Co-authored-by: Jonathan Weiss <[email protected]>

* fx: workers-unit test

* add scripts used for lab work and fix yaml (#29)

* scripts: add scripts used for faster development in aqua environment

* github: edit workflow so doesnt try to run dependency tests

* workflows fix (#30)

* scripts: add scripts used for faster development in aqua environment

* github: edit workflow so doesnt try to run dependency tests

* Update fast_test.yml

* 25 client service (#32)

* cmake: make easier to find include files of each target

* client_service: start functions

* Services (#33)

services package:
- Worker -manager subscribing
- WIP: work-distribution, first connection made (manager to worker)/
- WIP: thread safe DB-handle.
- refactored worker, and created utils.hpp.

math_util package:
- channel read with timeouts.


Co-authored-by: Jonathan Weiss <[email protected]>
Co-authored-by: Jonathan Weiss <[email protected]>

* Manager subscriber (#34)

* service package:
 - threadsafe db.
 - heavy refactoring and adding utils.hpp.
 - connection between worker-manager half-complete. no distribution logic as of yet.
 - server.hpp improvements.
 - channel can now wwait with a timeout.
 - fix in matrix.h

* read-with-timeout

Co-authored-by: Jonathan Weiss <[email protected]>

* Update fast_test.yml

* Concurrency refactor (#35)

* concurrency: 
-refactor cuncurrency into it's own target and folder, move old files into older for cleanup

* src:
-refactor cmake files and includes to more consistent naming scheme for including headers.
-rename matrix_multiplier to matrix_operations
-rename multiplication_utils namespace to math_utils nmespace

* upgrading remote-compiler to support callgrind visualisations

* WIP: Worker (#37)

In this PR we are connecting one side of the main-server to the worker.

- manager offers API for waiting to X workers to register.
- streaming galois keys from manager to worker.
- receiving galois keys on the worker side.
- additional constants.

* Client service (#36)


* Create devcontainer.json

* client_service: queries, callback with answer, decryption and round notification implemented

* marshal: add marshaling for ptx and ctx vectors , pir responses, and queries into protobuf messages

* client_service: test works, add ele sizes to configs

Co-authored-by: elkanatovey <[email protected]>
Co-authored-by: Elkana Tovey <[email protected]>

* server_service: start work on db modifying ptxs for between round work

* server_service: start work on db modifying ptxs for between round work

* server: add rpcs, make implement server from grpc

* server: put in stubs for client connections, start work on bookeeping for work distribution

* server_service: continue work

* server: ledger now more organised

* server: minor refactor

* squashed branch:
- replaced waitGroup with std:latch/
- mvp reciving worker's local processings.
- matrix asserting correct access to its data.

* server: commented out unimplemented code

* removed unneeded scope

* renamed namespace from pir_primitives to services

* fix: shared lock on write

* renamed clientQueryLedger

* manager.cpp: start galois key mapping
server.cpp: create mapping logic

* manager.cpp: write galois mapping distribute work

* server main-loop binary supported

* manager: add db sending functionality
marshal: add more marshaling caps + test

* manager: add query sending functionality

* manager: minor change to db responsibilities

* manager: halfway done integration

* fix: ipv6 support in extract ip

* manager.cpp: continue work on integration

* manager: mostly done integration

* manager: fix bug and factor out old db constructs
server: factor out old db constructs
proto: minor update to unsigned integer types for consistency

* proto: pass ip address in message body from worker

* math_utils/evaluator_wrapper: add method for ptx embedding of ctxs

* Async stream (#55)

* async server sending using streams.
* worker identification using credentials (secret given to server upon register).

Co-authored-by: Jonathan Weiss <[email protected]>

* evaluator_wrapper: add compose to plaintext, add const on add_plain

* evaluator_wrapper: compose_to_plaintext writes as ntt form

* Server service (#56)

* server_service: add fuctionality for work distribution

* evaluator_wrapper: add functionality for second stage pir


Co-authored-by: Jonathan Weiss <[email protected]>
Co-authored-by: Jonathan <[email protected]>

* fix: galois_keys generation

* Squashed commit of the following:

commit df44f799c26ed4085374ff54fdd4a5b9f94eb7fd
Author: Jonathan Weiss <[email protected]>
Date:   Thu Dec 8 09:34:03 2022 +0200

    async mat-mult ops
    - mult with vector from left or right.
    - mult with matrices of different elements (ctxs-ptx, ptx-ctx, ctx-ctx).

commit 867da10ccba23e1ea809cb19dd6a29efab0c64c6
Author: Jonathan Weiss <[email protected]>
Date:   Thu Dec 8 08:51:56 2022 +0200

    refactor: naming mult the same for ptx mult vs split-ptx mult

commit 5c3e0e9766b7e9712da51c69d5b6f8174b44d211
Author: Jonathan Weiss <[email protected]>
Date:   Thu Dec 8 08:17:56 2022 +0200

    refactor

commit 772c0f8dfae95e77ea4067b99c711a4eda435d6a
Author: Jonathan Weiss <[email protected]>
Date:   Thu Dec 8 08:15:44 2022 +0200

    dropped code used only in tests of itself.

commit 578eb077b0f1f7e4142ae2b181241f38a98cc6e3
Author: Jonathan Weiss <[email protected]>
Date:   Thu Dec 8 08:07:37 2022 +0200

    removed commented out code

commit 7741ddfd1a90884488fe0f2540077876b663ad87
Author: Jonathan Weiss <[email protected]>
Date:   Wed Dec 7 18:18:54 2022 +0200

    feat:
    - ctx-ctx matmul is threaded.
    - removed unused code

commit 24d9ea3e7e45587ae4eb5f57f167ba697af4c81b
Author: Jonathan Weiss <[email protected]>
Date:   Wed Dec 7 18:13:46 2022 +0200

    generic thread pool utilised

commit 3c40703
Author: Jonathan <[email protected]>
Date:   Wed Dec 7 15:42:38 2022 +0200

    Async stream (#55)

    * async server sending using streams.
    * worker identification using credentials (secret given to server upon register).

    Co-authored-by: Jonathan Weiss <[email protected]>

commit 0ed00c7
Merge: 956e12a f448803
Author: elkanatovey <[email protected]>
Date:   Wed Dec 7 15:17:15 2022 +0200

    Merge remote-tracking branch 'origin/server_service' into server_service

commit 956e12a
Author: elkanatovey <[email protected]>
Date:   Wed Dec 7 15:16:37 2022 +0200

    math_utils/evaluator_wrapper: add method for ptx embedding of ctxs

commit f448803
Author: elkana <[email protected]>
Date:   Tue Dec 6 23:17:11 2022 +0200

    proto: pass ip address in message body from worker

commit e54a9d2
Author: elkanatovey <[email protected]>
Date:   Tue Dec 6 18:03:54 2022 +0200

    manager: fix bug and factor out old db constructs
    server: factor out old db constructs
    proto: minor update to unsigned integer types for consistency

commit ecda72a
Author: elkanatovey <[email protected]>
Date:   Tue Dec 6 17:37:36 2022 +0200

    manager: mostly done integration

commit 1a96c9e
Author: elkana <[email protected]>
Date:   Tue Dec 6 12:45:37 2022 +0200

    manager.cpp: continue work on integration

commit e48447a
Author: Jonathan Weiss <[email protected]>
Date:   Tue Dec 6 08:35:53 2022 +0200

    fix: ipv6 support in extract ip

commit 598ebc6
Author: elkanatovey <[email protected]>
Date:   Mon Dec 5 20:50:01 2022 +0200

    manager: halfway done integration

commit aee2ef2
Author: elkanatovey <[email protected]>
Date:   Mon Dec 5 18:12:11 2022 +0200

    manager: minor change to db responsibilities

commit 8c079f0
Author: elkanatovey <[email protected]>
Date:   Mon Dec 5 16:01:48 2022 +0200

    manager: add query sending functionality

commit 25ec9f2
Author: elkanatovey <[email protected]>
Date:   Mon Dec 5 14:24:30 2022 +0200

    manager: add db sending functionality
    marshal: add more marshaling caps + test

commit f901016
Author: Jonathan Weiss <[email protected]>
Date:   Mon Dec 5 09:48:53 2022 +0200

    server main-loop binary supported

commit c6ba581
Author: elkana <[email protected]>
Date:   Sun Dec 4 22:37:03 2022 +0200

    manager.cpp: write galois mapping distribute work

commit 5122396
Author: elkana <[email protected]>
Date:   Sun Dec 4 20:40:08 2022 +0200

    manager.cpp: start galois key mapping
    server.cpp: create mapping logic

commit 19059de
Author: Jonathan Weiss <[email protected]>
Date:   Sun Dec 4 11:58:53 2022 +0200

    renamed clientQueryLedger

commit 1928551
Author: Jonathan Weiss <[email protected]>
Date:   Sun Dec 4 11:53:19 2022 +0200

    fix: shared lock on write

commit e0267a1
Author: Jonathan Weiss <[email protected]>
Date:   Sun Dec 4 11:29:57 2022 +0200

    renamed namespace from pir_primitives to services

commit 24c569f
Author: Jonathan Weiss <[email protected]>
Date:   Sun Dec 4 11:27:53 2022 +0200

    removed unneeded scope

commit 39a3665
Author: Jonathan Weiss <[email protected]>
Date:   Sun Dec 4 11:24:27 2022 +0200

    server: commented out unimplemented code

commit 30e15bc
Author: Jonathan Weiss <[email protected]>
Date:   Sun Dec 4 11:17:56 2022 +0200

    squashed branch:
    - replaced waitGroup with std:latch/
    - mvp reciving worker's local processings.
    - matrix asserting correct access to its data.

commit 8750fbf
Author: elkanatovey <[email protected]>
Date:   Thu Dec 1 18:02:25 2022 +0200

    server: minor refactor

commit 0696f1a
Author: elkanatovey <[email protected]>
Date:   Thu Dec 1 15:37:54 2022 +0200

    server: ledger now more organised

commit 558423a
Author: elkanatovey <[email protected]>
Date:   Thu Dec 1 13:47:02 2022 +0200

    server_service: continue work

commit 7649d7f
Author: elkanatovey <[email protected]>
Date:   Wed Nov 30 18:43:11 2022 +0200

    server: put in stubs for client connections, start work on bookeeping for work distribution

commit 80f53c6
Author: elkanatovey <[email protected]>
Date:   Wed Nov 30 14:22:34 2022 +0200

    server: add rpcs, make implement server from grpc

commit e90160c
Author: elkanatovey <[email protected]>
Date:   Tue Nov 29 16:53:02 2022 +0200

    server_service: start work on db modifying ptxs for between round work

commit e76c080
Author: elkanatovey <[email protected]>
Date:   Tue Nov 29 16:49:16 2022 +0200

    server_service: start work on db modifying ptxs for between round work

* added some comments

* promise struct

* new test

* changed def for async mat-mult

* fx: removed unneeded check

* template fixing

* fix: concurrency issues

* added test

* small refactor to the creation of a FullServer

* concurrency package:
- fix: bug in channel.
- add: threadpool

* thread pool

* promise set option

* matops support receiving an existing threadpool

* expander receives threadpool

* misplaced constructor in tpp

* server fix: construction error, async expander operative

* bug fix: forgot to pass promise to thread

* on new epoch management receives the client db, creates an EpochData instance and stores everything related to the current epoch there

* avoid move

* Second stage pir (#57)

* manager: fix location of commas in test funcs

* evaluator: add ptx decomposition mult

* evaluator:add test for ptx embedding

* evaluator:add ntt transform for EmbeddedCiphertext

* server.cpp: minor change for debug mode

* fix: query_expander construction

* Create fast_test_debug

* Update fast_test_debug

* Before processings (#59)

* channel throws if write on closed

* manager sets up a threadpool

* manager sets up random vector each epoch

* Squashed commit of the following:

commit 6284db7
Merge: 06d979b b75a7d2
Author: Jonathan Weiss <[email protected]>
Date:   Sun Dec 11 14:20:26 2022 +0200

    Merge branch 'dev' of github.com:elkanatovey/distribicom into dev

commit 06d979b
Author: Jonathan Weiss <[email protected]>
Date:   Sun Dec 11 14:20:17 2022 +0200

    fix: query_expander construction

commit b75a7d2
Author: Elkana Tovey <[email protected]>
Date:   Sun Dec 11 14:03:55 2022 +0200

    Second stage pir (#57)

    * manager: fix location of commas in test funcs

    * evaluator: add ptx decomposition mult

    * evaluator:add test for ptx embedding

    * evaluator:add ntt transform for EmbeddedCiphertext

    * server.cpp: minor change for debug mode

* code-style fix

* new epoch async prepares for frievald.

* server.cpp: minor change for debug mode

* added test to async query expansion

* verify the query_x_rand_vec in debug mod

* refactor locking in distribute-work

* client_context.hpp: start refactor of clientDB

* fx: safelatch introduced

* refactor safelatch in its own file

* refactor safelatch in its own file

* client_context.hpp: refactor client setting
manager.hpp: start adding partial work to dbs

* client_context.hpp: minor fix for cmake

* convert client db mutex to pointer

* move ClientDB into manager

* matrix_operations.tpp: fix multiplication bug for regular plaintext case
evaluator_wrapper.cpp: create method for calculating expansion ratio
worker_test.cpp: update according to evaluator wrapper

* query_expander.cpp: add version of expansion that returns query as col vector

* server: factor db into manager
matrix_operations: add sync version of scalar dot product
manager: add sync versions of stage two, freivalds still has bugs

* removed promise-hell

* improved async usage

* server.cpp: add partial answer struct to client
manager.cpp: add method to store partial work, start calculate final answer
worker_test: update per mods to client struct

* refactor: queries_dim2 are now not promised

* fx: ntt form db multiply with query_vec

* ensuring worker-manager ntt forms match

* ntt-forms match

* matrix_operations.hpp: fix for scalar  dot product dims

* worker_test.cpp update test for more general query nums.
manager.hpp: add comment

* ntt query-dim-2

* ledger: added promise for verify_worker

* async-verification

* integrating with current server

* fx: removed comments

* duct-tape without sending responses

* todos

Co-authored-by: Jonathan Weiss <[email protected]>
Co-authored-by: elkana <[email protected]>

* fix: using random to generate the worker credentials

* worker-main

* src/server.cpp add creation of clients

* src/server.cpp add creation of clients

* src/server.cpp add creation of clients

* src/server.cpp add creation of clients

* fx: worker's binary wouldn't stop running.

* Update matrix_operations.hpp

Co-authored-by: elkanatovey <[email protected]>
Co-authored-by: Elkana Tovey <[email protected]>
Co-authored-by: Jonathan Weiss <[email protected]>
  • Loading branch information
4 people authored Dec 14, 2022
1 parent 177ebed commit b4bce21
Show file tree
Hide file tree
Showing 108 changed files with 6,676 additions and 1,111 deletions.
5 changes: 5 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"image": "mcr.microsoft.com/devcontainers/cpp:ubuntu-22.04",
"features": {
}
}
8 changes: 4 additions & 4 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CMake

on:
push:
branches: [ "master", "frievaldsBranch" ]
branches: [ "master" ]
pull_request:
branches: [ "master", "frievaldsBranch" ]
branches: [ "master" ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
Expand All @@ -15,7 +15,7 @@ jobs:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
Expand All @@ -33,5 +33,5 @@ jobs:
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}
run: ctest -C ${{env.BUILD_TYPE}} --test-dir test

48 changes: 48 additions & 0 deletions .github/workflows/fast_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Cmake fast
on:
push:
branches: [ "master", "dev" ]
pull_request:
branches: [ "master", "dev" ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Cache dependencies
id: cache-all-deps
uses: actions/cache@v3
env:
cache-name: cache-dependencies
with:
path: ~/.distribicom_installs
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: install deps
continue-on-error: true
run: bash ${{github.workspace}}/scripts/deps.sh

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_PREINSTALLED_GRPC=ON -DUSE_PRECOMPILED_SEAL=ON -D CMAKE_PREFIX_PATH=~/.distribicom_installs

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --test-dir test
48 changes: 48 additions & 0 deletions .github/workflows/fast_test_debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Cmake fast debug
on:
push:
branches: [ "master", "dev" ]
pull_request:
branches: [ "master", "dev" ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Debug

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Cache dependencies
id: cache-all-deps
uses: actions/cache@v3
env:
cache-name: cache-dependencies
with:
path: ~/.distribicom_installs
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: install deps
continue-on-error: true
run: bash ${{github.workspace}}/scripts/deps.sh

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_PREINSTALLED_GRPC=ON -DUSE_PRECOMPILED_SEAL=ON -D CMAKE_PREFIX_PATH=~/.distribicom_installs

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --test-dir test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ seal_download
CmakeFiles
.idea
.DS_Store
bin
bin
*checks*
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
set(CMAKE_CXX_FLAGS "-Wall -Wextra ")
option(DONT_COMPILE_DEPENDENCIES "GET_SEAL" OFF)

option(USE_PRECOMPILED_SEAL "Use preinstalled seal" OFF)
option(USE_PREINSTALLED_GRPC "Use preinstalled gRPC" OFF)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)

cmake_minimum_required(VERSION 3.20)
project(distribicom VERSION 1.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include_directories("${PROJECT_SOURCE_DIR}/util" "${PROJECT_BINARY_DIR}/util")
add_subdirectory(util)

include(dependencies/FetchDependencies.cmake)

add_subdirectory(src)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

Distribicom is a research library and should not be used in production systems.

-DUSE_PREINSTALLED_GRPC=ON -DUSE_PRECOMPILED_SEAL=ON options for precompiled main library use. Note that Distibicom relies on SEAL compiled with -DSEAL_THROW_ON_TRANSPARENT_CIPHERTEXT=OFF
61 changes: 38 additions & 23 deletions dependencies/FetchDependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
# Store the old value of the 'CMAKE_RUNTIME_OUTPUT_DIRECTORY'
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_OLD ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# Make subproject to use 'BUILD_SHARED_LIBS=ON' setting.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/deps CACHE INTERNAL "send deps binaries off")

message("seal dir is ${SEAL_DIR}")
# get seal if no seal_dir
if((NOT SEAL_DIR) OR GET_SEAL)
message("Getting dependencies... ")
# get dependencies (just seal for now)
configure_file(dependencies/FetchSeal.cmake seal_download/CMakeLists.txt)
if(USE_PRECOMPILED_SEAL)
message(STATUS "cmake prefix path is ${CMAKE_PREFIX_PATH}")
find_package(SEAL 4.0.0 REQUIRED)
else()
message("seal dir is ${SEAL_DIR}")
# get seal if no seal_dir
if((NOT SEAL_DIR))
message("Getting dependencies... ")
# get dependencies (just seal for now)
configure_file(dependencies/FetchSeal.cmake seal_download/CMakeLists.txt)

# get seal
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/seal_download )
if(result)
message(FATAL_ERROR "CMake step for seal failed: ${result}")
endif()
# get seal
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/seal_download )
if(result)
message(FATAL_ERROR "CMake step for seal failed: ${result}")
endif()

# build seal
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/seal_download )
if(result)
message(FATAL_ERROR "Build step for seal failed: ${result}")
# build seal
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/seal_download )
if(result)
message(FATAL_ERROR "Build step for seal failed: ${result}")
endif()
set(SEAL_DIR ${CMAKE_BINARY_DIR}/seal_download/_deps/com_microsoft_seal-build/cmake CACHE STRING "" FORCE)
message("seal dir is ${SEAL_DIR}")
endif()
set(SEAL_DIR ${CMAKE_BINARY_DIR}/seal_download/_deps/com_microsoft_seal-build/cmake CACHE STRING "" FORCE)
find_package(SEAL 4.0.0 REQUIRED PATH ${SEAL_DIR})

message("seal dir is ${SEAL_DIR}")
set(SEAL_DIR ${SEAL_DIR} CACHE STRING "" FORCE)
endif()

message("seal dir is ${SEAL_DIR}")
set(SEAL_DIR ${SEAL_DIR} CACHE STRING "" FORCE)
# get sealpir
include(dependencies/FetchSealPIR.cmake)
include(dependencies/FetchSealPIR.cmake)

include(dependencies/FetchGRPC.cmake)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_OLD} CACHE PATH "send deps binaries off done" FORCE)
58 changes: 58 additions & 0 deletions dependencies/FetchGRPC.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

if(USE_PREINSTALLED_GRPC)
# Find previously-installed gRPC
find_package(Protobuf CONFIG REQUIRED)

message(STATUS "Using protobuf ${Protobuf_VERSION}")

set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
set(_REFLECTION gRPC::grpc++_reflection)
if(CMAKE_CROSSCOMPILING)
find_program(_PROTOBUF_PROTOC protoc)
else()
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
endif()

# Find gRPC installation
# Looks for gRPCConfig.cmake file installed by gRPC's cmake installation.
find_package(gRPC CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")

set(_GRPC_GRPCPP gRPC::grpc++)
if(CMAKE_CROSSCOMPILING)
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
else()
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
endif()

else()
include(FetchContent)
FetchContent_Declare(
gRPC
GIT_REPOSITORY https://github.com/grpc/grpc
GIT_TAG v1.50.1 # e.g v1.28.0
USES_TERMINAL_DOWNLOAD ON
)
set(FETCHCONTENT_QUIET OFF)

if(NOT gRPC_POPULATED)
FetchContent_Populate(gRPC)
add_subdirectory(
${grpc_SOURCE_DIR}
${grpc_BINARY_DIR}
EXCLUDE_FROM_ALL)
endif()


# Since FetchContent uses add_subdirectory under the hood, we can use
# the grpc targets directly from this build.
set(_PROTOBUF_LIBPROTOBUF libprotobuf)
set(_REFLECTION grpc++_reflection)
set(_PROTOBUF_PROTOC $<TARGET_FILE:protoc>)
set(_GRPC_GRPCPP grpc++)
if(CMAKE_CROSSCOMPILING)
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
else()
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:grpc_cpp_plugin>)
endif()
endif()
1 change: 1 addition & 0 deletions dependencies/FetchSeal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project(seal_download NONE)
include(FetchContent)

set(SEAL_THROW_ON_TRANSPARENT_CIPHERTEXT OFF)
set(SEAL_USE_INTEL_HEXL ON)

FetchContent_Declare(
com_microsoft_seal
Expand Down
8 changes: 7 additions & 1 deletion dependencies/FetchSealPIR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ FetchContent_Declare(
USES_TERMINAL_DOWNLOAD ON
)

FetchContent_GetProperties(com_sealpir)

if(NOT com_sealpir_POPULATED)
FetchContent_MakeAvailable(com_sealpir)
FetchContent_Populate(com_sealpir)
add_subdirectory(
${com_sealpir_SOURCE_DIR}
${com_sealpir_BINARY_DIR}
EXCLUDE_FROM_ALL)
endif()
12 changes: 11 additions & 1 deletion remote-compiler/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN apt-get clean


RUN ( \
echo 'LogLevel DEBUG2'; \
echo 'LogLevel ERROR'; \
echo 'PermitRootLogin yes'; \
echo 'PasswordAuthentication yes'; \
echo 'Subsystem sftp /usr/lib/openssh/sftp-server'; \
Expand All @@ -38,5 +38,15 @@ RUN mkdir -p /home/user/.ssh && \
touch /home/user/.ssh/authorized_keys &&\
chmod 666 /home/user/.ssh/authorized_keys

COPY deps.sh /deps.sh
RUN /deps.sh

RUN apt-get install -y vim
RUN apt-get install -y sudo

RUN apt-get install graphviz pip kcachegrind
RUN pip install gprof2dot # ./gprof2dot -f callgrind callgrind.out.x | dot -Tsvg -o output.svg



CMD ["/usr/sbin/sshd", "-D", "-e", "-f", "/etc/ssh/sshd_config_test_clion"]
40 changes: 40 additions & 0 deletions remote-compiler/deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# the below script installs all library dependencies of distribicom other than sealpir to $HOME/.distribicom_installs.
# If you wish to preinstall these libraries and use them to compile distribicom, than run the script and then call
# cmake with the below flags:
# #-DUSE_PREINSTALLED_GRPC=ON -DUSE_PRECOMPILED_SEAL=ON -D CMAKE_PREFIX_PATH=${HOME}/.distribicom_installs

# If you wish to change the install location of the librariesthan just change ${HOME}/.distribicom_installs to your
# preferred location in every place in this file and proceed according to the above instructions.

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

export MY_INSTALL_DIR=$HOME/.distribicom_installs
mkdir -p $MY_INSTALL_DIR
export PATH="$MY_INSTALL_DIR/bin:$PATH"

# install grpc
git clone --recurse-submodules -b v1.50.1 --depth 1 --shallow-submodules https://github.com/grpc/grpc
cd grpc
mkdir -p cmake/build
pushd cmake/build
cmake -DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
../..
make -j6
make install
popd

cd ..
rm -rf grpc

# install seal
git clone --recurse-submodules -b v4.0.0 --depth 1 --shallow-submodules https://github.com/microsoft/SEAL
cd SEAL
cmake -S . -B build -DSEAL_THROW_ON_TRANSPARENT_CIPHERTEXT=OFF -DSEAL_USE_INTEL_HEXL=ON
cmake --build build
cmake --install build
cd ..
rm -rf SEAL
2 changes: 2 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The scripts here are useful for faster compiling and development of the project in the aquarium
environment. For more information read the scripts
Loading

0 comments on commit b4bce21

Please sign in to comment.