Annotate noexcept and constexpr with HEDLEY, and add interval containment, ChaCha, and the dyadic range tables.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
875f09fec1
commit
0d8a5a8131
97 changed files with 9212 additions and 1159 deletions
|
|
@ -1,42 +1,43 @@
|
|||
#include <cstdint>
|
||||
#include <iostream>
|
||||
|
||||
#include "dpf.hpp"
|
||||
|
||||
int main(int arc, char * argv[])
|
||||
/// Inclusive range. The returned iterable yields one share per input in
|
||||
/// `[from, to]`, in that order.
|
||||
int main()
|
||||
{
|
||||
uint16_t x = 42, y;
|
||||
using prg = dpf::prg::counter_wrapper<dpf::prg::dummy>;
|
||||
const std::uint8_t alpha = 42;
|
||||
const std::uint64_t beta = 7;
|
||||
const std::uint8_t from = 40;
|
||||
const std::uint8_t to = 50;
|
||||
auto [k0, k1] = dpf::make_dpf(alpha, beta);
|
||||
|
||||
// Make the DPF
|
||||
auto before = prg::count();
|
||||
auto [dpf0, dpf1] = dpf::make_dpf<prg>(x);
|
||||
auto after = prg::count();
|
||||
std::cout << "dpf::make_dpf prg invocation: " << (after-before) << "\n";
|
||||
//! [eval-interval]
|
||||
auto [buf0, iter0] = dpf::eval_interval(k0, from, to);
|
||||
auto [buf1, iter1] = dpf::eval_interval(k1, from, to);
|
||||
|
||||
// Evaluate the DPF by interval
|
||||
before = prg::count();
|
||||
int from = 0, to = 49;
|
||||
auto [buf0, iter0] = dpf::eval_interval(dpf0, from, to);
|
||||
auto [buf1, iter1] = dpf::eval_interval(dpf1, from, to);
|
||||
after = prg::count();
|
||||
std::cout << "dpf::eval_interval prg invocation: " << (after-before) << "\n";
|
||||
|
||||
// Retrieve the original input by iterating over the two buffers
|
||||
std::vector<bool> result;
|
||||
for (size_t i = from; i < to+1; ++i) {
|
||||
bool item1 = buf0[i];
|
||||
bool item2 = buf1[i];
|
||||
result.push_back(item1 ^ item2);
|
||||
if (item1 ^ item2) y=i;
|
||||
auto it0 = std::begin(iter0);
|
||||
auto it1 = std::begin(iter1);
|
||||
for (std::uint8_t x = from; x <= to; ++x, ++it0, ++it1)
|
||||
{
|
||||
std::uint64_t got = dpf::reconstruct(*it0, *it1);
|
||||
std::uint64_t expect = (x == alpha) ? beta : 0;
|
||||
if (got != expect)
|
||||
{
|
||||
std::cerr << "eval_interval\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// Print out the XOR interval
|
||||
for (const auto& item : result) {
|
||||
std::cout << static_cast<bool>(item);
|
||||
//! [eval-interval]
|
||||
if (it0 != std::end(iter0) || it1 != std::end(iter1))
|
||||
{
|
||||
std::cerr << "eval_interval length\n";
|
||||
return 1;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
if (y == x) std::cout << "The orginal value is: " << x << std::endl;
|
||||
else std::cout << "The evaluated inputs did not match the original value." << std::endl;
|
||||
|
||||
std::cout << "Total PRG invocation: " << prg::count() << std::endl;
|
||||
|
||||
std::cout << dpf::reconstruct(*std::begin(iter0), *std::begin(iter1)) << "\n";
|
||||
(void)buf0;
|
||||
(void)buf1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue