#include #include #include "dpf.hpp" /// One input. `*eval_point` is that party's share of output 0. /// Reconstruct with `dpf::reconstruct` (leaf outputs are subtractive). int main() { const std::uint8_t alpha = 42; const std::uint64_t beta = 7; auto [k0, k1] = dpf::make_dpf(alpha, beta); using key_t = dpf::unwrap_party_key_t>; //! [eval-point] auto y0 = *dpf::eval_point(k0, alpha); auto y1 = *dpf::eval_point(k1, alpha); std::uint64_t opened = dpf::reconstruct(y0, y1); //! [eval-point] if (opened != beta) { std::cerr << "eval_point at the programmed input\n"; return 1; } auto off0 = *dpf::eval_point(k0, std::uint8_t{41}); auto off1 = *dpf::eval_point(k1, std::uint8_t{41}); if (dpf::reconstruct(off0, off1) != 0) { std::cerr << "eval_point off the programmed input\n"; return 1; } //! [eval-point-memo] // One mutable memoizer per key. Nearby points reuse the common prefix. auto path0 = dpf::make_basic_path_memoizer(); auto path1 = dpf::make_basic_path_memoizer(); for (int x = 40; x <= 44; ++x) { auto s0 = *dpf::eval_point(k0, static_cast(x), path0); auto s1 = *dpf::eval_point(k1, static_cast(x), path1); std::uint64_t got = dpf::reconstruct(s0, s1); std::uint64_t expect = (static_cast(x) == alpha) ? beta : 0; if (got != expect) { std::cerr << "path memoizer\n"; return 1; } } //! [eval-point-memo] std::cout << opened << "\n"; return 0; }