libdpf/examples/mwe/interval.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

28 lines
964 B
C++

#include <cstdint>
#include <iostream>
#include "dpf.hpp"
// Complete program. The secret is a mask r. The public interval is [p, q]
// on the unmasked input x - r. ic returns `beta` inside that interval.
//
// c++ -std=c++17 -march=native -I include -I thirdparty examples/mwe/interval.cpp
int main()
{
const std::uint8_t r = 10;
const std::uint8_t p = 3;
const std::uint8_t q = 5;
const std::uint64_t beta = 9;
auto [k0, k1] = dpf::make_dpf(r, dpf::ic(p, q, beta));
// x = 14 means x - r = 4, which is inside [3, 5].
const auto inside = dpf::reconstruct(
dpf::eval_point(dpf::ic, k0, std::uint8_t{14}),
dpf::eval_point(dpf::ic, k1, std::uint8_t{14}));
const auto outside = dpf::reconstruct(
dpf::eval_point(dpf::ic, k0, std::uint8_t{0}),
dpf::eval_point(dpf::ic, k1, std::uint8_t{0}));
std::cout << inside << " " << outside << "\n";
return (inside == beta && outside == 0) ? 0 : 1;
}