From b366b13a8718bb90f1273888431225aac0db1f9a Mon Sep 17 00:00:00 2001 From: Peter Rindal Date: Tue, 23 Jan 2024 11:52:23 -0800 Subject: [PATCH] fix 1-2 OT example for softspoken --- frontend/ExampleTwoChooseOne.cpp | 34 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/frontend/ExampleTwoChooseOne.cpp b/frontend/ExampleTwoChooseOne.cpp index edce51c..01eeafb 100644 --- a/frontend/ExampleTwoChooseOne.cpp +++ b/frontend/ExampleTwoChooseOne.cpp @@ -35,9 +35,9 @@ namespace osuCrypto template using is_SoftSpoken = typename std::conditional< std::is_same>::value || - std::is_same>::value || - std::is_same::value || - std::is_same::value, + std::is_same>::value || + std::is_same::value || + std::is_same::value, std::true_type, std::false_type>::type; #else @@ -84,7 +84,7 @@ namespace osuCrypto if (role == Role::Receiver) { DefaultBaseOT base; - std::array, 128> baseMsg; + std::vector> baseMsg(receiver.baseOtCount()); // perform the base To, call sync_wait to block until they have completed. cp::sync_wait(base.send(baseMsg, prng, chl)); @@ -94,8 +94,8 @@ namespace osuCrypto { DefaultBaseOT base; - BitVector bv(128); - std::array baseMsg; + BitVector bv(sender.baseOtCount()); + std::vector baseMsg(sender.baseOtCount()); bv.randomize(prng); // perform the base To, call sync_wait to block until they have completed. @@ -106,19 +106,23 @@ namespace osuCrypto #else if (!cmd.isSet("fakeBase")) std::cout << "warning, base ots are not enabled. Fake base OTs will be used. " << std::endl; - PRNG commonPRNG(oc::ZeroBlock); - std::array, 128> sendMsgs; - commonPRNG.get(sendMsgs.data(), sendMsgs.size()); + PRNG commonPRNG(oc::CCBlock); if (role == Role::Receiver) { + std::vector> sendMsgs(receiver.baseOtCount()); + commonPRNG.get(sendMsgs.data(), sendMsgs.size()); receiver.setBaseOts(sendMsgs); } else { - BitVector bv(128); + + std::vector> sendMsgs(sender.baseOtCount()); + commonPRNG.get(sendMsgs.data(), sendMsgs.size()); + + BitVector bv(sendMsgs.size()); bv.randomize(commonPRNG); - std::array recvMsgs; - for (u64 i = 0; i < 128; ++i) + std::vector recvMsgs(sendMsgs.size()); + for (u64 i = 0; i < sendMsgs.size(); ++i) recvMsgs[i] = sendMsgs[i][bv[i]]; sender.setBaseOts(recvMsgs, bv); } @@ -198,7 +202,7 @@ namespace osuCrypto chl.close(); } } - + // make sure all messages have been sent. cp::sync_wait(chl.flush()); } @@ -320,7 +324,7 @@ namespace osuCrypto #else throw std::runtime_error("This example requires coproto to enable boost support. Please build libOTe with `-DCOPROTO_ENABLE_BOOST=ON`. " LOCATION); #endif - } + } @@ -346,4 +350,4 @@ namespace osuCrypto #endif return flagSet; } - } +}