online.cpp 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  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. #include "baltree.hpp"
  8. static void online_test(MPCIO &mpcio,
  9. const PRACOptions &opts, char **args)
  10. {
  11. nbits_t nbits = VALUE_BITS;
  12. if (*args) {
  13. nbits = atoi(*args);
  14. }
  15. size_t memsize = 9;
  16. MPCTIO tio(mpcio, 0);
  17. bool is_server = (mpcio.player == 2);
  18. RegAS *A = new RegAS[memsize];
  19. value_t V;
  20. RegBS F0, F1;
  21. RegXS X;
  22. if (!is_server) {
  23. A[0].randomize();
  24. A[1].randomize();
  25. F0.randomize();
  26. A[4].randomize();
  27. F1.randomize();
  28. A[6].randomize();
  29. A[7].randomize();
  30. X.randomize();
  31. arc4random_buf(&V, sizeof(V));
  32. printf("A:\n"); for (size_t i=0; i<memsize; ++i) printf("%3lu: %016lX\n", i, A[i].ashare);
  33. printf("V : %016lX\n", V);
  34. printf("F0 : %01X\n", F0.bshare);
  35. printf("F1 : %01X\n", F1.bshare);
  36. printf("X : %016lX\n", X.xshare);
  37. }
  38. std::vector<coro_t> coroutines;
  39. coroutines.emplace_back(
  40. [&tio, &A, nbits](yield_t &yield) {
  41. mpc_mul(tio, yield, A[2], A[0], A[1], nbits);
  42. });
  43. coroutines.emplace_back(
  44. [&tio, &A, V, nbits](yield_t &yield) {
  45. mpc_valuemul(tio, yield, A[3], V, nbits);
  46. });
  47. coroutines.emplace_back(
  48. [&tio, &A, &F0, nbits](yield_t &yield) {
  49. mpc_flagmult(tio, yield, A[5], F0, A[4], nbits);
  50. });
  51. coroutines.emplace_back(
  52. [&tio, &A, &F1, nbits](yield_t &yield) {
  53. mpc_oswap(tio, yield, A[6], A[7], F1, nbits);
  54. });
  55. coroutines.emplace_back(
  56. [&tio, &A, &X, nbits](yield_t &yield) {
  57. mpc_xs_to_as(tio, yield, A[8], X, nbits);
  58. });
  59. run_coroutines(tio, coroutines);
  60. if (!is_server) {
  61. printf("\n");
  62. printf("A:\n"); for (size_t i=0; i<memsize; ++i) printf("%3lu: %016lX\n", i, A[i].ashare);
  63. }
  64. // Check the answers
  65. if (mpcio.player == 1) {
  66. tio.queue_peer(A, memsize*sizeof(RegAS));
  67. tio.queue_peer(&V, sizeof(V));
  68. tio.queue_peer(&F0, sizeof(RegBS));
  69. tio.queue_peer(&F1, sizeof(RegBS));
  70. tio.queue_peer(&X, sizeof(RegXS));
  71. tio.send();
  72. } else if (mpcio.player == 0) {
  73. RegAS *B = new RegAS[memsize];
  74. RegBS BF0, BF1;
  75. RegXS BX;
  76. value_t BV;
  77. value_t *S = new value_t[memsize];
  78. bit_t SF0, SF1;
  79. value_t SX;
  80. tio.recv_peer(B, memsize*sizeof(RegAS));
  81. tio.recv_peer(&BV, sizeof(BV));
  82. tio.recv_peer(&BF0, sizeof(RegBS));
  83. tio.recv_peer(&BF1, sizeof(RegBS));
  84. tio.recv_peer(&BX, sizeof(RegXS));
  85. for(size_t i=0; i<memsize; ++i) S[i] = A[i].ashare+B[i].ashare;
  86. SF0 = F0.bshare ^ BF0.bshare;
  87. SF1 = F1.bshare ^ BF1.bshare;
  88. SX = X.xshare ^ BX.xshare;
  89. printf("S:\n"); for (size_t i=0; i<memsize; ++i) printf("%3lu: %016lX\n", i, S[i]);
  90. printf("SF0: %01X\n", SF0);
  91. printf("SF1: %01X\n", SF1);
  92. printf("SX : %016lX\n", SX);
  93. printf("\n%016lx\n", S[0]*S[1]-S[2]);
  94. printf("%016lx\n", (V*BV)-S[3]);
  95. printf("%016lx\n", (SF0*S[4])-S[5]);
  96. printf("%016lx\n", S[8]-SX);
  97. delete[] B;
  98. delete[] S;
  99. }
  100. delete[] A;
  101. }
  102. static void lamport_test(MPCIO &mpcio,
  103. const PRACOptions &opts, char **args)
  104. {
  105. // Create a bunch of threads and send a bunch of data to the other
  106. // peer, and receive their data. If an arg is specified, repeat
  107. // that many times. The Lamport clock at the end should be just the
  108. // number of repetitions. Subsequent args are the chunk size and
  109. // the number of chunks per message
  110. size_t niters = 1;
  111. size_t chunksize = 1<<20;
  112. size_t numchunks = 1;
  113. if (*args) {
  114. niters = atoi(*args);
  115. ++args;
  116. }
  117. if (*args) {
  118. chunksize = atoi(*args);
  119. ++args;
  120. }
  121. if (*args) {
  122. numchunks = atoi(*args);
  123. ++args;
  124. }
  125. int num_threads = opts.num_threads;
  126. boost::asio::thread_pool pool(num_threads);
  127. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  128. boost::asio::post(pool, [&mpcio, thread_num, niters, chunksize, numchunks] {
  129. MPCTIO tio(mpcio, thread_num);
  130. char *sendbuf = new char[chunksize];
  131. char *recvbuf = new char[chunksize*numchunks];
  132. for (size_t i=0; i<niters; ++i) {
  133. for (size_t chunk=0; chunk<numchunks; ++chunk) {
  134. arc4random_buf(sendbuf, chunksize);
  135. tio.queue_peer(sendbuf, chunksize);
  136. }
  137. tio.send();
  138. tio.recv_peer(recvbuf, chunksize*numchunks);
  139. }
  140. delete[] recvbuf;
  141. delete[] sendbuf;
  142. });
  143. }
  144. pool.join();
  145. }
  146. static void rdpf_test(MPCIO &mpcio,
  147. const PRACOptions &opts, char **args)
  148. {
  149. nbits_t depth=6;
  150. size_t num_iters = 1;
  151. if (*args) {
  152. depth = atoi(*args);
  153. ++args;
  154. }
  155. if (*args) {
  156. num_iters = atoi(*args);
  157. ++args;
  158. }
  159. int num_threads = opts.num_threads;
  160. boost::asio::thread_pool pool(num_threads);
  161. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  162. boost::asio::post(pool, [&mpcio, thread_num, depth, num_iters] {
  163. MPCTIO tio(mpcio, thread_num);
  164. run_coroutines(tio, [&tio, depth, num_iters] (yield_t &yield) {
  165. size_t &aes_ops = tio.aes_ops();
  166. for (size_t iter=0; iter < num_iters; ++iter) {
  167. if (tio.player() == 2) {
  168. RDPFPair dp = tio.rdpfpair(yield, depth);
  169. for (int i=0;i<2;++i) {
  170. const RDPF &dpf = dp.dpf[i];
  171. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  172. DPFnode leaf = dpf.leaf(x, aes_ops);
  173. RegBS ub = dpf.unit_bs(leaf);
  174. RegAS ua = dpf.unit_as(leaf);
  175. RegXS sx = dpf.scaled_xs(leaf);
  176. RegAS sa = dpf.scaled_as(leaf);
  177. printf("%04x %x %016lx %016lx %016lx\n", x,
  178. ub.bshare, ua.ashare, sx.xshare, sa.ashare);
  179. }
  180. printf("\n");
  181. }
  182. } else {
  183. RDPFTriple dt = tio.rdpftriple(yield, depth);
  184. for (int i=0;i<3;++i) {
  185. const RDPF &dpf = dt.dpf[i];
  186. RegXS peer_scaled_xor;
  187. RegAS peer_scaled_sum;
  188. if (tio.player() == 1) {
  189. tio.iostream_peer() << dpf.scaled_xor << dpf.scaled_sum;
  190. } else {
  191. tio.iostream_peer() >> peer_scaled_xor >> peer_scaled_sum;
  192. peer_scaled_sum += dpf.scaled_sum;
  193. peer_scaled_xor ^= dpf.scaled_xor;
  194. }
  195. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  196. DPFnode leaf = dpf.leaf(x, aes_ops);
  197. RegBS ub = dpf.unit_bs(leaf);
  198. RegAS ua = dpf.unit_as(leaf);
  199. RegXS sx = dpf.scaled_xs(leaf);
  200. RegAS sa = dpf.scaled_as(leaf);
  201. printf("%04x %x %016lx %016lx %016lx\n", x,
  202. ub.bshare, ua.ashare, sx.xshare, sa.ashare);
  203. if (tio.player() == 1) {
  204. tio.iostream_peer() << ub << ua << sx << sa;
  205. } else {
  206. RegBS peer_ub;
  207. RegAS peer_ua;
  208. RegXS peer_sx;
  209. RegAS peer_sa;
  210. tio.iostream_peer() >> peer_ub >> peer_ua >>
  211. peer_sx >> peer_sa;
  212. ub ^= peer_ub;
  213. ua += peer_ua;
  214. sx ^= peer_sx;
  215. sa += peer_sa;
  216. if (ub.bshare || ua.ashare || sx.xshare || sa.ashare) {
  217. printf("**** %x %016lx %016lx %016lx\n",
  218. ub.bshare, ua.ashare, sx.xshare, sa.ashare);
  219. printf("SCALE %016lx %016lx\n",
  220. peer_scaled_xor.xshare, peer_scaled_sum.ashare);
  221. }
  222. }
  223. }
  224. printf("\n");
  225. }
  226. }
  227. }
  228. });
  229. });
  230. }
  231. pool.join();
  232. }
  233. static void rdpf_timing(MPCIO &mpcio,
  234. const PRACOptions &opts, char **args)
  235. {
  236. nbits_t depth=6;
  237. if (*args) {
  238. depth = atoi(*args);
  239. ++args;
  240. }
  241. int num_threads = opts.num_threads;
  242. boost::asio::thread_pool pool(num_threads);
  243. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  244. boost::asio::post(pool, [&mpcio, thread_num, depth] {
  245. MPCTIO tio(mpcio, thread_num);
  246. run_coroutines(tio, [&tio, depth] (yield_t &yield) {
  247. size_t &aes_ops = tio.aes_ops();
  248. if (tio.player() == 2) {
  249. RDPFPair dp = tio.rdpfpair(yield, depth);
  250. for (int i=0;i<2;++i) {
  251. RDPF &dpf = dp.dpf[i];
  252. dpf.expand(aes_ops);
  253. RegXS scaled_xor;
  254. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  255. DPFnode leaf = dpf.leaf(x, aes_ops);
  256. RegXS sx = dpf.scaled_xs(leaf);
  257. scaled_xor ^= sx;
  258. }
  259. printf("%016lx\n%016lx\n", scaled_xor.xshare,
  260. dpf.scaled_xor.xshare);
  261. printf("\n");
  262. }
  263. } else {
  264. RDPFTriple dt = tio.rdpftriple(yield, depth);
  265. for (int i=0;i<3;++i) {
  266. RDPF &dpf = dt.dpf[i];
  267. dpf.expand(aes_ops);
  268. RegXS scaled_xor;
  269. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  270. DPFnode leaf = dpf.leaf(x, aes_ops);
  271. RegXS sx = dpf.scaled_xs(leaf);
  272. scaled_xor ^= sx;
  273. }
  274. printf("%016lx\n%016lx\n", scaled_xor.xshare,
  275. dpf.scaled_xor.xshare);
  276. printf("\n");
  277. }
  278. }
  279. });
  280. });
  281. }
  282. pool.join();
  283. }
  284. static value_t parallel_streameval_rdpf(MPCIO &mpcio, const RDPF &dpf,
  285. address_t start, int num_threads)
  286. {
  287. RegXS scaled_xor[num_threads];
  288. boost::asio::thread_pool pool(num_threads);
  289. address_t totsize = (address_t(1)<<dpf.depth());
  290. address_t threadstart = start;
  291. address_t threadchunk = totsize / num_threads;
  292. address_t threadextra = totsize % num_threads;
  293. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  294. address_t threadsize = threadchunk + (address_t(thread_num) < threadextra);
  295. boost::asio::post(pool,
  296. [&mpcio, &dpf, &scaled_xor, thread_num, threadstart, threadsize] {
  297. MPCTIO tio(mpcio, thread_num);
  298. //printf("Thread %d from %X for %X\n", thread_num, threadstart, threadsize);
  299. RegXS local_xor;
  300. size_t local_aes_ops = 0;
  301. auto ev = StreamEval(dpf, threadstart, 0, local_aes_ops);
  302. for (address_t x=0;x<threadsize;++x) {
  303. //if (x%0x10000 == 0) printf("%d", thread_num);
  304. DPFnode leaf = ev.next();
  305. local_xor ^= dpf.scaled_xs(leaf);
  306. }
  307. scaled_xor[thread_num] = local_xor;
  308. tio.aes_ops() += local_aes_ops;
  309. //printf("Thread %d complete\n", thread_num);
  310. });
  311. threadstart = (threadstart + threadsize) % totsize;
  312. }
  313. pool.join();
  314. RegXS res;
  315. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  316. res ^= scaled_xor[thread_num];
  317. }
  318. return res.xshare;
  319. }
  320. static void rdpfeval_timing(MPCIO &mpcio,
  321. const PRACOptions &opts, char **args)
  322. {
  323. nbits_t depth=6;
  324. address_t start=0;
  325. if (*args) {
  326. depth = atoi(*args);
  327. ++args;
  328. }
  329. if (*args) {
  330. start = strtoull(*args, NULL, 16);
  331. ++args;
  332. }
  333. int num_threads = opts.num_threads;
  334. MPCTIO tio(mpcio, 0, num_threads);
  335. run_coroutines(tio, [&mpcio, &tio, depth, start, num_threads] (yield_t &yield) {
  336. if (tio.player() == 2) {
  337. RDPFPair dp = tio.rdpfpair(yield, depth);
  338. for (int i=0;i<2;++i) {
  339. RDPF &dpf = dp.dpf[i];
  340. value_t scaled_xor =
  341. parallel_streameval_rdpf(mpcio, dpf, start, num_threads);
  342. printf("%016lx\n%016lx\n", scaled_xor,
  343. dpf.scaled_xor.xshare);
  344. printf("\n");
  345. }
  346. } else {
  347. RDPFTriple dt = tio.rdpftriple(yield, depth);
  348. for (int i=0;i<3;++i) {
  349. RDPF &dpf = dt.dpf[i];
  350. value_t scaled_xor =
  351. parallel_streameval_rdpf(mpcio, dpf, start, num_threads);
  352. printf("%016lx\n%016lx\n", scaled_xor,
  353. dpf.scaled_xor.xshare);
  354. printf("\n");
  355. }
  356. }
  357. });
  358. }
  359. static void par_rdpfeval_timing(MPCIO &mpcio,
  360. const PRACOptions &opts, char **args)
  361. {
  362. nbits_t depth=6;
  363. address_t start=0;
  364. if (*args) {
  365. depth = atoi(*args);
  366. ++args;
  367. }
  368. if (*args) {
  369. start = strtoull(*args, NULL, 16);
  370. ++args;
  371. }
  372. int num_threads = opts.num_threads;
  373. MPCTIO tio(mpcio, 0, num_threads);
  374. run_coroutines(tio, [&tio, depth, start, num_threads] (yield_t &yield) {
  375. if (tio.player() == 2) {
  376. RDPFPair dp = tio.rdpfpair(yield, depth);
  377. for (int i=0;i<2;++i) {
  378. RDPF &dpf = dp.dpf[i];
  379. nbits_t depth = dpf.depth();
  380. auto pe = ParallelEval(dpf, start, 0,
  381. address_t(1)<<depth, num_threads, tio.aes_ops());
  382. RegXS result, init;
  383. result = pe.reduce(init, [&dpf] (int thread_num,
  384. address_t i, const RDPF::node &leaf) {
  385. return dpf.scaled_xs(leaf);
  386. });
  387. printf("%016lx\n%016lx\n", result.xshare,
  388. dpf.scaled_xor.xshare);
  389. printf("\n");
  390. }
  391. } else {
  392. RDPFTriple dt = tio.rdpftriple(yield, depth);
  393. for (int i=0;i<3;++i) {
  394. RDPF &dpf = dt.dpf[i];
  395. nbits_t depth = dpf.depth();
  396. auto pe = ParallelEval(dpf, start, 0,
  397. address_t(1)<<depth, num_threads, tio.aes_ops());
  398. RegXS result, init;
  399. result = pe.reduce(init, [&dpf] (int thread_num,
  400. address_t i, const RDPF::node &leaf) {
  401. return dpf.scaled_xs(leaf);
  402. });
  403. printf("%016lx\n%016lx\n", result.xshare,
  404. dpf.scaled_xor.xshare);
  405. printf("\n");
  406. }
  407. }
  408. });
  409. }
  410. static void tupleeval_timing(MPCIO &mpcio,
  411. const PRACOptions &opts, char **args)
  412. {
  413. nbits_t depth=6;
  414. address_t start=0;
  415. if (*args) {
  416. depth = atoi(*args);
  417. ++args;
  418. }
  419. if (*args) {
  420. start = atoi(*args);
  421. ++args;
  422. }
  423. int num_threads = opts.num_threads;
  424. MPCTIO tio(mpcio, 0, num_threads);
  425. run_coroutines(tio, [&tio, depth, start] (yield_t &yield) {
  426. size_t &aes_ops = tio.aes_ops();
  427. if (tio.player() == 2) {
  428. RDPFPair dp = tio.rdpfpair(yield, depth);
  429. RegXS scaled_xor0, scaled_xor1;
  430. auto ev = StreamEval(dp, start, 0, aes_ops, false);
  431. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  432. auto [L0, L1] = ev.next();
  433. RegXS sx0 = dp.dpf[0].scaled_xs(L0);
  434. RegXS sx1 = dp.dpf[1].scaled_xs(L1);
  435. scaled_xor0 ^= sx0;
  436. scaled_xor1 ^= sx1;
  437. }
  438. printf("%016lx\n%016lx\n", scaled_xor0.xshare,
  439. dp.dpf[0].scaled_xor.xshare);
  440. printf("\n");
  441. printf("%016lx\n%016lx\n", scaled_xor1.xshare,
  442. dp.dpf[1].scaled_xor.xshare);
  443. printf("\n");
  444. } else {
  445. RDPFTriple dt = tio.rdpftriple(yield, depth);
  446. RegXS scaled_xor0, scaled_xor1, scaled_xor2;
  447. auto ev = StreamEval(dt, start, 0, aes_ops, false);
  448. for (address_t x=0;x<(address_t(1)<<depth);++x) {
  449. auto [L0, L1, L2] = ev.next();
  450. RegXS sx0 = dt.dpf[0].scaled_xs(L0);
  451. RegXS sx1 = dt.dpf[1].scaled_xs(L1);
  452. RegXS sx2 = dt.dpf[2].scaled_xs(L2);
  453. scaled_xor0 ^= sx0;
  454. scaled_xor1 ^= sx1;
  455. scaled_xor2 ^= sx2;
  456. }
  457. printf("%016lx\n%016lx\n", scaled_xor0.xshare,
  458. dt.dpf[0].scaled_xor.xshare);
  459. printf("\n");
  460. printf("%016lx\n%016lx\n", scaled_xor1.xshare,
  461. dt.dpf[1].scaled_xor.xshare);
  462. printf("\n");
  463. printf("%016lx\n%016lx\n", scaled_xor2.xshare,
  464. dt.dpf[2].scaled_xor.xshare);
  465. printf("\n");
  466. }
  467. });
  468. }
  469. static void par_tupleeval_timing(MPCIO &mpcio,
  470. const PRACOptions &opts, char **args)
  471. {
  472. nbits_t depth=6;
  473. address_t start=0;
  474. if (*args) {
  475. depth = atoi(*args);
  476. ++args;
  477. }
  478. if (*args) {
  479. start = atoi(*args);
  480. ++args;
  481. }
  482. int num_threads = opts.num_threads;
  483. MPCTIO tio(mpcio, 0, num_threads);
  484. run_coroutines(tio, [&tio, depth, start, num_threads] (yield_t &yield) {
  485. size_t &aes_ops = tio.aes_ops();
  486. if (tio.player() == 2) {
  487. RDPFPair dp = tio.rdpfpair(yield, depth);
  488. auto pe = ParallelEval(dp, start, 0, address_t(1)<<depth,
  489. num_threads, aes_ops);
  490. using V = std::tuple<RegXS,RegXS>;
  491. V result, init;
  492. result = pe.reduce(init, [&dp] (int thread_num, address_t i,
  493. const RDPFPair::node &leaf) {
  494. return dp.scaled<RegXS>(leaf);
  495. });
  496. printf("%016lx\n%016lx\n", std::get<0>(result).xshare,
  497. dp.dpf[0].scaled_xor.xshare);
  498. printf("\n");
  499. printf("%016lx\n%016lx\n", std::get<1>(result).xshare,
  500. dp.dpf[1].scaled_xor.xshare);
  501. printf("\n");
  502. } else {
  503. RDPFTriple dt = tio.rdpftriple(yield, depth);
  504. auto pe = ParallelEval(dt, start, 0, address_t(1)<<depth,
  505. num_threads, aes_ops);
  506. using V = std::tuple<RegXS,RegXS,RegXS>;
  507. V result, init;
  508. result = pe.reduce(init, [&dt] (int thread_num, address_t i,
  509. const RDPFTriple::node &leaf) {
  510. return dt.scaled<RegXS>(leaf);
  511. });
  512. printf("%016lx\n%016lx\n", std::get<0>(result).xshare,
  513. dt.dpf[0].scaled_xor.xshare);
  514. printf("\n");
  515. printf("%016lx\n%016lx\n", std::get<1>(result).xshare,
  516. dt.dpf[1].scaled_xor.xshare);
  517. printf("\n");
  518. printf("%016lx\n%016lx\n", std::get<2>(result).xshare,
  519. dt.dpf[2].scaled_xor.xshare);
  520. printf("\n");
  521. }
  522. });
  523. }
  524. // T is RegAS or RegXS for additive or XOR shared database respectively
  525. template <typename T>
  526. static void duoram_test(MPCIO &mpcio,
  527. const PRACOptions &opts, char **args)
  528. {
  529. nbits_t depth=6;
  530. address_t share=arc4random();
  531. if (*args) {
  532. depth = atoi(*args);
  533. ++args;
  534. }
  535. if (*args) {
  536. share = atoi(*args);
  537. ++args;
  538. }
  539. share &= ((address_t(1)<<depth)-1);
  540. MPCTIO tio(mpcio, 0, opts.num_threads);
  541. run_coroutines(tio, [&tio, depth, share] (yield_t &yield) {
  542. size_t size = size_t(1)<<depth;
  543. // size_t &aes_ops = tio.aes_ops();
  544. Duoram<T> oram(tio.player(), size);
  545. auto A = oram.flat(tio, yield);
  546. RegAS aidx, aidx2, aidx3;
  547. aidx.ashare = share;
  548. aidx2.ashare = share + tio.player();
  549. aidx3.ashare = share + 1;
  550. T M;
  551. if (tio.player() == 0) {
  552. M.set(0xbabb0000);
  553. } else {
  554. M.set(0x0000a66e);
  555. }
  556. RegXS xidx;
  557. xidx.xshare = share;
  558. T N;
  559. if (tio.player() == 0) {
  560. N.set(0xdead0000);
  561. } else {
  562. N.set(0x0000beef);
  563. }
  564. // Writing and reading with additively shared indices
  565. printf("Additive Updating\n");
  566. A[aidx] += M;
  567. printf("Additive Reading\n");
  568. T Aa = A[aidx];
  569. // Writing and reading with XOR shared indices
  570. printf("XOR Updating\n");
  571. A[xidx] += N;
  572. printf("XOR Reading\n");
  573. T Ax = A[xidx];
  574. T Ae;
  575. // Writing and reading with explicit indices
  576. if (depth > 2) {
  577. printf("Explicit Updating\n");
  578. A[5] += Aa;
  579. printf("Explicit Reading\n");
  580. Ae = A[6];
  581. }
  582. // Simultaneous independent reads
  583. printf("3 independent reading\n");
  584. std::vector<T> Av = A.indep(std::array {
  585. aidx, aidx2, aidx3
  586. });
  587. // Simultaneous independent updates
  588. T Aw1, Aw2, Aw3;
  589. Aw1.set(0x101010101010101 * tio.player());
  590. Aw2.set(0x202020202020202 * tio.player());
  591. Aw3.set(0x303030303030303 * tio.player());
  592. printf("3 independent updating\n");
  593. A.indep(std::array { aidx, aidx2, aidx3 }) -=
  594. std::array { Aw1, Aw2, Aw3 };
  595. if (depth <= 10) {
  596. oram.dump();
  597. auto check = A.reconstruct();
  598. if (tio.player() == 0) {
  599. for (address_t i=0;i<size;++i) {
  600. printf("%04x %016lx\n", i, check[i].share());
  601. }
  602. }
  603. }
  604. auto checkread = A.reconstruct(Aa);
  605. auto checkreade = A.reconstruct(Ae);
  606. auto checkreadx = A.reconstruct(Ax);
  607. if (tio.player() == 0) {
  608. printf("Read AS value = %016lx\n", checkread.share());
  609. printf("Read AX value = %016lx\n", checkreadx.share());
  610. printf("Read Ex value = %016lx\n", checkreade.share());
  611. }
  612. for (auto &v : Av) {
  613. auto checkv = A.reconstruct(v);
  614. if (tio.player() == 0) {
  615. printf("Read Av value = %016lx\n", checkv.share());
  616. }
  617. }
  618. });
  619. }
  620. // This measures the same things as the Duoram paper: dependent and
  621. // independent reads, updates, writes, and interleaves
  622. // T is RegAS or RegXS for additive or XOR shared database respectively
  623. template <typename T>
  624. static void duoram(MPCIO &mpcio,
  625. const PRACOptions &opts, char **args)
  626. {
  627. nbits_t depth = 6;
  628. int items = 4;
  629. if (*args) {
  630. depth = atoi(*args);
  631. ++args;
  632. }
  633. if (*args) {
  634. items = atoi(*args);
  635. ++args;
  636. }
  637. MPCTIO tio(mpcio, 0, opts.num_threads);
  638. run_coroutines(tio, [&mpcio, &tio, depth, items] (yield_t &yield) {
  639. size_t size = size_t(1)<<depth;
  640. address_t mask = (depth < ADDRESS_MAX_BITS ?
  641. ((address_t(1)<<depth) - 1) : ~0);
  642. Duoram<T> oram(tio.player(), size);
  643. auto A = oram.flat(tio, yield);
  644. std::cout << "===== DEPENDENT UPDATES =====\n";
  645. mpcio.reset_stats();
  646. tio.reset_lamport();
  647. // Make a linked list of length items
  648. std::vector<T> list_indices;
  649. T prev_index, next_index;
  650. prev_index.randomize(depth);
  651. for (int i=0;i<items;++i) {
  652. next_index.randomize(depth);
  653. A[next_index] += prev_index;
  654. list_indices.push_back(next_index);
  655. prev_index = next_index;
  656. }
  657. tio.sync_lamport();
  658. mpcio.dump_stats(std::cout);
  659. std::cout << "\n===== DEPENDENT READS =====\n";
  660. mpcio.reset_stats();
  661. tio.reset_lamport();
  662. // Read the linked list starting with prev_index
  663. T cur_index = prev_index;
  664. for (int i=0;i<items;++i) {
  665. cur_index = A[cur_index];
  666. }
  667. tio.sync_lamport();
  668. mpcio.dump_stats(std::cout);
  669. std::cout << "\n===== INDEPENDENT READS =====\n";
  670. mpcio.reset_stats();
  671. tio.reset_lamport();
  672. // Read all the entries in the list at once
  673. std::vector<T> read_outputs = A.indep(list_indices);
  674. tio.sync_lamport();
  675. mpcio.dump_stats(std::cout);
  676. std::cout << "\n===== INDEPENDENT UPDATES =====\n";
  677. mpcio.reset_stats();
  678. tio.reset_lamport();
  679. // Make a vector of indices 1 larger than those in list_indices,
  680. // and a vector of values 1 larger than those in outputs
  681. std::vector<T> indep_indices, indep_values;
  682. T one;
  683. one.set(tio.player()); // Sets the shared value to 1
  684. for (int i=0;i<items;++i) {
  685. indep_indices.push_back(list_indices[i]+one);
  686. indep_values.push_back(read_outputs[i]+one);
  687. }
  688. // Update all the indices at once
  689. A.indep(indep_indices) += indep_values;
  690. tio.sync_lamport();
  691. mpcio.dump_stats(std::cout);
  692. std::cout << "\n===== DEPENDENT WRITES =====\n";
  693. mpcio.reset_stats();
  694. tio.reset_lamport();
  695. T two;
  696. two.set(2*tio.player()); // Sets the shared value to 2
  697. // For each address addr that's number i from the end of the
  698. // linked list, write i+1 into location addr+2
  699. for (int i=0;i<items;++i) {
  700. T val;
  701. val.set((i+1)*tio.player());
  702. A[list_indices[i]+two] = val;
  703. }
  704. tio.sync_lamport();
  705. mpcio.dump_stats(std::cout);
  706. std::cout << "\n===== DEPENDENT INTERLEAVED =====\n";
  707. mpcio.reset_stats();
  708. tio.reset_lamport();
  709. T three;
  710. three.set(3*tio.player()); // Sets the shared value to 3
  711. // Follow the linked list and whenever A[addr]=val, set
  712. // A[addr+3]=val+3
  713. cur_index = prev_index;
  714. for (int i=0;i<items;++i) {
  715. T next_index = A[cur_index];
  716. A[cur_index+three] = next_index+three;
  717. cur_index = next_index;
  718. }
  719. tio.sync_lamport();
  720. mpcio.dump_stats(std::cout);
  721. std::cout << "\n";
  722. mpcio.reset_stats();
  723. tio.reset_lamport();
  724. if (depth <= 30) {
  725. auto check = A.reconstruct();
  726. auto head = A.reconstruct(prev_index);
  727. if (tio.player() == 0) {
  728. int width = (depth+3)/4;
  729. printf("Head of linked list: %0*lx\n\n", width,
  730. head.share() & mask);
  731. std::cout << "Non-zero reconstructed database entries:\n";
  732. for (address_t i=0;i<size;++i) {
  733. value_t share = check[i].share() & mask;
  734. if (share) printf("%0*x: %0*lx\n", width, i, width, share);
  735. }
  736. }
  737. }
  738. });
  739. }
  740. static void cdpf_test(MPCIO &mpcio,
  741. const PRACOptions &opts, char **args)
  742. {
  743. value_t query, target;
  744. int iters = 1;
  745. arc4random_buf(&query, sizeof(query));
  746. arc4random_buf(&target, sizeof(target));
  747. if (*args) {
  748. query = strtoull(*args, NULL, 16);
  749. ++args;
  750. }
  751. if (*args) {
  752. target = strtoull(*args, NULL, 16);
  753. ++args;
  754. }
  755. if (*args) {
  756. iters = atoi(*args);
  757. ++args;
  758. }
  759. int num_threads = opts.num_threads;
  760. boost::asio::thread_pool pool(num_threads);
  761. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  762. boost::asio::post(pool, [&mpcio, thread_num, query, target, iters] {
  763. MPCTIO tio(mpcio, thread_num);
  764. run_coroutines(tio, [&tio, query, target, iters] (yield_t &yield) {
  765. size_t &aes_ops = tio.aes_ops();
  766. for (int i=0;i<iters;++i) {
  767. if (tio.player() == 2) {
  768. tio.cdpf(yield);
  769. auto [ dpf0, dpf1 ] = CDPF::generate(target, aes_ops);
  770. DPFnode leaf0 = dpf0.leaf(query, aes_ops);
  771. DPFnode leaf1 = dpf1.leaf(query, aes_ops);
  772. printf("DPFXOR_{%016lx}(%016lx} = ", target, query);
  773. dump_node(leaf0 ^ leaf1);
  774. } else {
  775. CDPF dpf = tio.cdpf(yield);
  776. printf("ashare = %016lX\nxshare = %016lX\n",
  777. dpf.as_target.ashare, dpf.xs_target.xshare);
  778. DPFnode leaf = dpf.leaf(query, aes_ops);
  779. printf("DPF(%016lx) = ", query);
  780. dump_node(leaf);
  781. if (tio.player() == 1) {
  782. tio.iostream_peer() << leaf;
  783. } else {
  784. DPFnode peerleaf;
  785. tio.iostream_peer() >> peerleaf;
  786. printf("XOR = ");
  787. dump_node(leaf ^ peerleaf);
  788. }
  789. }
  790. }
  791. });
  792. });
  793. }
  794. pool.join();
  795. }
  796. static int compare_test_one(MPCTIO &tio, yield_t &yield,
  797. value_t target, value_t x)
  798. {
  799. int player = tio.player();
  800. size_t &aes_ops = tio.aes_ops();
  801. int res = 1;
  802. if (player == 2) {
  803. // Create a CDPF pair with the given target
  804. auto [dpf0, dpf1] = CDPF::generate(target, aes_ops);
  805. // Send it and a share of x to the computational parties
  806. RegAS x0, x1;
  807. x0.randomize();
  808. x1.set(x-x0.share());
  809. tio.iostream_p0() << dpf0 << x0;
  810. tio.iostream_p1() << dpf1 << x1;
  811. } else {
  812. CDPF dpf;
  813. RegAS xsh;
  814. tio.iostream_server() >> dpf >> xsh;
  815. auto [lt, eq, gt] = dpf.compare(tio, yield, xsh, aes_ops);
  816. printf("%016lx %016lx %d %d %d ", target, x, lt.bshare,
  817. eq.bshare, gt.bshare);
  818. // Check the answer
  819. if (player == 1) {
  820. tio.iostream_peer() << xsh << lt << eq << gt;
  821. } else {
  822. RegAS peer_xsh;
  823. RegBS peer_lt, peer_eq, peer_gt;
  824. tio.iostream_peer() >> peer_xsh >> peer_lt >> peer_eq >> peer_gt;
  825. lt ^= peer_lt;
  826. eq ^= peer_eq;
  827. gt ^= peer_gt;
  828. xsh += peer_xsh;
  829. int lti = int(lt.bshare);
  830. int eqi = int(eq.bshare);
  831. int gti = int(gt.bshare);
  832. x = xsh.share();
  833. printf(": %d %d %d ", lti, eqi, gti);
  834. bool signbit = (x >> 63);
  835. if (lti + eqi + gti != 1) {
  836. printf("INCONSISTENT");
  837. res = 0;
  838. } else if (x == 0 && eqi) {
  839. printf("=");
  840. } else if (!signbit && gti) {
  841. printf(">");
  842. } else if (signbit && lti) {
  843. printf("<");
  844. } else {
  845. printf("INCORRECT");
  846. res = 0;
  847. }
  848. }
  849. printf("\n");
  850. }
  851. return res;
  852. }
  853. static int compare_test_target(MPCTIO &tio, yield_t &yield,
  854. value_t target, value_t x)
  855. {
  856. int res = 1;
  857. res &= compare_test_one(tio, yield, target, x);
  858. res &= compare_test_one(tio, yield, target, 0);
  859. res &= compare_test_one(tio, yield, target, 1);
  860. res &= compare_test_one(tio, yield, target, 15);
  861. res &= compare_test_one(tio, yield, target, 16);
  862. res &= compare_test_one(tio, yield, target, 17);
  863. res &= compare_test_one(tio, yield, target, -1);
  864. res &= compare_test_one(tio, yield, target, -15);
  865. res &= compare_test_one(tio, yield, target, -16);
  866. res &= compare_test_one(tio, yield, target, -17);
  867. res &= compare_test_one(tio, yield, target, (value_t(1)<<63));
  868. res &= compare_test_one(tio, yield, target, (value_t(1)<<63)+1);
  869. res &= compare_test_one(tio, yield, target, (value_t(1)<<63)-1);
  870. return res;
  871. }
  872. static void compare_test(MPCIO &mpcio,
  873. const PRACOptions &opts, char **args)
  874. {
  875. value_t target, x;
  876. arc4random_buf(&target, sizeof(target));
  877. arc4random_buf(&x, sizeof(x));
  878. if (*args) {
  879. target = strtoull(*args, NULL, 16);
  880. ++args;
  881. }
  882. if (*args) {
  883. x = strtoull(*args, NULL, 16);
  884. ++args;
  885. }
  886. int num_threads = opts.num_threads;
  887. boost::asio::thread_pool pool(num_threads);
  888. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  889. boost::asio::post(pool, [&mpcio, thread_num, target, x] {
  890. MPCTIO tio(mpcio, thread_num);
  891. run_coroutines(tio, [&tio, target, x] (yield_t &yield) {
  892. int res = 1;
  893. res &= compare_test_target(tio, yield, target, x);
  894. res &= compare_test_target(tio, yield, 0, x);
  895. res &= compare_test_target(tio, yield, 1, x);
  896. res &= compare_test_target(tio, yield, 15, x);
  897. res &= compare_test_target(tio, yield, 16, x);
  898. res &= compare_test_target(tio, yield, 17, x);
  899. res &= compare_test_target(tio, yield, -1, x);
  900. res &= compare_test_target(tio, yield, -15, x);
  901. res &= compare_test_target(tio, yield, -16, x);
  902. res &= compare_test_target(tio, yield, -17, x);
  903. res &= compare_test_target(tio, yield, (value_t(1)<<63), x);
  904. res &= compare_test_target(tio, yield, (value_t(1)<<63)+1, x);
  905. res &= compare_test_target(tio, yield, (value_t(1)<<63)-1, x);
  906. if (tio.player() == 0) {
  907. if (res == 1) {
  908. printf("All tests passed!\n");
  909. } else {
  910. printf("TEST FAILURES\n");
  911. }
  912. }
  913. });
  914. });
  915. }
  916. pool.join();
  917. }
  918. static void sort_test(MPCIO &mpcio,
  919. const PRACOptions &opts, char **args)
  920. {
  921. nbits_t depth=6;
  922. if (*args) {
  923. depth = atoi(*args);
  924. ++args;
  925. }
  926. int num_threads = opts.num_threads;
  927. boost::asio::thread_pool pool(num_threads);
  928. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  929. boost::asio::post(pool, [&mpcio, thread_num, depth] {
  930. MPCTIO tio(mpcio, thread_num);
  931. run_coroutines(tio, [&tio, depth] (yield_t &yield) {
  932. address_t size = address_t(1)<<depth;
  933. // size_t &aes_ops = tio.aes_ops();
  934. Duoram<RegAS> oram(tio.player(), size);
  935. auto A = oram.flat(tio, yield);
  936. A.explicitonly(true);
  937. // Initialize the memory to random values in parallel
  938. std::vector<coro_t> coroutines;
  939. for (address_t i=0; i<size; ++i) {
  940. coroutines.emplace_back(
  941. [&A, i](yield_t &yield) {
  942. auto Acoro = A.context(yield);
  943. RegAS v;
  944. v.randomize(62);
  945. Acoro[i] += v;
  946. });
  947. }
  948. run_coroutines(yield, coroutines);
  949. A.bitonic_sort(0, depth);
  950. if (depth <= 10) {
  951. oram.dump();
  952. auto check = A.reconstruct();
  953. if (tio.player() == 0) {
  954. for (address_t i=0;i<size;++i) {
  955. printf("%04x %016lx\n", i, check[i].share());
  956. }
  957. }
  958. }
  959. });
  960. });
  961. }
  962. pool.join();
  963. }
  964. static void bsearch_test(MPCIO &mpcio,
  965. const PRACOptions &opts, char **args)
  966. {
  967. value_t target;
  968. arc4random_buf(&target, sizeof(target));
  969. target >>= 1;
  970. nbits_t depth=6;
  971. if (*args) {
  972. depth = atoi(*args);
  973. ++args;
  974. }
  975. if (*args) {
  976. target = strtoull(*args, NULL, 16);
  977. ++args;
  978. }
  979. int num_threads = opts.num_threads;
  980. boost::asio::thread_pool pool(num_threads);
  981. for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
  982. boost::asio::post(pool, [&mpcio, thread_num, depth, target] {
  983. MPCTIO tio(mpcio, thread_num);
  984. run_coroutines(tio, [&tio, depth, target] (yield_t &yield) {
  985. address_t size = address_t(1)<<depth;
  986. RegAS tshare;
  987. if (tio.player() == 2) {
  988. // Send shares of the target to the computational
  989. // players
  990. RegAS tshare0, tshare1;
  991. tshare0.randomize();
  992. tshare1.set(target-tshare0.share());
  993. tio.iostream_p0() << tshare0;
  994. tio.iostream_p1() << tshare1;
  995. printf("Using target = %016lx\n", target);
  996. yield();
  997. } else {
  998. // Get the share of the target
  999. tio.iostream_server() >> tshare;
  1000. }
  1001. // Create a random database and sort it
  1002. // size_t &aes_ops = tio.aes_ops();
  1003. Duoram<RegAS> oram(tio.player(), size);
  1004. auto A = oram.flat(tio, yield);
  1005. A.explicitonly(true);
  1006. // Initialize the memory to random values in parallel
  1007. std::vector<coro_t> coroutines;
  1008. for (address_t i=0; i<size; ++i) {
  1009. coroutines.emplace_back(
  1010. [&A, i](yield_t &yield) {
  1011. auto Acoro = A.context(yield);
  1012. RegAS v;
  1013. v.randomize(62);
  1014. Acoro[i] += v;
  1015. });
  1016. }
  1017. run_coroutines(yield, coroutines);
  1018. A.bitonic_sort(0, depth);
  1019. // Binary search for the target
  1020. RegAS tindex = A.obliv_binary_search(tshare);
  1021. // Check the answer
  1022. if (tio.player() == 1) {
  1023. tio.iostream_peer() << tindex;
  1024. } else if (tio.player() == 0) {
  1025. RegAS peer_tindex;
  1026. tio.iostream_peer() >> peer_tindex;
  1027. tindex += peer_tindex;
  1028. }
  1029. if (depth <= 10) {
  1030. auto check = A.reconstruct();
  1031. if (tio.player() == 0) {
  1032. for (address_t i=0;i<size;++i) {
  1033. printf("%04x %016lx\n", i, check[i].share());
  1034. }
  1035. }
  1036. }
  1037. if (tio.player() == 0) {
  1038. printf("Found index = %lx\n", tindex.share());
  1039. }
  1040. });
  1041. });
  1042. }
  1043. pool.join();
  1044. }
  1045. void online_main(MPCIO &mpcio, const PRACOptions &opts, char **args)
  1046. {
  1047. MPCTIO tio(mpcio, 0);
  1048. if (!*args) {
  1049. std::cerr << "Mode is required as the first argument when not preprocessing.\n";
  1050. return;
  1051. } else if (!strcmp(*args, "test")) {
  1052. ++args;
  1053. online_test(mpcio, opts, args);
  1054. } else if (!strcmp(*args, "lamporttest")) {
  1055. ++args;
  1056. lamport_test(mpcio, opts, args);
  1057. } else if (!strcmp(*args, "rdpftest")) {
  1058. ++args;
  1059. rdpf_test(mpcio, opts, args);
  1060. } else if (!strcmp(*args, "rdpftime")) {
  1061. ++args;
  1062. rdpf_timing(mpcio, opts, args);
  1063. } else if (!strcmp(*args, "evaltime")) {
  1064. ++args;
  1065. rdpfeval_timing(mpcio, opts, args);
  1066. } else if (!strcmp(*args, "parevaltime")) {
  1067. ++args;
  1068. par_rdpfeval_timing(mpcio, opts, args);
  1069. } else if (!strcmp(*args, "tupletime")) {
  1070. ++args;
  1071. tupleeval_timing(mpcio, opts, args);
  1072. } else if (!strcmp(*args, "partupletime")) {
  1073. ++args;
  1074. par_tupleeval_timing(mpcio, opts, args);
  1075. } else if (!strcmp(*args, "duotest")) {
  1076. ++args;
  1077. if (opts.use_xor_db) {
  1078. duoram_test<RegXS>(mpcio, opts, args);
  1079. } else {
  1080. duoram_test<RegAS>(mpcio, opts, args);
  1081. }
  1082. } else if (!strcmp(*args, "cdpftest")) {
  1083. ++args;
  1084. cdpf_test(mpcio, opts, args);
  1085. } else if (!strcmp(*args, "cmptest")) {
  1086. ++args;
  1087. compare_test(mpcio, opts, args);
  1088. } else if (!strcmp(*args, "sorttest")) {
  1089. ++args;
  1090. sort_test(mpcio, opts, args);
  1091. } else if (!strcmp(*args, "bsearch")) {
  1092. ++args;
  1093. bsearch_test(mpcio, opts, args);
  1094. } else if (!strcmp(*args, "duoram")) {
  1095. ++args;
  1096. if (opts.use_xor_db) {
  1097. duoram<RegXS>(mpcio, opts, args);
  1098. } else {
  1099. duoram<RegAS>(mpcio, opts, args);
  1100. }
  1101. } else if (!strcmp(*args, "baltree")) {
  1102. ++args;
  1103. baltree(mpcio, opts, args);
  1104. } else {
  1105. std::cerr << "Unknown mode " << *args << "\n";
  1106. }
  1107. }