29 lines
964 B
C++
29 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;
|
||
|
|
}
|