@@ -135,7 +135,7 @@ namespace osuCrypto
135
135
// otherwise we perform a base OT protocol to
136
136
// generate the needed OTs.
137
137
task<> genSilentBaseOts (PRNG& prng, Socket& chl)
138
- {
138
+ try {
139
139
#ifdef LIBOTE_HAS_BASE_OT
140
140
141
141
#if defined ENABLE_MRR_TWIST && defined ENABLE_SSE
@@ -150,24 +150,20 @@ namespace osuCrypto
150
150
using BaseOT = DefaultBaseOT;
151
151
#endif
152
152
153
- auto choice = BitVector{};
154
- auto bb = BitVector{};
155
- auto msg = AlignedUnVector<block>{};
156
- auto baseVole = std::vector<block>{};
157
- auto baseOt = BaseOT{};
158
- auto chl2 = Socket{};
159
- auto prng2 = PRNG{};
160
- auto noiseVals = VecG{};
161
- auto baseAs = VecF{};
162
- auto nv = NoisyVoleReceiver<F, G, Ctx>{};
153
+ // auto choice = BitVector{};
154
+ // auto bb = BitVector{};
155
+ // auto msg = AlignedUnVector<block>{};
156
+ // auto baseVole = std::vector<block>{};
157
+ // auto baseOt = BaseOT{};
158
+ // auto nv = NoisyVoleReceiver<F, G, Ctx>{};
163
159
164
160
165
161
setTimePoint (" SilentVoleReceiver.genSilent.begin" );
166
162
if (isConfigured () == false )
167
163
throw std::runtime_error (" configure must be called first" );
168
164
169
- choice = sampleBaseChoiceBits (prng);
170
- msg. resize (choice.size ());
165
+ auto choice = sampleBaseChoiceBits (prng);
166
+ AlignedUnVector<block> msg (choice.size ());
171
167
172
168
// sample the noise vector noiseVals such that we will compute
173
169
//
@@ -183,9 +179,11 @@ namespace osuCrypto
183
179
// plus voleDeltaShares[i] added to the appreciate spot. Similarly, the
184
180
// other party will program the PPRF to output their share of delta * noiseVals.
185
181
//
186
- noiseVals = sampleBaseVoleVals (prng);
182
+ auto noiseVals = sampleBaseVoleVals (prng);
183
+ auto baseAs = VecF{};
187
184
mCtx .resize (baseAs, noiseVals.size ());
188
185
186
+ auto nv = NoisyVoleReceiver<F, G, Ctx>{};
189
187
if (mTimer )
190
188
nv.setTimer (*mTimer );
191
189
@@ -201,7 +199,7 @@ namespace osuCrypto
201
199
if (mOtExtSender ->hasBaseOts () == false )
202
200
{
203
201
msg.resize (msg.size () + mOtExtSender ->baseOtCount ());
204
- bb. resize ( mOtExtSender ->baseOtCount ()) ;
202
+ auto bb = BitVector{ mOtExtSender ->baseOtCount () } ;
205
203
bb.randomize (prng);
206
204
choice.append (bb);
207
205
@@ -218,9 +216,8 @@ namespace osuCrypto
218
216
}
219
217
else
220
218
{
221
- chl2 = chl.fork ();
222
- prng2.SetSeed (prng.get ());
223
-
219
+ auto chl2 = chl.fork ();
220
+ auto prng2 = prng.fork ();
224
221
225
222
co_await (
226
223
macoro::when_all_ready (
@@ -234,8 +231,9 @@ namespace osuCrypto
234
231
}
235
232
else
236
233
{
237
- chl2 = chl.fork ();
238
- prng2.SetSeed (prng.get ());
234
+ auto chl2 = chl.fork ();
235
+ auto prng2 = prng.fork ();
236
+ BaseOT baseOt;
239
237
240
238
co_await (
241
239
macoro::when_all_ready (
@@ -250,7 +248,12 @@ namespace osuCrypto
250
248
throw std::runtime_error (" LIBOTE_HAS_BASE_OT = false, must enable relic, sodium or simplest ot asm." LOCATION);
251
249
co_return ;
252
250
#endif
253
- };
251
+ }
252
+ catch (...)
253
+ {
254
+ chl.close ();
255
+ throw ;
256
+ }
254
257
255
258
// configure the silent OT extension. This sets
256
259
// the parameters and figures out how many base OT
@@ -268,10 +271,8 @@ namespace osuCrypto
268
271
mState = State::Configured;
269
272
mBaseType = type;
270
273
271
-
272
274
syndromeDecodingConfigure (mNumPartitions , mSizePer , mNoiseVecSize , mSecParam , mRequestSize , mMultType );
273
275
274
-
275
276
mGen .configure (mSizePer , mNumPartitions );
276
277
}
277
278
@@ -286,7 +287,6 @@ namespace osuCrypto
286
287
throw std::runtime_error (" configure must be called first" );
287
288
288
289
return mGen .baseOtCount ();
289
-
290
290
}
291
291
292
292
// The silent base OTs must have specially set base OTs.
@@ -306,7 +306,7 @@ namespace osuCrypto
306
306
VecG sampleBaseVoleVals (PRNG& prng)
307
307
{
308
308
if (isConfigured () == false )
309
- throw RTE_LOC ;
309
+ throw std::runtime_error ( " configure must be called first. " LOCATION) ;
310
310
311
311
// sample the values of the noisy coordinate of c
312
312
// and perform a noicy vole to get a = b + mD * c
@@ -400,9 +400,10 @@ namespace osuCrypto
400
400
VecF& a,
401
401
PRNG& prng,
402
402
Socket& chl)
403
- {
403
+ try {
404
+
404
405
if (c.size () != a.size ())
405
- throw RTE_LOC ;
406
+ throw std::runtime_error ( " input sizes do not match. " LOCATION) ;
406
407
407
408
co_await (silentReceiveInplace (c.size (), prng, chl));
408
409
@@ -411,6 +412,11 @@ namespace osuCrypto
411
412
412
413
clear ();
413
414
}
415
+ catch (...)
416
+ {
417
+ chl.close ();
418
+ throw ;
419
+ }
414
420
415
421
// Perform the actual OT extension. If silent
416
422
// base OTs have been generated or set, then
@@ -420,11 +426,10 @@ namespace osuCrypto
420
426
u64 n,
421
427
PRNG& prng,
422
428
Socket& chl)
423
- {
429
+ try {
424
430
auto myHash = std::array<u8, 32 >{};
425
431
auto theirHash = std::array<u8, 32 >{};
426
432
gTimer .setTimePoint (" SilentVoleReceiver.ot.enter" );
427
-
428
433
if (isConfigured () == false )
429
434
{
430
435
// first generate 128 normal base OTs
@@ -434,9 +439,13 @@ namespace osuCrypto
434
439
if (mRequestSize < n)
435
440
throw std::invalid_argument (" n does not match the requested number of OTs via configure(...). " LOCATION);
436
441
442
+
437
443
if (hasSilentBaseOts () == false )
438
444
{
445
+ std::cout << " r genBase " << std::endl;
439
446
co_await (genSilentBaseOts (prng, chl));
447
+ std::cout << " r genBase done" << std::endl;
448
+
440
449
}
441
450
442
451
// allocate mA
@@ -472,8 +481,13 @@ namespace osuCrypto
472
481
//
473
482
// mA = mB + mS(mBaseC * mDelta)
474
483
//
484
+
485
+ std::cout << " r expand" << std::endl;
486
+
475
487
co_await (mGen .expand (chl, mA , PprfOutputFormat::Interleaved, true , mNumThreads ));
476
488
489
+ std::cout << " r expand done" << std::endl;
490
+
477
491
setTimePoint (" SilentVoleReceiver.expand.pprf_transpose" );
478
492
479
493
// populate the noisy coordinates of mC and
@@ -494,19 +508,27 @@ namespace osuCrypto
494
508
495
509
if (mMalType == SilentSecType::Malicious)
496
510
{
511
+ std::cout << " r mal" << std::endl;
512
+
497
513
co_await (chl.send (std::move (mMalCheckSeed )));
498
514
499
515
if constexpr (MaliciousSupported)
500
516
myHash = ferretMalCheck ();
501
- else
517
+ else {
502
518
throw std::runtime_error (" malicious is currently only supported for GF128 block. " LOCATION);
519
+ }
503
520
504
521
co_await (chl.recv (theirHash));
505
522
506
523
if (theirHash != myHash)
507
- throw RTE_LOC;
524
+ {
525
+ throw std::runtime_error (" malcicious security check failed. " LOCATION);
526
+ }
527
+ std::cout << " r mal done" << std::endl;
528
+
508
529
}
509
530
531
+
510
532
switch (mMultType )
511
533
{
512
534
case osuCrypto::MultType::ExConv7x24:
@@ -543,7 +565,9 @@ namespace osuCrypto
543
565
encoder.dualEncode (mC );
544
566
}
545
567
else
568
+ {
546
569
throw std::runtime_error (" QuasiCyclic is only supported for GF128, i.e. block. " LOCATION);
570
+ }
547
571
#else
548
572
throw std::runtime_error (" QuasiCyclic requires ENABLE_BITPOLYMUL = true. " LOCATION);
549
573
#endif
@@ -569,11 +593,18 @@ namespace osuCrypto
569
593
mBaseC = {};
570
594
mBaseA = {};
571
595
596
+ std::cout << " r done" << std::endl;
597
+
598
+
572
599
// make the protocol as done and that
573
600
// mA,mC are ready to be consumed.
574
601
mState = State::Default;
575
602
}
576
-
603
+ catch (...)
604
+ {
605
+ chl.close ();
606
+ throw ;
607
+ }
577
608
578
609
579
610
// internal.
0 commit comments