#include #include #include #include "dpf.hpp" #include "dpf/app_flow.hpp" #include "dpf/app_plans.hpp" // Floram, the FSS read and write (Doerner and shelat, CCS 2017). Both // parties see the memory. The address is secret-shared, so keygen is // Doerner–Shelat rather than a dealer who knows the index. The read is // the inner product of a unit key with that memory. The write adds a // payload key, built from the same address shares, into subtractive // copies of the array. // // c++ -std=c++17 -march=native -I include -I thirdparty \ // examples/applications/floram.cpp int main() { constexpr std::size_t n = 256; constexpr std::uint8_t address = 42; constexpr std::uint8_t a0 = 0x15; constexpr std::uint8_t a1 = static_cast(address ^ a0); constexpr std::uint64_t message = 9; std::vector memory(n); memory[address] = 100; memory[7] = 3; auto [r0, r1] = dpf::make_dpf_doerner_shelat(a0, a1, std::uint64_t{1}); const auto word = dpf::reconstruct( dpf::eval_full_inner_product(dpf::paired, r0, memory), dpf::eval_full_inner_product(dpf::paired, r1, memory)); if (word != memory[address]) { std::cerr << "floram read\n"; return 1; } auto [w0, w1] = dpf::make_dpf_doerner_shelat(a0, a1, message); std::vector s0 = memory; std::vector s1(n); dpf::eval_full_add_into(s0, w0); dpf::eval_full_add_into(s1, w1); if (s0[address] - s1[address] != memory[address] + message || s0[7] - s1[7] != memory[7]) { std::cerr << "floram write\n"; return 1; } { if (int rc = dpf::app::run_measured("floram", dpf::protocol::floram_ds_plan(0), 40)) return rc; } std::cout << word << "\n"; return 0; }