/// @file dpf/mesh_apps.hpp /// @brief Micro-plan builders for PIRsona and hushmap on the edge mesh. #ifndef LIBDPF_INCLUDE_DPF_MESH_APPS_HPP__ #define LIBDPF_INCLUDE_DPF_MESH_APPS_HPP__ #include #include #include #include #include #include "dpf/compose.hpp" #include "dpf/pad_graphs.hpp" #include "dpf/protocol.hpp" namespace dpf { namespace protocol { /// @brief PIRsona: BitMore-shaped star fetch (L bit keys → 2^L servers). /// @details Returns upload+answer rounds for `n_servers = 1u << L`. inline std::vector pirsona_bitmore_fetch(std::size_t L, std::size_t seed_bytes, std::size_t answer_bytes, const std::shared_ptr>> & seeds, const std::shared_ptr>> & answers) { const std::size_t n = std::size_t{1} << L; return star_upload_answer_graph(n, seed_bytes * L, answer_bytes, seeds, answers); } /// @brief PIRsona one gradient-descent update: Du-Atallah mul graph (stub body). inline std::vector pirsona_gd_update_graph( const std::shared_ptr> & tape) { return du_atallah_mul_graph(tape, /*slot_bytes=*/32); } /// @brief Hushmap KHM ADD online skeleton: Beaver open + masked open rounds. /// @details Matches the barrier count of MPC_PROTOCOL-v3 Phase 1 (2 peer opens) /// after a dealer tape of `n_layers` triples has been spliced. inline std::vector hushmap_add_online_graph( std::size_t n_layers, std::size_t open_bytes = 8) { (void)n_layers; std::vector rounds(2); for (std::size_t r = 0; r < 2; ++r) { rounds[r].slot_bytes = open_bytes; rounds[r].edge = edge_peer; rounds[r].channel = edge_channel::peer; rounds[r].recv = receive_rule::domain_open; rounds[r].sink_round = static_cast(r); rounds[r].produce = [open_bytes, r](std::size_t, const std::uint8_t *, std::size_t, std::uint8_t * out) { if (out != nullptr) std::memset(out, static_cast(0x10 + r), open_bytes); }; } return rounds; } /// @brief Full hushmap ADD schedule: dealer tape then online opens. inline std::vector hushmap_add_schedule(std::size_t n_layers, const std::shared_ptr> & tape, std::size_t triple_bytes = 24, std::size_t open_bytes = 8) { auto pads = dealer_tape_graph(n_layers, triple_bytes, tape); auto online = hushmap_add_online_graph(n_layers, open_bytes); // Online peer sink_rounds start at 0 on a peer-only sink after dealer // edges are separate — keep sink_round as assigned. return splice_rounds(std::move(pads), std::move(online)); } /// @brief Composer plan for a 2-server keyword-PIR-shaped client_servers flow. /// @details Prefer `n_server_pir_plan` / `keyword_pir_compose_plan` in /// [app_plans.hpp](@ref dpf/app_plans.hpp) for depth-derived sizes. inline plan keyword_pir_plan(std::size_t party, std::size_t query_bytes, std::size_t answer_bytes) { composer c(party); auto q = c.client_servers(2, query_bytes, answer_bytes); (void)q; return c.default_plan(); } } // namespace protocol } // namespace dpf #endif // LIBDPF_INCLUDE_DPF_MESH_APPS_HPP__