libdpf/examples/evaluation/eval_dpf3_cmp_ic.cpp
Ryan Henry 0d22946a0e Checkpoint the party/runtime stack before share-program and malicious-mode work.
Ship the TLS mesh, composer, Beaver/Yao/leaf MPC, prep/online paths, apps, and docs so the tree is pushable before elevating share_expr, security_mode, and prep resume.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 05:59:19 -06:00

44 lines
1.3 KiB
C++

#include <cstdint>
#include <iostream>
#include "dpf.hpp"
/// Three-party comparison and interval-containment keys (one DCF share each).
int main()
{
using Input = std::uint8_t;
const Input thresh = 100;
const std::uint64_t beta = 5;
//! [eval-dpf3-cmp]
auto [c1, c2, c3] = dpf::make_dpf3_cmp(thresh, beta);
// Parties 1 and 3 hold the k0 half; party 2 holds k1. Open any complementary pair.
const dpf::fp61 hot =
dpf::reconstruct_cmp_halves(dpf::eval_point(c1, Input{10}),
dpf::eval_point(c2, Input{10}));
const dpf::fp61 cold =
dpf::reconstruct_cmp_halves(dpf::eval_point(c3, Input{200}),
dpf::eval_point(c2, Input{200}));
//! [eval-dpf3-cmp]
if (hot.raw() != beta || cold.raw() != 0)
{
std::cerr << "dpf3 cmp\n";
return 1;
}
//! [eval-dpf3-ic]
auto [i1, i2, i3] = dpf::make_dpf3_ic(Input{10}, Input{20}, Input{40}, beta);
// Interval is relative to the public shift `r`; x=35 is on for (20,40)@r=10.
const dpf::fp61 inside =
dpf::reconstruct_cmp_halves(dpf::eval_point(i1, Input{35}),
dpf::eval_point(i2, Input{35}));
//! [eval-dpf3-ic]
if (inside.raw() != beta)
{
std::cerr << "dpf3 ic\n";
return 1;
}
std::cout << hot.raw() << "\n";
return 0;
}