You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
4. Run `Eval` on each party and reconstruct using the group:
143
143
144
-
```cpp
145
-
// Each party evaluates independently
146
-
int4 y0 = dpf.Eval(false, seeds[0], cws, alpha);
147
-
int4 y1 = dpf.Eval(true, seeds[1], cws, alpha);
144
+
```cpp
145
+
// Each party evaluates independently
146
+
int4 y0 = dpf.Eval(false, seeds[0], cws, alpha);
147
+
int4 y1 = dpf.Eval(true, seeds[1], cws, alpha);
148
148
149
-
// Reconstruct via the group: convert to group elements, add, convert back
150
-
// For Bytes group this is XOR; for Uint group this is arithmetic addition
151
-
int4 sum = (Group::From(y0) + Group::From(y1)).Into();
152
-
// sum == beta at x == alpha, 0 otherwise
153
-
```
149
+
// Reconstruct via the group: convert to group elements, add, convert back
150
+
// For Bytes group this is XOR; for Uint group this is arithmetic addition
151
+
int4 sum = (Group::From(y0) + Group::From(y1)).Into();
152
+
// sum == beta at x == alpha, 0 otherwise
153
+
```
154
154
155
155
5. Free the AES contexts when done:
156
156
157
-
```cpp
158
-
DpfPrg::FreeCtxs(ctxs);
159
-
```
157
+
```cpp
158
+
DpfPrg::FreeCtxs(ctxs);
159
+
```
160
160
161
161
DCF follows the same pattern — use `DcfPrg` (mul=4, needs 4 AES keys), `Dcf`, and `Dcf::Cw`. The reconstructed output equals `beta` when `x < alpha` and `0` otherwise.
162
162
@@ -175,79 +175,113 @@ This walks through using DPF and DCF on the GPU with ChaCha PRG.
175
175
176
176
1. Include the headers and set up type aliases:
177
177
178
-
```cpp
179
-
#include<fss/dpf.cuh>
180
-
#include<fss/dcf.cuh>
181
-
#include<fss/group/bytes.cuh>
182
-
#include<fss/prg/chacha.cuh>
178
+
```cpp
179
+
#include<fss/dpf.cuh>
180
+
#include<fss/dcf.cuh>
181
+
#include<fss/group/bytes.cuh>
182
+
#include<fss/prg/chacha.cuh>
183
183
184
-
constexprintkInBits = 8;
185
-
using In = uint8_t;
186
-
using Group = fss::group::Bytes;
184
+
constexprintkInBits = 8;
185
+
using In = uint8_t;
186
+
using Group = fss::group::Bytes;
187
187
188
-
// DPF uses mul=2, DCF uses mul=4
189
-
using DpfPrg = fss::prg::ChaCha<2>;
190
-
using DcfPrg = fss::prg::ChaCha<4>;
191
-
using Dpf = fss::Dpf<kInBits, Group, DpfPrg, In>;
192
-
using Dcf = fss::Dcf<kInBits, Group, DcfPrg, In>;
193
-
```
188
+
// DPF uses mul=2, DCF uses mul=4
189
+
using DpfPrg = fss::prg::ChaCha<2>;
190
+
using DcfPrg = fss::prg::ChaCha<4>;
191
+
using Dpf = fss::Dpf<kInBits, Group, DpfPrg, In>;
192
+
using Dcf = fss::Dcf<kInBits, Group, DcfPrg, In>;
193
+
```
194
194
195
195
2. Set up a nonce in constant memory and create the PRG in a kernel:
5. Reconstruct on the host using the group, same as the CPU case:
242
242
243
-
```cpp
244
-
int4 sum = (Group::From(h_y0s[i]) + Group::From(h_y1s[i])).Into();
245
-
```
243
+
```cpp
244
+
int4 sum = (Group::From(h_y0s[i]) + Group::From(h_y1s[i])).Into();
245
+
```
246
246
247
247
DCF follows the same pattern — use `DcfPrg` (mul=4), `Dcf`, and `Dcf::Cw`.
248
248
249
249
See `samples/dpf_dcf_gpu.cu` for the complete working example.
250
250
251
+
## Benchmarks
252
+
253
+
Microbenchmarks for DPF/DCF `Gen`/`Eval` using [Google Benchmark](https://github.com/google/benchmark), covering both CPU (AES-128 MMO PRG) and GPU (ChaCha PRG) paths.
254
+
255
+
Configure with `BUILD_BENCH=ON` and build the targets:
0 commit comments