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 2e71d76 commit f79ede7
Show file tree
Hide file tree
Showing 19 changed files with 835 additions and 28 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@

- Added Naor-Pinkas oblivious transfer.
- Added IKNP oblivious transfer extension.

## Version 0.2.0

### Features

- Added KKRT oblivious transfer.
6 changes: 3 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(VERSE VERSION 0.1.0 LANGUAGES CXX C)
project(VERSE VERSION 0.2.0 LANGUAGES CXX C)

########################
# Global configuration #
Expand Down Expand Up @@ -193,7 +193,7 @@ if(NOT TARGET Threads::Threads)
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 @@ -217,7 +217,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 Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It is one of the many components in [the framework PETAce](https://github.com/ti

PETAce-Verse implements frequently, repeatedly called subprotocols, as implied by the same "Verse".
Examples are oblivious transfer, oblivious pseudorandom functions, (vector) oblivious linear evaluation, etc.
Currently, PETAce-Verse includes: [Naor-Pinkas OT](https://dl.acm.org/doi/10.5555/365411.365502) and [IKNP OT](https://link.springer.com/chapter/10.1007/978-3-540-45146-4_9) with [optimization](https://link.springer.com/article/10.1007/s00145-016-9236-6).
Currently, PETAce-Verse includes: [Naor-Pinkas OT](https://dl.acm.org/doi/10.5555/365411.365502), [IKNP OT](https://link.springer.com/chapter/10.1007/978-3-540-45146-4_9) with [optimization](https://link.springer.com/article/10.1007/s00145-016-9236-6), and [KKRT OT](https://dl.acm.org/doi/abs/10.1145/2976749.2978381).

## Requirements

Expand All @@ -17,8 +17,8 @@ Currently, PETAce-Verse includes: [Naor-Pinkas OT](https://dl.acm.org/doi/10.555

| 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 |
| [PETAce-Solo](https://github.com/tiktok-privacy-innovation/PETAce-Solo) | 0.2.0 | Cryptography primitives |
| [PETAce-Network](https://github.com/tiktok-privacy-innovation/PETAce-Network) | 0.2.0 | Network communication protocols |

| Optional dependency | Tested version | Use |
|----------------------------------------------------|----------------|-------------------|
Expand Down Expand Up @@ -75,13 +75,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
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
4 changes: 2 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 # v0.1.0
GIT_REPOSITORY https://github.com/tiktok-privacy-innovation/PETAce-Solo.git
GIT_TAG ead22f615120a0cd9926cfc5d5787fe4bcda379c # 0.2.0
)
FetchContent_GetProperties(solo)

Expand Down
5 changes: 3 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(VERSEExamples VERSION 0.1.0 LANGUAGES CXX)
project(VERSEExamples VERSION 0.2.0 LANGUAGES CXX)

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

# Import Microsoft VERSE
find_package(PETAce-Verse 0.1.0 EXACT REQUIRED)
find_package(PETAce-Verse 0.2.0 EXACT REQUIRED)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
endif()
Expand All @@ -33,6 +33,7 @@ if(VERSE_BUILD_EXAMPLE)
set(PETACE_VERSE_EXAMPLE_FILES ${PETACE_VERSE_EXAMPLE_FILES}
${CMAKE_CURRENT_LIST_DIR}/example.cpp
${CMAKE_CURRENT_LIST_DIR}/iknp_ot_example.cpp
${CMAKE_CURRENT_LIST_DIR}/kkrt_ot_example.cpp
${CMAKE_CURRENT_LIST_DIR}/np_ot_example.cpp
)

Expand Down
23 changes: 14 additions & 9 deletions example/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ int main(int argc, char* argv[]) {
throw std::runtime_error("Parameters are incorrect!");
}
while (true) {
std::cout << "+---------------------------------------------------------+" << std::endl;
std::cout << "| The following examples should be executed while reading |" << std::endl;
std::cout << "| comments in associated files in examples/. |" << std::endl;
std::cout << "+---------------------------------------------------------+" << std::endl;
std::cout << "| Examples | Source Files |" << std::endl;
std::cout << "+----------------------------+----------------------------+" << std::endl;
std::cout << "| 1. Naor Pinkas OT | np_ot_example.cpp |" << std::endl;
std::cout << "| 2. IKNP OT | iknp_ot_example.cpp |" << std::endl;
std::cout << "+----------------------------+----------------------------+" << std::endl;
std::cout << "+--------------------------------------------------------------------+" << std::endl;
std::cout << "| The following examples should be executed while reading |" << std::endl;
std::cout << "| comments in associated files in examples/. |" << std::endl;
std::cout << "+--------------------------------------------------------------------+" << std::endl;
std::cout << "| Examples | Source Files |" << std::endl;
std::cout << "+----------------------------+---------------------------------------+" << std::endl;
std::cout << "| 1. Naor Pinkas OT | np_ot_example.cpp |" << std::endl;
std::cout << "| 2. IKNP 1-out-of-2 OT | iknp_ot_example.cpp |" << std::endl;
std::cout << "| 3. KKRT 1-out-of-n OT | kkrt_ot_example.cpp |" << std::endl;
std::cout << "+----------------------------+---------------------------------------+" << std::endl;

int selection = 0;
std::cin >> selection;
Expand All @@ -43,6 +44,10 @@ int main(int argc, char* argv[]) {
iknp_ot_example(
atoi(argv[5]), std::string(argv[1]), atoi(argv[2]), std::string(argv[3]), atoi(argv[4]));
break;
case 3:
kkrt_ot_example(
atoi(argv[5]), std::string(argv[1]), atoi(argv[2]), std::string(argv[3]), atoi(argv[4]));
break;
case 0:
return 0;
}
Expand Down
3 changes: 3 additions & 0 deletions example/example.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ void np_ot_example(std::size_t party_id, std::string local_addr, std::size_t loc

void iknp_ot_example(std::size_t party_id, std::string local_addr, std::size_t local_port, std::string remote_addr,
std::size_t remote_port);

void kkrt_ot_example(std::size_t party_id, std::string local_addr, std::size_t local_port, std::string remote_addr,
std::size_t remote_port);
84 changes: 84 additions & 0 deletions example/kkrt_ot_example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// 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.

#include <iostream>
#include <vector>

#include "example.h"

#include "network/net_factory.h"

#include "verse/util/common.h"
#include "verse/verse_factory.h"

void kkrt_ot_example(std::size_t party_id, std::string local_addr, std::size_t local_port, std::string remote_addr,
std::size_t remote_port) {
petace::network::NetParams net_params;
net_params.remote_addr = remote_addr;
net_params.remote_port = static_cast<std::uint16_t>(remote_port);
net_params.local_addr = local_addr;
net_params.local_port = static_cast<std::uint16_t>(local_port);
auto net = petace::network::NetFactory::get_instance().build(petace::network::NetScheme::SOCKET, net_params);

petace::verse::VerseParams params;
params.base_ot_sizes = 512;
params.ext_ot_sizes = 1024;
std::vector<petace::verse::block> base_recv_ots;
std::vector<std::array<petace::verse::block, 2>> base_send_ots;
std::vector<petace::verse::block> base_choices;
std::vector<petace::verse::block> ext_choices;
for (std::size_t i = 0; i < 4; i++) {
base_choices.emplace_back(petace::verse::read_block_from_dev_urandom());
}
for (std::size_t i = 0; i < params.ext_ot_sizes; i++) {
ext_choices.emplace_back(_mm_set_epi64x(0, i));
}

auto npot_sender = petace::verse::VerseFactory<petace::verse::BaseOtSender>::get_instance().build(
petace::verse::OTScheme::NaorPinkasSender, params);
auto npot_receiver = petace::verse::VerseFactory<petace::verse::BaseOtReceiver>::get_instance().build(
petace::verse::OTScheme::NaorPinkasReceiver, params);
auto kkrt_sender = petace::verse::VerseFactory<petace::verse::NcoOtExtSender>::get_instance().build(
petace::verse::OTScheme::KkrtSender, params);
auto kkrt_receiver = petace::verse::VerseFactory<petace::verse::NcoOtExtReceiver>::get_instance().build(
petace::verse::OTScheme::KkrtReceiver, params);

std::vector<petace::verse::block> recv_msgs;
if (party_id == 0) {
npot_receiver->receive(net, base_choices, base_recv_ots);
kkrt_sender->set_base_ots(base_choices, base_recv_ots);
kkrt_sender->send(net, params.ext_ot_sizes);

std::cout << "sender messages" << std::endl;
petace::verse::block output;
for (std::size_t i = 0; i < 16; i++) {
std::cout << std::dec << "ot index: " << i << std::endl;
for (std::size_t j = 0; j < 16; j++) {
kkrt_sender->encode(i, _mm_set_epi64x(0, j), output);
std::cout << std::hex << output[0] << "|" << output[1] << std::endl;
}
std::cout << std::endl;
}
} else {
npot_sender->send(net, base_send_ots);
kkrt_receiver->set_base_ots(base_send_ots);
kkrt_receiver->receive(net, ext_choices, recv_msgs);
std::cout << "reciver messages" << std::endl;
for (std::size_t i = 0; i < 16; i++) {
std::cout << std::dec << "ot index: " << i << std::endl;
std::cout << std::hex << recv_msgs[i][0] << "|" << recv_msgs[i][1] << "--" << ext_choices[i][0]
<< std::endl;
}
}
}
1 change: 1 addition & 0 deletions src/verse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ install(
add_subdirectory(util)
add_subdirectory(base-ot)
add_subdirectory(two-choose-one)
add_subdirectory(n-choose-one)

set(VERSE_SOURCE_FILES ${VERSE_SOURCE_FILES} PARENT_SCOPE)
25 changes: 25 additions & 0 deletions src/verse/n-choose-one/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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.

# Add header files for installation
install(
FILES
${CMAKE_CURRENT_LIST_DIR}/nco_ot_ext_receiver.h
${CMAKE_CURRENT_LIST_DIR}/nco_ot_ext_sender.h
DESTINATION
${VERSE_INCLUDES_INSTALL_DIR}/verse/n-choose-one
)
add_subdirectory(kkrt)

set(VERSE_SOURCE_FILES ${VERSE_SOURCE_FILES} PARENT_SCOPE)
28 changes: 28 additions & 0 deletions src/verse/n-choose-one/kkrt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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.

# Source files in this directory
set(VERSE_SOURCE_FILES ${VERSE_SOURCE_FILES}
${CMAKE_CURRENT_LIST_DIR}/kkrt_nco_ot_ext.cpp
)

# Add header files for installation
install(
FILES
${CMAKE_CURRENT_LIST_DIR}/kkrt_nco_ot_ext.h
DESTINATION
${VERSE_INCLUDES_INSTALL_DIR}/verse/n-choose-one/kkrt
)

set(VERSE_SOURCE_FILES ${VERSE_SOURCE_FILES} PARENT_SCOPE)
Loading

0 comments on commit f79ede7

Please sign in to comment.