diff --git a/fbpcf/mpc_std_lib/permuter/AsWaksmanPermuterForBitString_impl.h b/fbpcf/mpc_std_lib/permuter/AsWaksmanPermuterForBitString_impl.h index 7f1010de..630b4383 100644 --- a/fbpcf/mpc_std_lib/permuter/AsWaksmanPermuterForBitString_impl.h +++ b/fbpcf/mpc_std_lib/permuter/AsWaksmanPermuterForBitString_impl.h @@ -111,7 +111,9 @@ AsWaksmanPermuter, schedulerId>::permute( } auto length = vectorOfVectors.at(0).size(); std::vector> rst; - rst.reserve(2 * (std::ceil(log2(order.size()))) - 1); + if (order.size() > 2) { + rst.reserve(2 * (std::ceil(log2(order.size()))) - 1); + } computeChoiceVectors( std::vector>(1, order), rst, order.size()); diff --git a/fbpcf/mpc_std_lib/permuter/test/PermuterTest.cpp b/fbpcf/mpc_std_lib/permuter/test/PermuterTest.cpp index e846c768..aa6a225f 100644 --- a/fbpcf/mpc_std_lib/permuter/test/PermuterTest.cpp +++ b/fbpcf/mpc_std_lib/permuter/test/PermuterTest.cpp @@ -74,12 +74,12 @@ void party1Task( void permuterTest( IPermuterFactory>& permuterFactory0, - IPermuterFactory>& permuterFactory1) { + IPermuterFactory>& permuterFactory1, + uint32_t size) { auto agentFactories = engine::communication::getInMemoryAgentFactory(2); setupRealBackend<0, 1>(*agentFactories[0], *agentFactories[1]); auto permuter0 = permuterFactory0.create(); auto permuter1 = permuterFactory1.create(); - uint32_t size = 17; auto [originalData, order, expectedOutput] = getPermuterTestData(size); auto future0 = std::async(party0Task, std::move(permuter0), originalData, order); @@ -95,14 +95,21 @@ TEST(permuterTest, testDummyPermuter) { insecure::DummyPermuterFactory, 0> factory0(0, 1); insecure::DummyPermuterFactory, 1> factory1(1, 0); - permuterTest(factory0, factory1); + permuterTest(factory0, factory1, 17); } TEST(permuterTest, testAsWaksmanPermuter) { AsWaksmanPermuterFactory, 0> factory0(0, 1); AsWaksmanPermuterFactory, 1> factory1(1, 0); - permuterTest(factory0, factory1); + permuterTest(factory0, factory1, 17); +} + +TEST(permuterTest, testAsWaksmanPermuterSingleValue) { + AsWaksmanPermuterFactory, 0> factory0(0, 1); + AsWaksmanPermuterFactory, 1> factory1(1, 0); + + permuterTest(factory0, factory1, 1); } void testAsWaksmanParameter() {