Skip to content

Commit

Permalink
minor co_await changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ladnir committed Oct 28, 2024
1 parent e12bfbb commit 7e82275
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 2 additions & 0 deletions libOTe/Tools/Pprf/RegularPprf.h
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,8 @@ namespace osuCrypto
// The OTs are used in blocks of 8, so make sure that there is a whole
// number of blocks.
mBaseOTs.resize(roundUpTo(mPntCount, 8), mDepth);
if (mBaseOTs.size() < baseMessages.size())
throw RTE_LOC;
memcpy(mBaseOTs.data(), baseMessages.data(), baseMessages.size() * sizeof(block));
}

Expand Down
6 changes: 3 additions & 3 deletions libOTe/Vole/Noisy/NoisyVoleSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ namespace osuCrypto {

setTimePoint("NoisyVoleSender.ot.begin");

co_await(ot.receive(bv, otMsg, prng, chl));
co_await ot.receive(bv, otMsg, prng, chl);
setTimePoint("NoisyVoleSender.ot.end");

co_await(send(delta, b, prng, otMsg, chl, ctx));
co_await send(delta, b, prng, otMsg, chl, ctx);

} MACORO_CATCH(eptr) {
co_await chl.close();
Expand Down Expand Up @@ -100,7 +100,7 @@ namespace osuCrypto {

// receive the the excrypted one shares.
buffer.resize(xb.size() * b.size() * ctx.template byteSize<F>());
co_await(chl.recv(buffer));
co_await chl.recv(buffer);
ctx.resize(msg, xb.size() * b.size());
ctx.deserialize(buffer.begin(), buffer.end(), msg.begin());

Expand Down
30 changes: 15 additions & 15 deletions libOTe/Vole/Silent/SilentVoleReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ namespace osuCrypto
bb.randomize(prng);
choice.append(bb);

co_await(mOtExtRecver->receive(choice, msg, prng, chl));
co_await mOtExtRecver->receive(choice, msg, prng, chl);

mOtExtSender->setBaseOts(
span<block>(msg).subspan(
Expand All @@ -205,18 +205,18 @@ namespace osuCrypto
bb);

msg.resize(msg.size() - mOtExtSender->baseOtCount());
co_await(nv.receive(noiseVals, baseAs, prng, *mOtExtSender, chl, mCtx));
co_await nv.receive(noiseVals, baseAs, prng, *mOtExtSender, chl, mCtx);
}
else
{
auto chl2 = chl.fork();
auto prng2 = prng.fork();

co_await(
co_await
macoro::when_all_ready(
nv.receive(noiseVals, baseAs, prng2, *mOtExtSender, chl2, mCtx),
mOtExtRecver->receive(choice, msg, prng, chl)
));
);
}
#else
throw std::runtime_error("soft spoken must be enabled");
Expand All @@ -228,11 +228,11 @@ namespace osuCrypto
auto prng2 = prng.fork();
BaseOT baseOt;

co_await(
co_await
macoro::when_all_ready(
baseOt.receive(choice, msg, prng, chl),
nv.receive(noiseVals, baseAs, prng2, baseOt, chl2, mCtx))
);
;

}

Expand Down Expand Up @@ -400,7 +400,7 @@ namespace osuCrypto
if (c.size() != a.size())
throw std::runtime_error("input sizes do not match." LOCATION);

co_await(silentReceiveInplace(c.size(), prng, chl));
co_await silentReceiveInplace(c.size(), prng, chl);

mCtx.copy(mC.begin(), mC.begin() + c.size(), c.begin());
mCtx.copy(mA.begin(), mA.begin() + a.size(), a.begin());
Expand Down Expand Up @@ -437,7 +437,7 @@ namespace osuCrypto

if (hasSilentBaseOts() == false)
{
co_await(genSilentBaseOts(prng, chl));
co_await genSilentBaseOts(prng, chl);
}

// allocate mA
Expand Down Expand Up @@ -473,7 +473,7 @@ namespace osuCrypto
//
// mA = mB + mS(mBaseC * mDelta)
//
co_await(mGen.expand(chl, mA, PprfOutputFormat::Interleaved, true, mNumThreads));
co_await mGen.expand(chl, mA, PprfOutputFormat::Interleaved, true, mNumThreads);

setTimePoint("SilentVoleReceiver.expand.pprf_transpose");

Expand All @@ -488,22 +488,22 @@ namespace osuCrypto

if (mDebug)
{
co_await(checkRT(chl));
co_await checkRT(chl);
setTimePoint("SilentVoleReceiver.expand.checkRT");
}


if (mMalType == SilentSecType::Malicious)
{
co_await(chl.send(std::move(mMalCheckSeed)));
co_await chl.send(std::move(mMalCheckSeed));

if constexpr (MaliciousSupported)
myHash = ferretMalCheck();
else {
throw std::runtime_error("malicious is currently only supported for GF128 block. " LOCATION);
}

co_await(chl.recv(theirHash));
co_await chl.recv(theirHash);

if (theirHash != myHash)
{
Expand Down Expand Up @@ -601,19 +601,19 @@ namespace osuCrypto
// recv delta
buffer.resize(mCtx.template byteSize<F>());
mCtx.resize(delta, 1);
co_await(chl.recv(buffer));
co_await chl.recv(buffer);
mCtx.deserialize(buffer.begin(), buffer.end(), delta.begin());

// recv B
buffer.resize(mCtx.template byteSize<F>() * mA.size());
mCtx.resize(B, mA.size());
co_await(chl.recv(buffer));
co_await chl.recv(buffer);
mCtx.deserialize(buffer.begin(), buffer.end(), B.begin());

// recv the noisy values.
buffer.resize(mCtx.template byteSize<F>() * mBaseA.size());
mCtx.resize(baseB, mBaseA.size());
co_await(chl.recvResize(buffer));
co_await chl.recvResize(buffer);
mCtx.deserialize(buffer.begin(), buffer.end(), baseB.begin());

// it shoudl hold that
Expand Down

0 comments on commit 7e82275

Please sign in to comment.