libdpf/examples/evaluation/eval_dpf3_doerner_shelat.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

36 lines
1.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <cstdint>
#include <iostream>
#include "dpf.hpp"
/// Dual-spine Doerner–Shelat (2,3) keygen: XOR shares of `α`, same clear `β`
/// as honest-dealer `make_dpf3(α, β)`.
int main()
{
using Input = std::uint8_t;
const Input alpha = 0x2a;
const Input x0 = 0x13;
const Input x1 = static_cast<Input>(alpha ^ x0);
const dpf::fp61 beta{99};
//! [eval-dpf3-ds]
auto [d1, d2, d3] = dpf::make_dpf3(alpha, beta);
auto [s1, s2, s3] = dpf::make_dpf3_doerner_shelat(x0, x1, beta);
const dpf::fp61 dealer = dpf::reconstruct(
dpf::as_share(d1, dpf::eval_point(d1, alpha)),
dpf::as_share(d2, dpf::eval_point(d2, alpha)),
dpf::as_share(d3, dpf::eval_point(d3, alpha)));
const dpf::fp61 dual = dpf::reconstruct(
dpf::as_share(s1, dpf::eval_point(s1, alpha)),
dpf::as_share(s2, dpf::eval_point(s2, alpha)),
dpf::as_share(s3, dpf::eval_point(s3, alpha)));
//! [eval-dpf3-ds]
if (dealer != beta || dual != beta)
{
std::cerr << "dealer vs dual-spine disagree\n";
return 1;
}
std::cout << dual.raw() << "\n";
return 0;
}