libdpf/examples/mwe/compare.cpp

25 lines
807 B
C++
Raw Normal View History

#include <cstdint>
#include <iostream>
#include "dpf.hpp"
// Complete program. Comparison shares are additive: reconstruct is share0 + share1.
// gt(1) is 1 where x > alpha and 0 elsewhere.
//
// c++ -std=c++17 -march=native -I include -I thirdparty examples/mwe/compare.cpp
int main()
{
const std::uint8_t alpha = 40;
auto [k0, k1] = dpf::make_dpf(alpha, dpf::gt(std::uint64_t{1}));
const auto above = dpf::reconstruct(
dpf::eval_point(dpf::cmp, k0, std::uint8_t{50}),
dpf::eval_point(dpf::cmp, k1, std::uint8_t{50}));
const auto below = dpf::reconstruct(
dpf::eval_point(dpf::cmp, k0, std::uint8_t{10}),
dpf::eval_point(dpf::cmp, k1, std::uint8_t{10}));
std::cout << above << " " << below << "\n";
return (above == 1 && below == 0) ? 0 : 1;
}