Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions libOTe_Tests/BinarySolver_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,15 +727,15 @@ namespace osuCrypto

// Build batch instances
std::vector<Matrix<u8>> A(batch), A0(batch), A1(batch);
std::vector<Matrix<u8>> B(batch), B0(batch), B1(batch), C0(batch), C1(batch);
std::vector<Matrix<u8>> B(batch), Bsh0(batch), Bsh1(batch), C0(batch), C1(batch);
for (u64 b = 0; b < batch; ++b)
{
A[b].resize(n, m8);
A0[b].resize(n, m8);
A1[b].resize(n, m8);
B[b].resize(m, k8);
B0[b].resize(m, k8);
B1[b].resize(m, k8);
Bsh0[b].resize(m, k8);
Bsh1[b].resize(m, k8);
C0[b].resize(n, k8);
C1[b].resize(n, k8);

Expand All @@ -754,10 +754,10 @@ namespace osuCrypto
for (u64 j = 0; j < k; ++j)
{
*BitIterator(B[b][i].data(), j) = prng.getBit();
*BitIterator(B0[b][i].data(), j) = prng.getBit();
*BitIterator(Bsh0[b][i].data(), j) = prng.getBit();
}
for (u64 j = 0; j < B[b].cols(); ++j)
B1[b](i, j) = B[b](i, j) ^ B0[b](i, j);
Bsh1[b](i, j) = B[b](i, j) ^ Bsh0[b](i, j);
}
}

Expand All @@ -767,7 +767,7 @@ namespace osuCrypto
for (u64 b = 0; b < batch; ++b)
{
A0List.emplace_back(A0[b]); A1List.emplace_back(A1[b]);
B0List.emplace_back(B0[b]); B1List.emplace_back(B1[b]);
B0List.emplace_back(Bsh0[b]); B1List.emplace_back(Bsh1[b]);
C0List.emplace_back(C0[b]); C1List.emplace_back(C1[b]);
}

Expand Down
14 changes: 7 additions & 7 deletions libOTe_Tests/RingLpn_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,26 +689,26 @@ namespace osuCrypto
throw RTE_LOC;

auto sock = coproto::LocalAsyncSocket::makePair();
std::vector<F> A0(n), B0(n), C0(n);
std::vector<F> A1(n), B1(n), C1(n);
std::vector<F> A0(n), Bsh0(n), C0(n);
std::vector<F> A1(n), Bsh1(n), C1(n);

if (verbose)
triples[0].setTimer(timer);

// Generate triples using the 3-parameter expand function
auto r = macoro::sync_wait(macoro::when_all_ready(
triples[0].expand(A0, B0, C0, prng0, sock[0]),
triples[1].expand(A1, B1, C1, prng1, sock[1])));
triples[0].expand(A0, Bsh0, C0, prng0, sock[0]),
triples[1].expand(A1, Bsh1, C1, prng1, sock[1])));
std::get<0>(r).result();
std::get<1>(r).result();

// Verify that we got correct triple correlations
// Check that (A0 + A1) * (B0 + B1) = C0 + C1
// Check that (A0 + A1) * (Bsh0 + Bsh1) = C0 + C1
bool allCorrect = true;
for (size_t i = 0; i < n && allCorrect; i++)
{
auto a = A0[i] + A1[i]; // Reconstruct A
auto b = B0[i] + B1[i]; // Reconstruct B
auto b = Bsh0[i] + Bsh1[i]; // Reconstruct B
auto c = C0[i] + C1[i]; // Reconstruct C
auto expected = a * b; // Expected product

Expand All @@ -734,7 +734,7 @@ namespace osuCrypto
for (u64 i = 0; i < std::min<u64>(5, n); ++i)
{
auto a = A0[i] + A1[i];
auto b = B0[i] + B1[i];
auto b = Bsh0[i] + Bsh1[i];
auto c = C0[i] + C1[i];
std::cout << " Triple " << i << ": " << a << " * " << b << " = " << c << std::endl;
}
Expand Down
Loading