Skip to content

Commit

Permalink
feat: version 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PETAce committed Jan 23, 2025
1 parent a1713d7 commit 018c1b8
Show file tree
Hide file tree
Showing 39 changed files with 3,150 additions and 180 deletions.
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
default_language_version:
# force all unspecified python hooks to run python3
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@
- Added support for dual Paillier backends: GMP-based Paillier implementation and IPCL-based Paillier implementation.
- Refactored code structure for Duet.
- Added benchmark for Duet.

## Version 0.4.0

### Features

- Optimized comparison operators.
- Added oblivious switching network (OSN) protocol from https://eprint.iacr.org/2021/243 and https://eprint.iacr.org/2013/137.
- Added Discrete Gaussian Sampling protocol from [Securely Sampling Discrete Gaussian Noise for Multi-Party Differential Privacy](https://dl.acm.org/doi/abs/10.1145/3576915.3616641).
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
message(STATUS "Build type (CMAKE_BUILD_TYPE): ${CMAKE_BUILD_TYPE}")

project(DUET VERSION 0.3.0 LANGUAGES CXX C)
project(DUET VERSION 0.4.0 LANGUAGES CXX C)

########################
# Global configuration #
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ As implied by the name "Duet", PETAce-Duet implements various two-party MPC prot

- [Secret shared shuffle](https://link.springer.com/chapter/10.1007/978-3-030-64840-4_12). The permutation network will be available in a future release.

- [Oblivious switching network](https://eprint.iacr.org/2021/243.pdf) with the random OT optimizations.

- Homomorphic Encryption (HE): Duet integrates the Paillier cryptosystem to improve two-party secure computation.
For example, HE enables efficient alternative solutions to problems such as secure shuffling and linear matrix operations.
A generic implementation of the Paillier cryptosystem based on the GMP library is provided in PETAce-Solo.
Expand All @@ -24,6 +26,8 @@ We support the conversion between HE ciphertexts and arithmetic shares. As a res
- Fully Homomorphic Encryption (FHE): Duet integrates the BFV scheme to improve two-party Beaver triple generation.
The underlying BFV functionalities depend on Microsoft SEAL.

- Discrete Gaussian Sampling: Duet leverages MPC to sample random noise according to Discrete Gaussian distribution and outputs the noise in the form of secret sharing.

The core functionalities of Duet are written in C++ to provide the best performance.
A Python interface is provided in [PETAce](https://github.com/tiktok-privacy-innovation/PETAce).

Expand All @@ -42,9 +46,9 @@ A Python interface is provided in [PETAce](https://github.com/tiktok-privacy-inn
| [Eigen](https://gitlab.com/libeigen/eigen) | 3.4.0 | Matrix and vector templates |
| [Intel Paillier Cryptosystem Library (IPCL)](https://github.com/intel/pailliercryptolib) | 2.0.0 | Paillier Encryption |
| [Microsoft SEAL](https://github.com/microsoft/SEAL) | 4.1.0 | Fully homomorphic encryption |
| [PETAce-Solo](https://github.com/tiktok-privacy-innovation/PETAce-Solo) | 0.3.0 | Cryptography primitives |
| [PETAce-Network](https://github.com/tiktok-privacy-innovation/PETAce-Network) | 0.3.0 | Network communication protocols |
| [PETAce-Verse](https://github.com/tiktok-privacy-innovation/PETAce-Verse) | 0.3.0 | Primitive cryptographic protocols |
| [PETAce-Solo](https://github.com/tiktok-privacy-innovation/PETAce-Solo) | 0.4.0 | Cryptography primitives |
| [PETAce-Network](https://github.com/tiktok-privacy-innovation/PETAce-Network) | 0.4.0 | Network communication protocols |
| [PETAce-Verse](https://github.com/tiktok-privacy-innovation/PETAce-Verse) | 0.4.0 | Primitive cryptographic protocols |

| Optional dependency | Tested version | Use |
|--------------------------------------------------------|----------------|------------------------|
Expand Down Expand Up @@ -117,14 +121,14 @@ 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.3.0
### Version 0.4.0

```tex
@misc{petace,
title = {PETAce (release 0.3.0)},
title = {PETAce (release 0.4.0)},
howpublished = {\url{https://github.com/tiktok-privacy-innovation/PETAce}},
month = Jun,
year = 2024,
month = Jan,
year = 2025,
note = {TikTok Pte. Ltd.},
key = {PETAce}
}
Expand Down
4 changes: 2 additions & 2 deletions bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

cmake_minimum_required(VERSION 3.14)

project(DUETBench VERSION 0.3.0 LANGUAGES CXX)
project(DUETBench VERSION 0.4.0 LANGUAGES CXX)

# If not called from root CMakeLists.txt
if(NOT DEFINED DUET_BUILD_BENCH)
set(DUET_BUILD_BENCH ON)

find_package(PETAce-Duet 0.3.0 EXACT REQUIRED)
find_package(PETAce-Duet 0.4.0 EXACT REQUIRED)

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

Expand Down
6 changes: 4 additions & 2 deletions bench/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class LogToFileSink : public google::LogSink {
log_file_.close();
}

void send(google::LogSeverity severity, const char* full_filename, const char* base_filename, int line,
const struct ::tm* tm_time, const char* message, size_t message_len) override {
void send(google::LogSeverity /*severity*/, const char* /*full_filename*/, const char* /*base_filename*/,
int /*line*/, const struct ::tm* /*tm_time*/, const char* message, size_t message_len) override {
log_file_.write(message, message_len);
log_file_.put('\n');
log_file_.flush();
Expand Down Expand Up @@ -125,6 +125,8 @@ int main(int argc, char** argv) {
equal_bench(net, duet, test_number, 100, 100);
} else if (test_case == "less") {
less_bench(net, duet, test_number, 100, 100);
} else if (test_case == "less_with_ot") {
less_with_ot_bench(net, duet, test_number, 100, 100);
} else if (test_case == "greater") {
greater_bench(net, duet, test_number, 100, 100);
} else if (test_case == "less_than_zero") {
Expand Down
41 changes: 41 additions & 0 deletions bench/duet_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,47 @@ void less_bench(const std::shared_ptr<petace::network::Network>& net, const std:
}
}

void less_with_ot_bench(const std::shared_ptr<petace::network::Network>& net,
const std::shared_ptr<petace::duet::Duet>& duet, std::size_t test_number, std::size_t rows, std::size_t cols) {
try {
std::size_t size = rows * cols;

petace::duet::PrivateMatrix<double> private_0(rows, cols, 0);
petace::duet::PrivateMatrix<double> private_1(rows, cols, 1);
petace::duet::PrivateMatrix<double> ret(rows, cols, 0);
if (duet->party() == 0) {
for (std::size_t i = 0; i < size; i++) {
private_0(i) = static_cast<double>(i);
}
} else {
for (std::size_t i = 0; i < size; i++) {
private_1(i) = static_cast<double>(i + i % 2);
}
}

petace::duet::ArithMatrix cipher0(rows, cols);
petace::duet::ArithMatrix cipher1(rows, cols);
petace::duet::BoolMatrix cipher2(rows, cols);

duet->share(net, private_0, cipher0);
duet->share(net, private_1, cipher1);

double begin = get_unix_timestamp();
LOG(INFO) << std::fixed << "case less_with_ot" << rows << "_" << cols << "_bench"
<< " begin " << begin << " " << test_number << " " << rows << " " << cols;
for (size_t i = 0; i < test_number; i++) {
duet->less_with_ot(net, cipher0, cipher1, cipher2);
}
double end = get_unix_timestamp();

LOG(INFO) << std::fixed << "case less_with_ot" << rows << "_" << cols << "_bench"
<< " end " << end << " " << end - begin << "s " << net->get_bytes_sent() << " "
<< net->get_bytes_received();
} catch (const std::exception& e) {
std::cerr << e.what() << '\n';
}
}

void less_than_zero_bench(const std::shared_ptr<petace::network::Network>& net,
const std::shared_ptr<petace::duet::Duet>& duet, std::size_t test_number, std::size_t rows, std::size_t cols) {
try {
Expand Down
3 changes: 3 additions & 0 deletions bench/duet_bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@ void greater_bench(const std::shared_ptr<petace::network::Network>& net,
void less_bench(const std::shared_ptr<petace::network::Network>& net, const std::shared_ptr<petace::duet::Duet>& duet,
std::size_t test_number, std::size_t rows, std::size_t cols);

void less_with_ot_bench(const std::shared_ptr<petace::network::Network>& net,
const std::shared_ptr<petace::duet::Duet>& duet, std::size_t test_number, std::size_t rows, std::size_t cols);

void less_than_zero_bench(const std::shared_ptr<petace::network::Network>& net,
const std::shared_ptr<petace::duet::Duet>& duet, std::size_t test_number, std::size_t rows, std::size_t cols);
2 changes: 1 addition & 1 deletion cmake/PETAce-Network.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
FetchContent_Declare(
network
GIT_REPOSITORY https://github.com/tiktok-privacy-innovation/PETAce-Network.git
GIT_TAG 1952a0e0b061c5b43a7fbe5b8d71365abc5382a4 # 0.3.0
GIT_TAG 2842a3814e384140de58efc211cb0cdb02d8b2b9 # 0.4.0
)
FetchContent_GetProperties(network)

Expand Down
2 changes: 1 addition & 1 deletion cmake/PETAce-Solo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
FetchContent_Declare(
solo
GIT_REPOSITORY https://github.com/tiktok-privacy-innovation/PETAce-Solo.git
GIT_TAG 60c6301802040f622d30c148ab49ad42f5b0e3d2 # 0.3.0
GIT_TAG 069ae987a1fafe77be3d5d7b5bcdd20697ced378 # 0.4.0
)
FetchContent_GetProperties(solo)

Expand Down
2 changes: 1 addition & 1 deletion cmake/PETAce-Verse.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
FetchContent_Declare(
verse
GIT_REPOSITORY https://github.com/tiktok-privacy-innovation/PETAce-Verse.git
GIT_TAG 34ffb78e122805f5358cb77ae0ce2bb6f6241060 # 0.3.0
GIT_TAG 1514f98f6bee3cfaaadd919e2f4f1e45c80f6e62 # 0.4.0
)
FetchContent_GetProperties(verse)

Expand Down
4 changes: 2 additions & 2 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

cmake_minimum_required(VERSION 3.14)

project(DUETExample VERSION 0.3.0 LANGUAGES CXX)
project(DUETExample VERSION 0.4.0 LANGUAGES CXX)

# If not called from root CMakeLists.txt
if(NOT DEFINED DUET_BUILD_EXAMPLE)
set(DUET_BUILD_EXAMPLE ON)

# Import PETAce DUET
find_package(PETAce-Duet 0.3.0 EXACT REQUIRED)
find_package(PETAce-Duet 0.4.0 EXACT REQUIRED)

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

Expand Down
1 change: 1 addition & 0 deletions src/duet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set(DUET_SOURCE_FILES ${DUET_SOURCE_FILES}
${CMAKE_CURRENT_LIST_DIR}/duet_sql.cpp
${CMAKE_CURRENT_LIST_DIR}/duet_he.cpp
${CMAKE_CURRENT_LIST_DIR}/duet_stats.cpp
${CMAKE_CURRENT_LIST_DIR}/duet_dp.cpp
)

# Add header files for installation
Expand Down
22 changes: 12 additions & 10 deletions src/duet/beaver_triple/arithmetic_triple_ot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ std::vector<std::int64_t> ArithmeticTripleOT::get_rand_triple(const std::shared_
if (rand_triple_idx_ >= rand_triple_buff_.size()) {
refill_rand_triple_buffer(net);
}
std::vector<std::int64_t> ret;
ret.emplace_back(rand_triple_buff_[rand_triple_idx_][0]);
ret.emplace_back(rand_triple_buff_[rand_triple_idx_][1]);
ret.emplace_back(rand_triple_buff_[rand_triple_idx_][2]);
std::vector<std::int64_t> ret(3);
ret[0] = rand_triple_buff_[rand_triple_idx_][0];
ret[1] = rand_triple_buff_[rand_triple_idx_][1];
ret[2] = rand_triple_buff_[rand_triple_idx_][2];
rand_triple_idx_++;
return ret;
}
Expand Down Expand Up @@ -107,15 +107,17 @@ void ArithmeticTripleOT::gen_rand_triple(const std::shared_ptr<network::Network>

if (party_id_ == 0) {
for (std::size_t i = 0; i < rtp_size; i++) {
rand_triple_buff_[i].emplace_back(a0[i]);
rand_triple_buff_[i].emplace_back(b0[i]);
rand_triple_buff_[i].emplace_back(a0[i] * b0[i] + t0[i] + q0[i]);
rand_triple_buff_[i].resize(3);
rand_triple_buff_[i][0] = a0[i];
rand_triple_buff_[i][1] = b0[i];
rand_triple_buff_[i][2] = a0[i] * b0[i] + t0[i] + q0[i];
}
} else {
for (std::size_t i = 0; i < rtp_size; i++) {
rand_triple_buff_[i].emplace_back(a1[i]);
rand_triple_buff_[i].emplace_back(b1[i]);
rand_triple_buff_[i].emplace_back(a1[i] * b1[i] + t1[i] + q1[i]);
rand_triple_buff_[i].resize(3);
rand_triple_buff_[i][0] = a1[i];
rand_triple_buff_[i][1] = b1[i];
rand_triple_buff_[i][2] = a1[i] * b1[i] + t1[i] + q1[i];
}
}
return;
Expand Down
Loading

0 comments on commit 018c1b8

Please sign in to comment.