online.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. #include <bsd/stdlib.h> // arc4random_buf
  2. #include "online.hpp"
  3. #include "mpcops.hpp"
  4. #include "rdpf.hpp"
  5. #include "duoram.hpp"
  6. #include "cdpf.hpp"
  7. static void online_test(MPCIO &mpcio, yield_t &yield,
  8. const PRACOptions &opts, char **args)
  9. {
  10. nbits_t nbits = VALUE_BITS;
  11. if (*args) {
  12. nbits = atoi(*args);
  13. }
  14. size_t memsize = 9;
  15. MPCTIO tio(mpcio, 0);
  16. bool is_server = (mpcio.player == 2);
  17. RegAS *A = new RegAS[memsize];
  18. value_t V;
  19. RegBS F0, F1;
  20. RegXS X;
  21. if (!is_server) {
  22. A[0].randomize();
  23. A[1].randomize();
  24. F0.randomize();
  25. A[4].randomize();
  26. F1.randomize();
  27. A[6].randomize();
  28. A[7].randomize();
  29. X.randomize();
  30. arc4random_buf(&V, sizeof(V));
  31. printf("A:\n"); for (size_t i=0; i<memsize; ++i) printf("%3lu: %016lX\n", i, A[i].ashare);
  32. printf("V : %016lX\n", V);
  33. printf("F0 : %01X\n", F0.bshare);
  34. printf("F1 : %01X\n", F1.bshare);
  35. printf("X : %016lX\n", X.xshare);
  36. }
  37. std::vector<coro_t> coroutines;
  38. coroutines.emplace_back(
  39. [&](yield_t &yield) {
  40. mpc_mul(tio, yield, A[2], A[0], A[1], nbits);
  41. });
  42. coroutines.emplace_back(
  43. [&](yield_t &yield) {
  44. mpc_valuemul(tio, yield, A[3], V, nbits);
  45. });
  46. coroutines.emplace_back(
  47. [&](yield_t &yield) {
  48. mpc_flagmult(tio, yield, A[5], F0, A[4], nbits);
  49. });
  50. coroutines.emplace_back(
  51. [&](yield_t &yield) {
  52. mpc_oswap(tio, yield, A[6], A[7], F1, nbits);
  53. });
  54. coroutines.emplace_back(
  55. [&](yield_t &yield) {
  56. mpc_xs_to_as(tio, yield, A[8], X, nbits);
  57. });
  58. run_coroutines(yield, coroutines);
  59. if (!is_server) {
  60. printf("\n");
  61. printf("A:\n"); for (size_t i=0; i<memsize; ++i) printf("%3lu: %016lX\n", i, A[i].ashare);
  62. }
  63. // Check the answers
  64. if (mpcio.player == 1) {
  65. tio.queue_peer(A, memsize*sizeof(RegAS));
  66. tio.queue_peer(&V, sizeof(V));
  67. tio.queue_peer(&F0, sizeof(RegBS));
  68. tio.queue_peer(&F1, sizeof(RegBS));
  69. tio.queue_peer(&X, sizeof(RegXS));
  70. tio.send();
  71. } else if (mpcio.player == 0) {
  72. RegAS *B = new RegAS[memsize];
  73. RegBS BF0, BF1;
  74. RegXS BX;
  75. value_t BV;
  76. value_t *S = new value_t[memsize];
  77. bit_t SF0, SF1;
  78. value_t SX;
  79. tio.recv_peer(B, memsize*sizeof(RegAS));
  80. tio.recv_peer(&BV, sizeof(BV));
  81. tio.recv_peer(&BF0, sizeof(RegBS));
  82. tio.recv_peer(&BF1, sizeof(RegBS));
  83. tio.recv_peer(&BX, sizeof(RegXS));
  84. for(size_t i=0; i<memsize; ++i) S[i] = A[i].ashare+B[i].ashare;
  85. SF0 = F0.bshare ^ BF0.bshare;
  86. SF1 = F1.bshare ^ BF1.bshare;
  87. SX = X.xshare ^ BX.xshare;
  88. printf("S:\n"); for (size_t i=0; i<memsize; ++i) printf("%3lu: %016lX\n", i, S[i]);
  89. printf("SF0: %01X\n", SF0);
  90. printf("SF1: %01X\n", SF1);
  91. printf("SX : %016lX\n", SX);
  92. printf("\n%016lx\n", S[0]*S[1]-S[2]);
  93. printf("%016lx\n", (V*BV)-S[3]);
  94. printf("%016lx\n", (SF0*S[4])-S[5]);
  95. printf("%016lx\n", S[8]-SX);
  96. delete[] B;
  97. delete[] S;
  98. }
  99. delete[] A;
  100. }
  101. static void lamport_test(MPCIO &mpcio, yield_t &yield,
  102. const PRACOptions &opts, char **args)
  103. {
  104. // Create a bunch of threads and send a bunch of data to the other
  105. // peer, and receive their data. If an arg is specified, repeat
  106. // that many times. The Lamport clock at the end should be just the
  107. // number of repetitions. Subsequent args are the chunk size and
  108. // the number of chunks per message
  109. size_t niters = 1;
  110. size_t chunksize = 1<<20;
  111. size_t numchunks = 1;
  112. if (*args) {
  113. niters = atoi(*args);
  114. ++args;
  115. }
  116. if (*args) {
  117. chunksize = atoi(*args);
  118. ++args;
  119. }
  120. if (*args) {
  121. numchunks = atoi(*args);
  122. ++args;
  123. }
  124. int num_threads = opts.num_threads;
  125. boost::asio::thread_pool pool(num_threads);
  126. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  127. boost::asio::post(pool, [&mpcio, thread_num, niters, chunksize, numchunks] {
  128. MPCTIO tio(mpcio, thread_num);
  129. char *sendbuf = new char[chunksize];
  130. char *recvbuf = new char[chunksize*numchunks];
  131. for (size_t i=0; i<niters; ++i) {
  132. for (size_t chunk=0; chunk<numchunks; ++chunk) {
  133. arc4random_buf(sendbuf, chunksize);
  134. tio.queue_peer(sendbuf, chunksize);
  135. }
  136. tio.send();
  137. tio.recv_peer(recvbuf, chunksize*numchunks);
  138. }
  139. delete[] recvbuf;
  140. delete[] sendbuf;
  141. });
  142. }
  143. pool.join();
  144. }
  145. static void rdpf_test(MPCIO &mpcio, yield_t &yield,
  146. const PRACOptions &opts, char **args)
  147. {
  148. nbits_t depth=6;
  149. if (*args) {
  150. depth = atoi(*args);
  151. ++args;
  152. }
  153. int num_threads = opts.num_threads;
  154. boost::asio::thread_pool pool(num_threads);
  155. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  156. boost::asio::post(pool, [&mpcio, thread_num, depth] {
  157. MPCTIO tio(mpcio, thread_num);
  158. size_t &aes_ops = tio.aes_ops();
  159. if (mpcio.player == 2) {
  160. RDPFPair dp = tio.rdpfpair(depth);
  161. for (int i=0;i<2;++i) {
  162. const RDPF &dpf = dp.dpf[i];
  163. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  164. DPFnode leaf = dpf.leaf(x, aes_ops);
  165. RegBS ub = dpf.unit_bs(leaf);
  166. RegAS ua = dpf.unit_as(leaf);
  167. RegXS sx = dpf.scaled_xs(leaf);
  168. RegAS sa = dpf.scaled_as(leaf);
  169. printf("%04x %x %016lx %016lx %016lx\n", x,
  170. ub.bshare, ua.ashare, sx.xshare, sa.ashare);
  171. }
  172. printf("\n");
  173. }
  174. } else {
  175. RDPFTriple dt = tio.rdpftriple(depth);
  176. for (int i=0;i<3;++i) {
  177. const RDPF &dpf = dt.dpf[i];
  178. RegXS peer_scaled_xor;
  179. RegAS peer_scaled_sum;
  180. if (mpcio.player == 1) {
  181. tio.iostream_peer() << dpf.scaled_xor << dpf.scaled_sum;
  182. } else {
  183. tio.iostream_peer() >> peer_scaled_xor >> peer_scaled_sum;
  184. peer_scaled_sum += dpf.scaled_sum;
  185. peer_scaled_xor ^= dpf.scaled_xor;
  186. }
  187. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  188. DPFnode leaf = dpf.leaf(x, aes_ops);
  189. RegBS ub = dpf.unit_bs(leaf);
  190. RegAS ua = dpf.unit_as(leaf);
  191. RegXS sx = dpf.scaled_xs(leaf);
  192. RegAS sa = dpf.scaled_as(leaf);
  193. printf("%04x %x %016lx %016lx %016lx\n", x,
  194. ub.bshare, ua.ashare, sx.xshare, sa.ashare);
  195. if (mpcio.player == 1) {
  196. tio.iostream_peer() << ub << ua << sx << sa;
  197. } else {
  198. RegBS peer_ub;
  199. RegAS peer_ua;
  200. RegXS peer_sx;
  201. RegAS peer_sa;
  202. tio.iostream_peer() >> peer_ub >> peer_ua >>
  203. peer_sx >> peer_sa;
  204. ub ^= peer_ub;
  205. ua += peer_ua;
  206. sx ^= peer_sx;
  207. sa += peer_sa;
  208. if (ub.bshare || ua.ashare || sx.xshare || sa.ashare) {
  209. printf("**** %x %016lx %016lx %016lx\n",
  210. ub.bshare, ua.ashare, sx.xshare, sa.ashare);
  211. printf("SCALE %016lx %016lx\n",
  212. peer_scaled_xor.xshare, peer_scaled_sum.ashare);
  213. }
  214. }
  215. }
  216. printf("\n");
  217. }
  218. }
  219. tio.send();
  220. });
  221. }
  222. pool.join();
  223. }
  224. static void rdpf_timing(MPCIO &mpcio, yield_t &yield,
  225. const PRACOptions &opts, char **args)
  226. {
  227. nbits_t depth=6;
  228. if (*args) {
  229. depth = atoi(*args);
  230. ++args;
  231. }
  232. int num_threads = opts.num_threads;
  233. boost::asio::thread_pool pool(num_threads);
  234. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  235. boost::asio::post(pool, [&mpcio, thread_num, depth] {
  236. MPCTIO tio(mpcio, thread_num);
  237. size_t &aes_ops = tio.aes_ops();
  238. if (mpcio.player == 2) {
  239. RDPFPair dp = tio.rdpfpair(depth);
  240. for (int i=0;i<2;++i) {
  241. RDPF &dpf = dp.dpf[i];
  242. dpf.expand(aes_ops);
  243. RegXS scaled_xor;
  244. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  245. DPFnode leaf = dpf.leaf(x, aes_ops);
  246. RegXS sx = dpf.scaled_xs(leaf);
  247. scaled_xor ^= sx;
  248. }
  249. printf("%016lx\n%016lx\n", scaled_xor.xshare,
  250. dpf.scaled_xor.xshare);
  251. printf("\n");
  252. }
  253. } else {
  254. RDPFTriple dt = tio.rdpftriple(depth);
  255. for (int i=0;i<3;++i) {
  256. RDPF &dpf = dt.dpf[i];
  257. dpf.expand(aes_ops);
  258. RegXS scaled_xor;
  259. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  260. DPFnode leaf = dpf.leaf(x, aes_ops);
  261. RegXS sx = dpf.scaled_xs(leaf);
  262. scaled_xor ^= sx;
  263. }
  264. printf("%016lx\n%016lx\n", scaled_xor.xshare,
  265. dpf.scaled_xor.xshare);
  266. printf("\n");
  267. }
  268. }
  269. tio.send();
  270. });
  271. }
  272. pool.join();
  273. }
  274. static void rdpfeval_timing(MPCIO &mpcio, yield_t &yield,
  275. const PRACOptions &opts, char **args)
  276. {
  277. nbits_t depth=6;
  278. address_t start=0;
  279. if (*args) {
  280. depth = atoi(*args);
  281. ++args;
  282. }
  283. if (*args) {
  284. start = atoi(*args);
  285. ++args;
  286. }
  287. int num_threads = opts.num_threads;
  288. boost::asio::thread_pool pool(num_threads);
  289. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  290. boost::asio::post(pool, [&mpcio, thread_num, depth, start] {
  291. MPCTIO tio(mpcio, thread_num);
  292. size_t &aes_ops = tio.aes_ops();
  293. if (mpcio.player == 2) {
  294. RDPFPair dp = tio.rdpfpair(depth);
  295. for (int i=0;i<2;++i) {
  296. RDPF &dpf = dp.dpf[i];
  297. RegXS scaled_xor;
  298. auto ev = StreamEval(dpf, start, 0, aes_ops, false);
  299. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  300. DPFnode leaf = ev.next();
  301. RegXS sx = dpf.scaled_xs(leaf);
  302. scaled_xor ^= sx;
  303. }
  304. printf("%016lx\n%016lx\n", scaled_xor.xshare,
  305. dpf.scaled_xor.xshare);
  306. printf("\n");
  307. }
  308. } else {
  309. RDPFTriple dt = tio.rdpftriple(depth);
  310. for (int i=0;i<3;++i) {
  311. RDPF &dpf = dt.dpf[i];
  312. RegXS scaled_xor;
  313. auto ev = StreamEval(dpf, start, 0, aes_ops, false);
  314. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  315. DPFnode leaf = ev.next();
  316. RegXS sx = dpf.scaled_xs(leaf);
  317. scaled_xor ^= sx;
  318. }
  319. printf("%016lx\n%016lx\n", scaled_xor.xshare,
  320. dpf.scaled_xor.xshare);
  321. printf("\n");
  322. }
  323. }
  324. tio.send();
  325. });
  326. }
  327. pool.join();
  328. }
  329. static void tupleeval_timing(MPCIO &mpcio, yield_t &yield,
  330. const PRACOptions &opts, char **args)
  331. {
  332. nbits_t depth=6;
  333. address_t start=0;
  334. if (*args) {
  335. depth = atoi(*args);
  336. ++args;
  337. }
  338. if (*args) {
  339. start = atoi(*args);
  340. ++args;
  341. }
  342. int num_threads = opts.num_threads;
  343. boost::asio::thread_pool pool(num_threads);
  344. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  345. boost::asio::post(pool, [&mpcio, thread_num, depth, start] {
  346. MPCTIO tio(mpcio, thread_num);
  347. size_t &aes_ops = tio.aes_ops();
  348. if (mpcio.player == 2) {
  349. RDPFPair dp = tio.rdpfpair(depth);
  350. RegXS scaled_xor0, scaled_xor1;
  351. auto ev = StreamEval(dp, start, 0, aes_ops, false);
  352. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  353. auto [L0, L1] = ev.next();
  354. RegXS sx0 = dp.dpf[0].scaled_xs(L0);
  355. RegXS sx1 = dp.dpf[1].scaled_xs(L1);
  356. scaled_xor0 ^= sx0;
  357. scaled_xor1 ^= sx1;
  358. }
  359. printf("%016lx\n%016lx\n", scaled_xor0.xshare,
  360. dp.dpf[0].scaled_xor.xshare);
  361. printf("\n");
  362. printf("%016lx\n%016lx\n", scaled_xor1.xshare,
  363. dp.dpf[1].scaled_xor.xshare);
  364. printf("\n");
  365. } else {
  366. RDPFTriple dt = tio.rdpftriple(depth);
  367. RegXS scaled_xor0, scaled_xor1, scaled_xor2;
  368. auto ev = StreamEval(dt, start, 0, aes_ops, false);
  369. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  370. auto [L0, L1, L2] = ev.next();
  371. RegXS sx0 = dt.dpf[0].scaled_xs(L0);
  372. RegXS sx1 = dt.dpf[1].scaled_xs(L1);
  373. RegXS sx2 = dt.dpf[2].scaled_xs(L2);
  374. scaled_xor0 ^= sx0;
  375. scaled_xor1 ^= sx1;
  376. scaled_xor2 ^= sx2;
  377. }
  378. printf("%016lx\n%016lx\n", scaled_xor0.xshare,
  379. dt.dpf[0].scaled_xor.xshare);
  380. printf("\n");
  381. printf("%016lx\n%016lx\n", scaled_xor1.xshare,
  382. dt.dpf[1].scaled_xor.xshare);
  383. printf("\n");
  384. printf("%016lx\n%016lx\n", scaled_xor2.xshare,
  385. dt.dpf[2].scaled_xor.xshare);
  386. printf("\n");
  387. }
  388. tio.send();
  389. });
  390. }
  391. pool.join();
  392. }
  393. // T is RegAS or RegXS for additive or XOR shared database respectively
  394. template <typename T>
  395. static void duoram_test(MPCIO &mpcio, yield_t &yield,
  396. const PRACOptions &opts, char **args)
  397. {
  398. nbits_t depth=6;
  399. address_t share=arc4random();
  400. if (*args) {
  401. depth = atoi(*args);
  402. ++args;
  403. }
  404. if (*args) {
  405. share = atoi(*args);
  406. ++args;
  407. }
  408. share &= ((address_t(1)<<depth)-1);
  409. int num_threads = opts.num_threads;
  410. boost::asio::thread_pool pool(num_threads);
  411. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  412. boost::asio::post(pool, [&mpcio, &yield, thread_num, depth, share] {
  413. size_t size = size_t(1)<<depth;
  414. MPCTIO tio(mpcio, thread_num);
  415. // size_t &aes_ops = tio.aes_ops();
  416. Duoram<T> oram(mpcio.player, size);
  417. auto A = oram.flat(tio, yield);
  418. RegAS aidx;
  419. aidx.ashare = share;
  420. T M;
  421. if (tio.player() == 0) {
  422. M.set(0xbabb0000);
  423. } else {
  424. M.set(0x0000a66e);
  425. }
  426. RegXS xidx;
  427. xidx.xshare = share;
  428. T N;
  429. if (tio.player() == 0) {
  430. N.set(0xdead0000);
  431. } else {
  432. N.set(0x0000beef);
  433. }
  434. // Writing and reading with additively shared indices
  435. printf("Updating\n");
  436. A[aidx] += M;
  437. printf("Reading\n");
  438. T Aa = A[aidx];
  439. // Writing and reading with XOR shared indices
  440. printf("Updating\n");
  441. A[xidx] += N;
  442. printf("Reading\n");
  443. T Ax = A[xidx];
  444. T Ae;
  445. // Writing and reading with explicit indices
  446. if (depth > 2) {
  447. A[5] += Aa;
  448. Ae = A[6];
  449. }
  450. if (depth <= 10) {
  451. oram.dump();
  452. auto check = A.reconstruct();
  453. if (tio.player() == 0) {
  454. for (address_t i=0;i<size;++i) {
  455. printf("%04x %016lx\n", i, check[i].share());
  456. }
  457. }
  458. }
  459. auto checkread = A.reconstruct(Aa);
  460. auto checkreade = A.reconstruct(Ae);
  461. auto checkreadx = A.reconstruct(Ax);
  462. if (tio.player() == 0) {
  463. printf("Read AS value = %016lx\n", checkread.share());
  464. printf("Read AX value = %016lx\n", checkreadx.share());
  465. printf("Read Ex value = %016lx\n", checkreade.share());
  466. }
  467. tio.send();
  468. });
  469. }
  470. pool.join();
  471. }
  472. static void cdpf_test(MPCIO &mpcio, yield_t &yield,
  473. const PRACOptions &opts, char **args)
  474. {
  475. value_t query, target;
  476. arc4random_buf(&query, sizeof(query));
  477. arc4random_buf(&target, sizeof(target));
  478. if (*args) {
  479. query = strtoull(*args, NULL, 16);
  480. ++args;
  481. }
  482. if (*args) {
  483. target = strtoull(*args, NULL, 16);
  484. ++args;
  485. }
  486. int num_threads = opts.num_threads;
  487. boost::asio::thread_pool pool(num_threads);
  488. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  489. boost::asio::post(pool, [&mpcio, thread_num, &query, &target] {
  490. MPCTIO tio(mpcio, thread_num);
  491. size_t &aes_ops = tio.aes_ops();
  492. if (mpcio.player == 2) {
  493. auto [ dpf0, dpf1 ] = CDPF::generate(target, aes_ops);
  494. DPFnode leaf0 = dpf0.leaf(query, aes_ops);
  495. DPFnode leaf1 = dpf1.leaf(query, aes_ops);
  496. printf("DPFXOR_{%016lx}(%016lx} = ", target, query);
  497. dump_node(leaf0 ^ leaf1);
  498. } else {
  499. CDPF dpf = tio.cdpf();
  500. printf("ashare = %016lX\nxshare = %016lX\n",
  501. dpf.as_target.ashare, dpf.xs_target.xshare);
  502. DPFnode leaf = dpf.leaf(query, aes_ops);
  503. printf("DPF(%016lx) = ", query);
  504. dump_node(leaf);
  505. if (mpcio.player == 1) {
  506. tio.iostream_peer() << leaf;
  507. } else {
  508. DPFnode peerleaf;
  509. tio.iostream_peer() >> peerleaf;
  510. printf("XOR = ");
  511. dump_node(leaf ^ peerleaf);
  512. }
  513. }
  514. tio.send();
  515. });
  516. }
  517. pool.join();
  518. }
  519. void online_main(MPCIO &mpcio, const PRACOptions &opts, char **args)
  520. {
  521. // Run everything inside a coroutine so that simple tests don't have
  522. // to start one themselves
  523. MPCTIO tio(mpcio, 0);
  524. std::vector<coro_t> coroutines;
  525. coroutines.emplace_back(
  526. [&](yield_t &yield) {
  527. if (!*args) {
  528. std::cerr << "Mode is required as the first argument when not preprocessing.\n";
  529. return;
  530. } else if (!strcmp(*args, "test")) {
  531. ++args;
  532. online_test(mpcio, yield, opts, args);
  533. } else if (!strcmp(*args, "lamporttest")) {
  534. ++args;
  535. lamport_test(mpcio, yield, opts, args);
  536. } else if (!strcmp(*args, "rdpftest")) {
  537. ++args;
  538. rdpf_test(mpcio, yield, opts, args);
  539. } else if (!strcmp(*args, "rdpftime")) {
  540. ++args;
  541. rdpf_timing(mpcio, yield, opts, args);
  542. } else if (!strcmp(*args, "evaltime")) {
  543. ++args;
  544. rdpfeval_timing(mpcio, yield, opts, args);
  545. } else if (!strcmp(*args, "tupletime")) {
  546. ++args;
  547. tupleeval_timing(mpcio, yield, opts, args);
  548. } else if (!strcmp(*args, "duotest")) {
  549. ++args;
  550. if (opts.use_xor_db) {
  551. duoram_test<RegXS>(mpcio, yield, opts, args);
  552. } else {
  553. duoram_test<RegAS>(mpcio, yield, opts, args);
  554. }
  555. } else if (!strcmp(*args, "cdpftest")) {
  556. ++args;
  557. cdpf_test(mpcio, yield, opts, args);
  558. } else {
  559. std::cerr << "Unknown mode " << *args << "\n";
  560. }
  561. });
  562. run_coroutines(tio, coroutines);
  563. }