Ship the TLS mesh, composer, Beaver/Yao/leaf MPC, prep/online paths, apps, and docs so the tree is pushable before elevating share_expr, security_mode, and prep resume. Co-authored-by: Cursor <cursoragent@cursor.com>
68 lines
2.3 KiB
C++
68 lines
2.3 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include <cstdint>
|
|
#include <type_traits>
|
|
#include <vector>
|
|
|
|
#include "dpf.hpp"
|
|
|
|
TEST(ItDpf3, OnPointAndOffPoint)
|
|
{
|
|
constexpr std::uint8_t alpha = 42;
|
|
constexpr std::uint64_t beta = 7;
|
|
auto [k0, k1, k2] = dpf::make_it_dpf3(alpha, beta);
|
|
|
|
EXPECT_FALSE((std::is_same_v<decltype(k0),
|
|
decltype(std::get<0>(dpf::make_dpf3(alpha, dpf::fp61{1})))>));
|
|
|
|
const auto on = dpf::eval_it_dpf3(k0, alpha) + dpf::eval_it_dpf3(k1, alpha)
|
|
+ dpf::eval_it_dpf3(k2, alpha);
|
|
EXPECT_EQ(on, beta);
|
|
|
|
const auto off = dpf::eval_it_dpf3(k0, std::uint8_t{41})
|
|
+ dpf::eval_it_dpf3(k1, std::uint8_t{41})
|
|
+ dpf::eval_it_dpf3(k2, std::uint8_t{41});
|
|
EXPECT_EQ(off, 0u);
|
|
}
|
|
|
|
TEST(ItDpf3, InnerProductIsTableEntry)
|
|
{
|
|
constexpr std::uint8_t index = 17;
|
|
std::vector<std::uint64_t> table(256);
|
|
for (std::size_t i = 0; i < table.size(); ++i)
|
|
table[i] = i * i + 3;
|
|
|
|
auto [k0, k1, k2] = dpf::make_it_dpf3(index, 1);
|
|
const auto s0 = dpf::eval_it_dpf3_inner_product(k0, table);
|
|
const auto s1 = dpf::eval_it_dpf3_inner_product(k1, table);
|
|
const auto s2 = dpf::eval_it_dpf3_inner_product(k2, table);
|
|
EXPECT_EQ(s0 + s1 + s2, table[index]);
|
|
}
|
|
|
|
// Seam: same PIR shape as make_dpf3 + shamir reconstruct, different key type
|
|
// and three-way sum instead of any-two Lagrange.
|
|
TEST(ItDpf3, PirDotDistinctFromShamirDpf3)
|
|
{
|
|
constexpr std::uint8_t index = 42;
|
|
std::vector<std::uint64_t> table(256);
|
|
for (std::size_t i = 0; i < table.size(); ++i)
|
|
table[i] = i + 1;
|
|
|
|
auto [i0, i1, i2] = dpf::make_it_dpf3(index, 1);
|
|
const auto it_opened =
|
|
dpf::eval_it_dpf3_inner_product(i0, table)
|
|
+ dpf::eval_it_dpf3_inner_product(i1, table)
|
|
+ dpf::eval_it_dpf3_inner_product(i2, table);
|
|
EXPECT_EQ(it_opened, table[index]);
|
|
|
|
std::vector<dpf::fp61> ftable(256);
|
|
for (std::size_t i = 0; i < ftable.size(); ++i)
|
|
ftable[i] = dpf::fp61{static_cast<std::uint64_t>(i + 1)};
|
|
auto [d1, d2, d3] = dpf::make_dpf3(index, dpf::fp61{1});
|
|
const auto s1 = dpf::eval_full_inner_product(d1, ftable);
|
|
const auto s2 = dpf::eval_full_inner_product(d2, ftable);
|
|
const auto opened = dpf::shamir3::reconstruct(
|
|
dpf::as_share(d1, s1), dpf::as_share(d2, s2));
|
|
EXPECT_EQ(opened.raw(), table[index]);
|
|
EXPECT_FALSE((std::is_same_v<decltype(i0), decltype(d1)>));
|
|
}
|