Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Efficient Linear Multiparty PSI and Extension to Circuit/Quorum PSI #212

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"set": "cpp"
}
}
18 changes: 18 additions & 0 deletions experimental/psi/psi21/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Efficient Linear Multiparty PSI and Extension to Circuit/Quorum PSI

(https://www.xueshufan.com/publication/3150904314)

Our protocols for all three problem settings, namely, mPSI, circuit PSI and qPSI, broadly have two phases. At a high level, in the first phase, a fixed designated party, say P1, interacts with all other parties P2,...,Pn using 2-party protocols. In the second phase, all parties engage in n-party protocols to compute a circuit to get the requisite output.

**multiparty_psi**

For mPSI, in the first phase, we invoke a two-party functionality, which we call weak private set membership (wPSM) functionality,
between a leader, P1 and each Pi (for i ∈ {2, · · · , n}). Informally, the wPSM functionality, when invoked between P1 and Pi on their individual private sets does the following: for each element in P1’s set, it outputs the same random value to both P1 and Pi , if that element is in Pi’s set, and outputs independent random values, otherwise. By invoking only n instances ofthe wPSM functionality overall, we ensure that the total communication complexity of this phase is linear in n. In the second phase, all the parties together run a secure multiparty computation to obtain shares of 0 for each element in P1’s set that is in the intersection and shares of a random element for other elements.

**circuit_psi**

For circuit psi, the first phase additionally includes conversion ofthe outputs from the wPSM functionality to arithmetic shares of 1 if P1 and Pi received the same random value, and shares of 0, otherwise. In the second phase, for every element of P1, all parties must get shares of 1 if that element belongs to the intersection, and shares of 0, otherwise.

**quorum_psi**

For qpsi, the first phase additionally includes conversion ofthe outputs from the wPSM functionality to arithmetic shares of 1 if P1 and Pi received the same random value, and shares of 0, otherwise. In the second phase, we appropriately choose another polynomial such that for each element in P1’s set, the polynomial evaluates to 0 if and only if that element belongs to the quorum intersection, and random otherwise.
67 changes: 67 additions & 0 deletions experimental/psi/psi21/el_mp_psi/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright 2024 zhangwfjh
#
# 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.

load("//bazel:psi.bzl", "psi_cc_binary", "psi_cc_library", "psi_cc_test")

package(default_visibility = ["//visibility:public"])

WARNING_OPTS = ["-Wall"]
psi_cc_binary(
name = "el_mp_psi_benchmark",
srcs = ["el_mp_psi_benchmark.cc"],
copts = WARNING_OPTS,
deps = [
":el_mp_psi",
"@com_github_google_benchmark//:benchmark_main",
],
)

psi_cc_library(
name = "el_mp_psi",
srcs = [
"el_hashing.cc",
"el_mp_psi.cc",
"el_sender.cc",
"Mersenne.cc",
"el_protocol.cc",
],
hdrs = [
"el_hashing.h",
"el_mp_psi.h",
"el_sender.h",
"Mersenne.h",
"el_protocol.h",
],
deps = [
"//psi/utils:communication",
"//psi/utils:sync",
"//psi/utils:test_utils",
"@com_google_absl//absl/types:span",
"@yacl//yacl/base:exception",
"@yacl//yacl/base:int128",
"@yacl//yacl/crypto/hash:hash_utils",
"@yacl//yacl/crypto/rand",
"@yacl//yacl/kernel/algorithms:base_ot",
"@yacl//yacl/kernel/algorithms:iknp_ote",
"@yacl//yacl/kernel/algorithms:kkrt_ote",
"@yacl//yacl/link",
],
)

psi_cc_test(
name = "el_mp_psi_test",
srcs = ["el_mp_psi_test.cc"],
tags = ["manual"],
deps = [":el_mp_psi"],
)
79 changes: 79 additions & 0 deletions experimental/psi/psi21/el_mp_psi/Mersenne.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// \author Avishay Yanay
// \organization Bar-Ilan University
// \email [email protected]
//
// MIT License
//
// Copyright (c) 2018 AvishayYanay
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include "Mersenne.h"

template <>
ZpMersenneIntElement1 TemplateField<ZpMersenneIntElement1>::GetElement(long b) {
if (b == 1) {
return *m_ONE;
}
if (b == 0) {
return *m_ZERO;
} else {
ZpMersenneIntElement1 element(b);
return element;
}
}

template <>
ZpMersenneLongElement1 TemplateField<ZpMersenneLongElement1>::GetElement(
long b) {
if (b == 1) {
return *m_ONE;
}
if (b == 0) {
return *m_ZERO;
} else {
ZpMersenneLongElement1 element(b);
return element;
}
}

template <>
void TemplateField<ZpMersenneIntElement1>::elementToBytes(
unsigned char* elemenetInBytes, ZpMersenneIntElement1& element) {
memcpy(elemenetInBytes, (byte*)(&element.elem), 4);
}

template <>
void TemplateField<ZpMersenneLongElement1>::elementToBytes(
unsigned char* elemenetInBytes, ZpMersenneLongElement1& element) {
memcpy(elemenetInBytes, (byte*)(&element.elem), 8);
}

template <>
ZpMersenneIntElement1 TemplateField<ZpMersenneIntElement1>::bytesToElement(
unsigned char* elemenetInBytes) {
return ZpMersenneIntElement1((unsigned int)(*(unsigned int*)elemenetInBytes));
}

template <>
ZpMersenneLongElement1 TemplateField<ZpMersenneLongElement1>::bytesToElement(
unsigned char* elemenetInBytes) {
return ZpMersenneLongElement1(
(unsigned long)(*(unsigned long*)elemenetInBytes));
}
Loading
Loading