#include #include #include "dpf.hpp" /// Pre-assign full-domain expand, then rotate after the input wildcard opens. int main() { using input_type = std::uint8_t; using output_type = std::uint64_t; const output_type beta = 7; const input_type alpha = 42; const input_type from = 40; const input_type to = 50; auto [k0, k1] = dpf::make_dpf(dpf::wildcard_value{}, beta); //! [defer-eval] auto buf0 = dpf::make_output_buffer_for_full(k0); auto buf1 = dpf::make_output_buffer_for_full(k1); auto deferred0 = dpf::defer_eval_interval(k0, from, to, buf0); auto deferred1 = dpf::defer_eval_interval(k1, from, to, buf1); // Parties open mask - alpha into offset_x (local demo of the exchange). const input_type a0 = 0x12; const input_type a1 = static_cast(alpha - a0); const auto sh0 = k0.offset_x.compute_and_get_share(a0); const auto sh1 = k1.offset_x.compute_and_get_share(a1); k0.offset_x.reconstruct(sh1); k1.offset_x.reconstruct(sh0); auto view0 = deferred0.get(); auto view1 = deferred1.get(); //! [defer-eval] auto it0 = std::begin(view0); auto it1 = std::begin(view1); for (input_type x = from; x <= to; ++x, ++it0, ++it1) { const output_type got = dpf::reconstruct(*it0, *it1); const output_type expect = (x == alpha) ? beta : 0; if (got != expect) { std::cerr << "defer_eval\n"; return 1; } } if (it0 != std::end(view0) || it1 != std::end(view1)) { std::cerr << "defer_eval length\n"; return 1; } std::cout << dpf::reconstruct(*std::begin(view0), *std::begin(view1)) << "\n"; return 0; }