libdpf/examples/applications/hushmap_add.cpp

39 lines
1.1 KiB
C++
Raw Permalink Normal View History

#include <cstdint>
#include <iostream>
#include "dpf/online_session.hpp"
#include "dpf/prep_source.hpp"
// Hushmap KHM ADD: dealer tape + two online opens on async round sinks,
// then a real prep shipment (deal_views over async streams).
//
// c++ -std=c++17 -pthread -I include -I thirdparty \
// examples/applications/hushmap_add.cpp
int main()
{
constexpr std::size_t layers = 3;
try
{
dpf::session::drive_hushmap_add(layers);
dpf::prep::demand d;
d.ring_triples = static_cast<std::uint32_t>(layers);
const auto shipped = dpf::session::ship_prep(d);
std::uint8_t a0[8]{}, b0[8]{}, c0[8]{};
std::uint8_t a1[8]{}, b1[8]{}, c1[8]{};
auto c0p = shipped.party0;
auto c1p = shipped.party1;
c0p.take_ring(a0, b0, c0);
c1p.take_ring(a1, b1, c1);
std::cout << "hushmap_add layers=" << layers
<< " rounds=" << (layers + 2)
<< " prep_bytes=" << shipped.bytes0 << "\n";
}
catch (const std::exception & ex)
{
std::cerr << "hushmap_add: " << ex.what() << "\n";
return 1;
}
return 0;
}