Skip to content

Commit

Permalink
feat: version 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PETAce committed Oct 24, 2023
1 parent 0c10ab5 commit 89a68a8
Show file tree
Hide file tree
Showing 60 changed files with 3,843 additions and 84 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@

- Added ECDH-PSI.
- Added CSV data provider.

## Version 0.2.0

### Features

- Added KKRT-PSI
- Added Circuit-PSI
112 changes: 109 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
message(STATUS "Build type (CMAKE_BUILD_TYPE): ${CMAKE_BUILD_TYPE}")

project(SETOPS VERSION 0.1.0 LANGUAGES CXX C)
project(SETOPS VERSION 0.2.0 LANGUAGES CXX C)

########################
# Global configuration #
Expand Down Expand Up @@ -142,6 +142,8 @@ if (NOT SETOPS_AMD64 AND NOT SETOPS_ARM64)
message(FATAL_ERROR "Supported target architectures are x86_64 and arm64")
endif()

add_compile_options(-msse4.2 -Wno-ignored-attributes -mavx)

# Enable test coverage
set(SETOPS_ENABLE_GCOV_STR "Enable gcov")
option(SETOPS_ENABLE_GCOV ${SETOPS_ENABLE_GCOV_STR} OFF)
Expand Down Expand Up @@ -201,7 +203,7 @@ if(NOT TARGET OpenMP::OpenMP_CXX)
endif()

# PETAce-Network::network
find_package(PETAce-Network 0.1 QUIET CONFIG)
find_package(PETAce-Network 0.2 QUIET CONFIG)
if(PETAce-Network_FOUND)
message(STATUS "PETAce-Network: found")
if(PETAce-Network_STATIC_FOUND)
Expand All @@ -225,7 +227,7 @@ else()
endif()

# PETAce-Solo::solo
find_package(PETAce-Solo 0.1 QUIET CONFIG)
find_package(PETAce-Solo 0.2 QUIET CONFIG)
if(PETAce-Solo_FOUND)
message(STATUS "PETAce-Solo: found")
if(PETAce-Solo_STATIC_FOUND)
Expand All @@ -248,6 +250,54 @@ else()
endif()
endif()

# PETAce-Verse::verse
find_package(PETAce-Verse 0.2 QUIET CONFIG)
if(PETAce-Verse_FOUND)
message(STATUS "PETAce-Verse: found")
if(PETAce-Verse_STATIC_FOUND)
set(verse "PETAce-Verse::verse")
else()
set(verse "PETAce-Verse::verse_shared")
endif()
else()
if(SETOPS_BUILD_DEPS)
message(STATUS "PETAce-Verse: download ...")
setops_fetch_thirdparty_content(PETAce-Verse)
if(TARGET verse)
set(verse "verse")
else()
set(verse "verse_shared")
endif()
set(SETOPS_BUILD_VERSE TRUE CACHE BOOL "" FORCE)
else()
message(FATAL_ERROR "PETAce-Verse: not found, please download and install manually")
endif()
endif()

# PETAce-Duet::duet
find_package(PETAce-Duet 0.2 QUIET CONFIG)
if(PETAce-Duet_FOUND)
message(STATUS "PETAce-Duet: found")
if(PETAce-Duet_STATIC_FOUND)
set(duet "PETAce-Duet::duet")
else()
set(duet "PETAce-Duet::duet_shared")
endif()
else()
if(SETOPS_BUILD_DEPS)
message(STATUS "PETAce-Duet: download ...")
setops_fetch_thirdparty_content(PETAce-Duet)
if(TARGET duet)
set(duet "duet")
else()
set(duet "duet_shared")
endif()
set(SETOPS_BUILD_DUET TRUE CACHE BOOL "" FORCE)
else()
message(FATAL_ERROR "PETAce-Duet: not found, please download and install manually")
endif()
endif()

# glog::glog
find_package(glog 0.4.0 QUIET CONFIG)
if(glog_FOUND)
Expand Down Expand Up @@ -335,6 +385,24 @@ if(NOT SETOPS_BUILD_SHARED_LIBS)
target_link_libraries(setops PUBLIC ${solo})
set(SETOPS_CARRY_SOLO FALSE)

if(SETOPS_BUILD_VERSE)
add_dependencies(setops ${verse})
target_include_directories(setops PUBLIC
$<BUILD_INTERFACE:$<TARGET_PROPERTY:${verse},INTERFACE_INCLUDE_DIRECTORIES>>
$<INSTALL_INTERFACE:${SETOPS_INCLUDES_INSTALL_DIR}>)
endif()
target_link_libraries(setops PUBLIC ${verse})
set(SETOPS_CARRY_VERSE FALSE)

if(SETOPS_BUILD_DUET)
add_dependencies(setops ${duet})
target_include_directories(setops PUBLIC
$<BUILD_INTERFACE:$<TARGET_PROPERTY:${duet},INTERFACE_INCLUDE_DIRECTORIES>>
$<INSTALL_INTERFACE:${SETOPS_INCLUDES_INSTALL_DIR}>)
endif()
target_link_libraries(setops PUBLIC ${duet} m)
set(SETOPS_CARRY_DUET FALSE)

target_link_libraries(setops PUBLIC nlohmann_json::nlohmann_json)
target_link_libraries(setops PUBLIC Threads::Threads OpenMP::OpenMP_CXX)

Expand Down Expand Up @@ -386,6 +454,24 @@ else()
target_link_libraries(setops_shared PUBLIC ${solo})
set(SETOPS_CARRY_SOLO FALSE)

if(SETOPS_BUILD_VERSE)
add_dependencies(setops_shared ${verse})
target_include_directories(setops_shared PUBLIC
$<BUILD_INTERFACE:$<TARGET_PROPERTY:${verse},INTERFACE_INCLUDE_DIRECTORIES>>
$<INSTALL_INTERFACE:${SETOPS_INCLUDES_INSTALL_DIR}>)
endif()
target_link_libraries(setops_shared PUBLIC ${verse})
set(SETOPS_CARRY_VERSE FALSE)

if(SETOPS_BUILD_DUET)
add_dependencies(setops_shared ${duet})
target_include_directories(setops_shared PUBLIC
$<BUILD_INTERFACE:$<TARGET_PROPERTY:${duet},INTERFACE_INCLUDE_DIRECTORIES>>
$<INSTALL_INTERFACE:${SETOPS_INCLUDES_INSTALL_DIR}>)
endif()
target_link_libraries(setops_shared PUBLIC ${duet} m)
set(SETOPS_CARRY_DUET FALSE)

target_link_libraries(setops_shared PUBLIC nlohmann_json::nlohmann_json)
target_link_libraries(setops_shared PUBLIC Threads::Threads OpenMP::OpenMP_CXX)

Expand Down Expand Up @@ -448,6 +534,12 @@ if(SETOPS_BUILD_DEPS)
if(SETOPS_BUILD_SOLO)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} --build ${solo_BINARY_DIR} -t install)")
endif()
if(SETOPS_BUILD_VERSE)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} --build ${verse_BINARY_DIR} -t install)")
endif()
if(SETOPS_BUILD_DUET)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} --build ${duet_BINARY_DIR} -t install)")
endif()
if(SETOPS_BUILD_NETWORK)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} --build ${network_BINARY_DIR} -t install)")
endif()
Expand Down Expand Up @@ -483,3 +575,17 @@ if(SETOPS_BUILD_TEST)
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
endif()
endif()

##################
# SETOPS python #
##################

# [OPTION] SETOPS_BUILD_PYTHON (DEFAULT: OFF)
# Build a shared library if set to ON.
set(SETOPS_BUILD_PYTHON_STR "Build python shared library")
option(SETOPS_BUILD_PYTHON ${SETOPS_BUILD_PYTHON_STR} OFF)
message(STATUS "SETOPS_BUILD_PYTHON: ${SETOPS_BUILD_PYTHON}")

if(SETOPS_BUILD_PYTHON)
add_subdirectory(python)
endif()
43 changes: 32 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@
PETAce-SetOps is a collection of protocols that perform private set operations.
It is one of the many components in [the framework PETAce](https://github.com/tiktok-privacy-innovation/PETAce).

Private set operations generally include private set intersection(PSI), private join and compute(PJC), and private information retrieval(PIR) protocols.
Currently, PETAce-SetOps implements a PSI protocol based on Elliptic-Curve Diffie-Hellman (ECDH-PSI).
Private set operations generally include private set intersection (PSI), private join and compute (PJC), and private information retrieval (PIR) protocols.
Currently, PETAce-SetOps implements the ECDH-PSI protocol based on Elliptic-Curve Diffie-Hellman, the [KKRT-PSI](https://dl.acm.org/doi/abs/10.1145/2976749.2978381) protocol based on Oblivious Pseudorandom Functions (OPRF), and the PJC protocol based on [Circuit-PSI](https://www.researchgate.net/publication/356421123_Circuit-PSI_With_Linear_Complexity_via_Relaxed_Batch_OPPRF).

## Requirements

| System | Toolchain |
|--------|-------------------------------------------------------|
| Linux | Clang++ (>= 5.0) or GNU G++ (>= 5.5), CMake (>= 3.15) |

| Required dependency | Tested version | Use |
|--------------------------------------------------------------------------------|----------------|---------------------------------|
| [PETAce-Solo](https://github.com/tiktok-privacy-innovation/PETAce-Solo) | 0.1.0 | Cryptography primitives |
| [PETAce-Network](https://github.com/tiktok-privacy-innovation/PETAce-Network) | 0.1.0 | Network communication protocols |
| [Google Logging](https://github.com/google/glog) | 0.4.0 | Logging |
| [JSON for Modern C++(JSON)](https://github.com/nlohmann/json) | 3.10.1 | PSI parameter configuration |
| Required dependency | Tested version | Use |
|--------------------------------------------------------------------------------|----------------|--------------------------------------|
| [PETAce-Solo](https://github.com/tiktok-privacy-innovation/PETAce-Solo) | 0.2.0 | Cryptography primitives |
| [PETAce-Verse](https://github.com/tiktok-privacy-innovation/PETAce-Verse) | 0.2.0 | Primitive cryptographic protocols |
| [PETAce-Duet](https://github.com/tiktok-privacy-innovation/PETAce-Duet) | 0.2.0 | Two-party secure computing protocols |
| [PETAce-Network](https://github.com/tiktok-privacy-innovation/PETAce-Network) | 0.2.0 | Network communication protocols |
| [Google Logging](https://github.com/google/glog) | 0.4.0 | Logging |
| [JSON for Modern C++(JSON)](https://github.com/nlohmann/json) | 3.10.1 | PSI parameter configuration |

| Optional dependency | Tested version | Use |
|----------------------------------------------------|----------------|------------------------|
Expand Down Expand Up @@ -55,6 +57,18 @@ Output binaries can be found in `build/lib/` and `build/bin/` directories.
| `SETOPS_BUILD_TEST` | ON/OFF | ON | Build C++ test if set to ON. |
| `SETOPS_BUILD_DEPS` | ON/OFF | ON | Download and build unmet dependencies if set to ON. |

### Building python
To build PETAce-Setops python package:

```bash
cmake -S . -B build -DDUET_BUILD_PYTHON=ON -Dnlohmann_json_DIR=${JSON}/build
cmake --build build
cd build
make wheel
cd python/wheel
pip3 install petace_setops-0.2.0-py3-none-any.whl
```

Here we give a simple example to run protocols in PETAce-SetOps.

To run as Party A (a sender):
Expand All @@ -69,6 +83,13 @@ To run as Party B (a receiver):
bash build/example/scripts/ecdh_psi_receiver_example.sh
```

To run python examples, execute the following in commands in separate terminal sessions.

```bash
python3 ./example/setops_example.py -p 0
python3 ./example/setops_example.py -p 1
```

## Contribution

Please check [Contributing](CONTRIBUTING.md) for more details.
Expand All @@ -85,13 +106,13 @@ This project is licensed under the [Apache-2.0 License](LICENSE).

To cite PETAce in academic papers, please use the following BibTeX entries.

### Version 0.1.0
### Version 0.2.0

```tex
@misc{petace,
title = {PETAce (release 0.1.0)},
title = {PETAce (release 0.2.0)},
howpublished = {\url{https://github.com/tiktok-privacy-innovation/PETAce}},
month = July,
month = Oct,
year = 2023,
note = {TikTok Pte. Ltd.},
key = {PETAce}
Expand Down
32 changes: 32 additions & 0 deletions cmake/ExternalPybind11.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2023 TikTok Pte. Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.11.1
)
FetchContent_GetProperties(pybind11)

if(NOT pybind11_POPULATED)
FetchContent_Populate(pybind11)

mark_as_advanced(FETCHCONTENT_SOURCE_DIR_PYBIND11)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_PYBIND11)

add_subdirectory(
${pybind11_SOURCE_DIR}
${THIRDPARTY_BINARY_DIR}/pybind11-build
EXCLUDE_FROM_ALL)
endif()
37 changes: 37 additions & 0 deletions cmake/PETAce-Duet.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2023 TikTok Pte. Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FetchContent_Declare(
duet
GIT_REPOSITORY https://github.com/tiktok-privacy-innovation/PETAce-Duet.git
GIT_TAG be580aded7b037491d481cb6d03f52cc91d6554d # 0.2.0
)
FetchContent_GetProperties(duet)

if(NOT duet_POPULATED)
FetchContent_Populate(duet)

set(DUET_BUILD_SHARED_LIBS ${SETOPS_BUILD_SHARED_LIBS} CACHE BOOL "" FORCE)
set(DUET_BUILD_TEST OFF CACHE BOOL "" FORCE)
set(DUET_BUILD_BENCH OFF CACHE BOOL "" FORCE)
set(DUET_BUILD_EXAMPLE OFF CACHE BOOL "" FORCE)

mark_as_advanced(FETCHCONTENT_SOURCE_DIR_DUET)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_DUET)

add_subdirectory(
${duet_SOURCE_DIR}
${duet_SOURCE_DIR}/../duet-build
EXCLUDE_FROM_ALL)
endif()
4 changes: 2 additions & 2 deletions cmake/PETAce-Network.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

FetchContent_Declare(
network
GIT_REPOSITORY git@github.com:tiktok-privacy-innovation/PETAce-Network.git
GIT_TAG 096245f85cec4d0065488225bf1b2f1dc979efb2 # v0.1.0
GIT_REPOSITORY https://github.com/tiktok-privacy-innovation/PETAce-Network.git
GIT_TAG 92d1a6f079cd11e01bc8e610cb92126ede2964b1 # 0.2.0
)
FetchContent_GetProperties(network)

Expand Down
10 changes: 10 additions & 0 deletions cmake/PETAce-SetOpsConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ set(SETOPS_BUILD_TYPE @CMAKE_BUILD_TYPE@)
set(SETOPS_CARRY_GLOG @SETOPS_CARRY_GLOG@)
set(SETOPS_CARRY_NETWORK @SETOPS_CARRY_NETWORK@)
set(SETOPS_CARRY_SOLO @SETOPS_CARRY_SOLO@)
set(SETOPS_CARRY_VERSE @SETOPS_CARRY_VERSE@)
set(SETOPS_CARRY_DUET @SETOPS_CARRY_DUET@)

setops_find_dependency(OpenMP REQUIRED)
setops_find_dependency(nlohmann_json REQUIRED)
Expand All @@ -58,6 +60,14 @@ if(NOT SETOPS_CARRY_SOLO)
setops_find_dependency(PETAce-Solo REQUIRED)
endif()

if(NOT SETOPS_CARRY_VERSE)
setops_find_dependency(PETAce-Verse REQUIRED)
endif()

if(NOT SETOPS_CARRY_DUET)
setops_find_dependency(PETAce-Duet REQUIRED)
endif()

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
setops_find_dependency(Threads)
Expand Down
5 changes: 3 additions & 2 deletions cmake/PETAce-Solo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

FetchContent_Declare(
solo
GIT_REPOSITORY git@github.com:tiktok-privacy-innovation/PETAce-Solo.git
GIT_TAG 471d70069a684a23b6c11319643a73e005547a01 # dev
GIT_REPOSITORY https://github.com/tiktok-privacy-innovation/PETAce-Solo.git
GIT_TAG ead22f615120a0cd9926cfc5d5787fe4bcda379c # 0.2.0
)
FetchContent_GetProperties(solo)

Expand All @@ -26,6 +26,7 @@ if(NOT solo_POPULATED)
set(SOLO_BUILD_TEST OFF CACHE BOOL "" FORCE)
set(SOLO_BUILD_BENCH OFF CACHE BOOL "" FORCE)
set(SOLO_BUILD_EXAMPLE OFF CACHE BOOL "" FORCE)
set(SOLO_USE_IPCL ON CACHE BOOL "" FORCE)

mark_as_advanced(FETCHCONTENT_SOURCE_DIR_SOLO)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_SOLO)
Expand Down
Loading

0 comments on commit 89a68a8

Please sign in to comment.