The repository contains optimized code written to implement weak PRF with parameters m, n and t. Currently m = n = 256 and t = 81 in Z3.
Here are the instructions to replicate the benchmarking procedure:
- Clone the repository ($ git clone https://github.com/vivek18394/PseudoRandomFunction)
- Set the appropriate flag. Check section Flags
- run the command $g++ -std=c++14 [-O3] -o <output_file> -I include/darkmatter/ src/.cpp tests/.cpp
The repository houses a custom built framework and variations of 2-3 wPRF proposed in Dark Matter crypto paper (TCC '18).
- Basics - include/darkmatter/{PackedMod2.hpp, PackedMod3.hpp, utils.hpp, Timing.hpp}
- src/Toeplitz-by-x.cpp
- src/OT.cpp
- src/PRF.cpp
- tests/test_PRF.cpp
-
First phase contains the mod-2 multiplication of shares of input(x) and Key(K) in field ℤ2 .These operations are carried out in two sub phases: i) K*x mod 2 In this phase, the computation is divided into online module and an offline module. Recall that, both party has share of input(x1, x2) and Key(K1, K2). The aim is to compute K *x = (K1, K2) * (x1, x2) = K1x1 + K1x2 + K2x1 + K2x2 The first and last term can be computed locally since it is with the parties, while second and third term needs to be computed by exchanging messages without actually sharing the shares. This part comes under online computation. Refer to 5.1.3 for functions.
-
Second Phase In this phase, the output of phase 1 is converted from ℤ2 to ℤ3. The related functions and their descriptions is in Section 5.1.3.
The related functions can be found in files listed in 5.1.1.
- Third Phase This is the final phase of the protocol. It performs matrix vector multiplication between publicly available Random Matrix of size (t X m)[81 X 256] and m-bit sized output of phase 2(m ∈ ℤ3). There are two different implementation of the matrix vector multiplication. This can be implemented by enabling flag no. 1 for packed, bit sliced version and flag no. 2 for lookup table as shown in Section 7.1.
The related functions can be found in files listed in 5.1.1.
Function | Description |
---|---|
topelitz_Party2_1() | Computes Mx = x - rx |
topelitz_Party1() | Computes mA = A - rA and mb = (rA * Mx) + b + rb |
topelitz_Party2_2() | Computes mA * x + mb - rz where rz = rA * rx + rb |
{SC_Party2_1(), SC_Party1(), SC_party 2_2()} | Converts ℤ2 to ℤ3. |
matByVec() | Performs matrix Vector multiplication and outputs a t-bit vector. Not so fast, good on memory. |
usedLookupTable() | Implements matrix vector multiplication using a lookup table. Takes more memory but is fast. |
- Basics - include/darkmatter/{PackedMod2.hpp, PackedMod3.hpp, utils.hpp, Timing.hpp}
- src/newprotocol.cpp
- tests/test_newprotocol.cpp
- First phase: Masking the inputs Both the parties mask their shares of input and key with a random mask that is generated in preprocessing. These shares are shared at the end of this phase. So now apart from holding secret share of input and key, each party also holds masked input and key of other party.
- Second phase: Compute w'(Kx)
- Third phase: Perform matrix vector multiplication
- Basics - include/darkmatter/{PackedMod2.hpp, PackedMod3.hpp, utils.hpp, Timing.hpp}
- src/oprf.cpp
- tests/test_oprf.cpp
Server holds the key while client holds the input. The project includes Single client and single server implementation.
- First phase: Masking the inputs Server masks its input and sends it to client, while client masks its input and sends it to server.
- Second phase: Compute w'(Kx) Server Computes
- Third phase: Perform matrix vector multiplication
- src/packed_PRF_central.cpp
- tests/test_Packed_PRF.cpp
- tests/test_packed_PRF_central_lookup.cpp
- include/darkmatter/integer_pack.h
- src/integer_pack.cpp
- tests/test_central_int_packed.cpp
This section describes the part that was timed in each protocol. The protocols are divided into phases and each phase of the protocol are timed. Some phases can run independently, which means they don't need any extra communication while running. Note: They do need inputs(at the beginning) and produces output(at the end). Some phases run while communicating, in such cases, parties indulge in communication during the execution of phase. Some protocols can be parallelized, which means the parties running the phases of the protocol can run concurrently and in such cases, the time that a phase takes is the maximum of the timing among two parties running on same phase/round
- Time phase 1: The following three function are called twice in a single instance, one for K1x2 and other for K2x1
- Toeplitz_party2_1();
- Toeplitz_party1();
- Toeplitz_party2_2();
Sr. No. | Flag in mains.hpp | Description |
---|---|---|
1 | #define TEST_PRF | Runs the Dark matter(TCC '18) protocol without the lookup table |
2 | #define TEST_PRF_LOOKUP | Runs the Dark matter(TCC '18) protocol using a lookup table |
3 | #define TEST_NP | Runs the proposed Fully Distributed protocol without the lookup table |
4 | #define TEST_NP_LOOKUP | Runs the proposed Fully Distributed protocol using a lookup table |
5 | #define TEST_OPRF | Runs 23-wPRF based OPRF protocol without the lookup table |
6 | #define TEST_OPRF_LOOKUP | Runs 23-wPRF based OPRF protocol using a lookup table |
Sr. No. | Flags in mains.hpp | Description |
---|---|---|
1 | #define PACKED_PRF_CENTRAL | Runs operations in wPRF using Packing and BitSlicing |
2 | #define PACKED_PRF_CENTRAL_LOOKUP | Runs operations in wPRF using Packing, BitSlicing and lookup table |
3 | #define UNPACKED_PRF_CENTRAL | Runs operations in wPRF using Packing and naive method for matrix vector multiplication |
4 | #define TEST_INTEGER_PACKING | Runs operations in wPRF using Packing and Z3 integer packing. |
Sr. No. | Flags in mains.hpp | Description |
---|---|---|
1 | #define TEST_LOOKUP_INDEPENDENT | Test standalone Lookup table implementation |
2 | #define UNIT_NP | Test Fully Distributed 23-wPRF |
3 | #define UNIT_NP_LOOKUP | Test Fully Distributed 23-wPRF with a lookup table |
4 | #define TEST_PHASE1 | Test Ax+B phase 1 of Dark Matter TCC '18 const 3.1 protocol. |
- Dark Matter TCC '18 wPRF
- Dark Matter TCC '18 wPRF with packing
- Dark Matter TCC '18 wPRF with packing and lookup table
- Fully Distributed wPRF
- Fully Distributed wPRF with packing
- Fully Distributed wPRF with packing and lookup table
- Proposed OPRF with packing
- Proposed OPRF with packing and lookup table
- Fix DM unit test issue-reported 1/29/2021
- Fix PackedMod2 unit test issue-reported 1/29/2021