gen_graphs.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. #!/usr/bin/python3
  2. import sys
  3. import os
  4. import subprocess
  5. import numpy as np
  6. from numpy import genfromtxt
  7. import numpy.polynomial.polynomial as poly
  8. from operator import add
  9. import operator
  10. #import matplotlib as mpl
  11. #if os.environ.get('DISPLAY','') == '':
  12. # mpl.use('Agg')
  13. import matplotlib.pyplot as plt
  14. def quadratic_function(x, a, b, c):
  15. return a*x*x + b*x + c
  16. def linear_function(x, a, b):
  17. return a*x + b
  18. PLOT_PATHORAM = False
  19. PLOT_LSIPRM = False
  20. PLOT_CIRCUITORAM = False
  21. PLOT_ZEROTRACE = False
  22. if(len(sys.argv)>1):
  23. if(int(sys.argv[1])==1):
  24. PLOT_ZEROTRACE = True
  25. if(PLOT_ZEROTRACE):
  26. PLOT_CIRCUITORAM = True
  27. #List of plot files
  28. LF_PATHORAM='log_ZTPATHORAM'
  29. LF_CIRCUITORAM='log_ZTCIRCUITORAM'
  30. LF_LSIPRM='log_ZTLSORAM_IPRM'
  31. LF_LSOPRM='log_ZTLSORAM'
  32. FOLDER_XPIR='./XPIR/'
  33. LF_SEALPIR='log_SEALPIR'
  34. LF_SEALPIR_D1='log_SEALPIR_D1'
  35. DESC_SIZE=16384
  36. n= 10
  37. n_stop = 12000
  38. N = []
  39. while(n < n_stop):
  40. N.append(n)
  41. n = int(n * 8 / 5)
  42. print(N)
  43. plt.rc('font', size=18) # controls default text sizes
  44. plt.rc('axes', titlesize=18) # fontsize of the axes title
  45. plt.rc('axes', labelsize=18) # fontsize of the x and y labels
  46. plt.rc('xtick', labelsize=16) # fontsize of the tick labels
  47. plt.rc('ytick', labelsize=16) # fontsize of the tick labels
  48. plt.rc('legend', fontsize=14) # legend fontsize
  49. plt.rc('figure', titlesize=18) # fontsize of the figure title
  50. ########################
  51. LSIPRM_gtime=[]
  52. LSIPRM_ptime=[]
  53. LSIPRM_etime=[]
  54. LSIPRM_gtime_err=[]
  55. LSIPRM_ptime_err=[]
  56. LSIPRM_etime_err=[]
  57. LSIPRM_query_size=[]
  58. LSIPRM_response_size=[]
  59. LSIPRM_time = []
  60. LSIPRM_time_err = []
  61. LSOPRM_gtime=[]
  62. LSOPRM_ptime=[]
  63. LSOPRM_etime=[]
  64. LSOPRM_gtime_err=[]
  65. LSOPRM_ptime_err=[]
  66. LSOPRM_etime_err=[]
  67. LSOPRM_query_size=[]
  68. LSOPRM_response_size=[]
  69. LSOPRM_time = []
  70. LSOPRM_time_err = []
  71. CircuitORAM_gtime=[]
  72. CircuitORAM_ptime=[]
  73. CircuitORAM_etime=[]
  74. CircuitORAM_gtime_err=[]
  75. CircuitORAM_ptime_err=[]
  76. CircuitORAM_etime_err=[]
  77. CircuitORAM_query_size=[]
  78. CircuitORAM_response_size=[]
  79. CircuitORAM_time = []
  80. CircuitORAM_time_err = []
  81. PathORAM_gtime=[]
  82. PathORAM_ptime=[]
  83. PathORAM_etime=[]
  84. PathORAM_gtime_err=[]
  85. PathORAM_ptime_err=[]
  86. PathORAM_etime_err=[]
  87. PathORAM_query_size=[]
  88. PathORAM_response_size=[]
  89. PathORAM_time = []
  90. PathORAM_time_err = []
  91. XPIR_gtime=[]
  92. XPIR_ptime=[]
  93. XPIR_etime=[]
  94. XPIR_gtime_err=[]
  95. XPIR_ptime_err=[]
  96. XPIR_etime_err=[]
  97. XPIR_query_size=[]
  98. XPIR_response_size=[]
  99. XPIR_time = []
  100. XPIR_time_err =[]
  101. SealPIR_gtime=[]
  102. SealPIR_ptime=[]
  103. SealPIR_etime=[]
  104. SealPIR_gtime_err=[]
  105. SealPIR_ptime_err=[]
  106. SealPIR_etime_err=[]
  107. SealPIR_query_size=[]
  108. SealPIR_response_size=[]
  109. SealPIR_time = []
  110. SealPIR_time_err = []
  111. POINT_STYLES = [".","v","s","+","x","d",">","^","*","o","D"]
  112. ########################
  113. # NOTE N just needs to be picked once,
  114. # All plot files should have the same N range
  115. if(PLOT_PATHORAM):
  116. with open(LF_PATHORAM, 'r') as lfile:
  117. for line in lfile:
  118. values=line.split(',')
  119. PathORAM_gtime.append(float(values[1]))
  120. PathORAM_gtime_err.append(float(values[2]))
  121. PathORAM_ptime.append(float(values[3]))
  122. PathORAM_ptime_err.append(float(values[4]))
  123. PathORAM_etime.append(float(values[5]))
  124. PathORAM_etime_err.append(float(values[6]))
  125. PathORAM_query_size.append(int(values[7]))
  126. PathORAM_response_size.append(int(values[8]))
  127. if(PLOT_CIRCUITORAM):
  128. with open(LF_CIRCUITORAM, 'r') as lfile:
  129. for line in lfile:
  130. values=line.split(',')
  131. CircuitORAM_gtime.append(float(values[1]))
  132. CircuitORAM_gtime_err.append(float(values[2]))
  133. CircuitORAM_ptime.append(float(values[3]))
  134. CircuitORAM_ptime_err.append(float(values[4]))
  135. CircuitORAM_etime.append(float(values[5]))
  136. CircuitORAM_etime_err.append(float(values[6]))
  137. #CircuitORAM_query_size = int(values[7])
  138. #CircuitORAM_response_size = int(values[8])
  139. if(PLOT_LSIPRM):
  140. with open(LF_LSIPRM, 'r') as lfile:
  141. for line in lfile:
  142. values=line.split(',')
  143. LSIPRM_gtime.append(float(values[1]))
  144. LSIPRM_gtime_err.append(float(values[2]))
  145. LSIPRM_ptime.append(float(values[3]))
  146. LSIPRM_ptime_err.append(float(values[4]))
  147. LSIPRM_etime.append(float(values[5]))
  148. LSIPRM_etime_err.append(float(values[6]))
  149. #LSIPRM_query_size = int(values[7])
  150. #LSIPRM_response_size = int(values[8])
  151. if(PLOT_ZEROTRACE):
  152. with open(LF_LSOPRM, 'r') as lfile:
  153. for line in lfile:
  154. values=line.split(',')
  155. LSOPRM_gtime.append(float(values[1]))
  156. LSOPRM_gtime_err.append(float(values[2]))
  157. LSOPRM_ptime.append(float(values[3]))
  158. LSOPRM_ptime_err.append(float(values[4]))
  159. LSOPRM_etime.append(float(values[5]))
  160. LSOPRM_etime_err.append(float(values[6]))
  161. LSOPRM_query_size.append(int(values[7]))
  162. LSOPRM_response_size.append(int(values[8]))
  163. #SealPIR logs don't contain N
  164. with open(LF_SEALPIR, 'r') as lfile:
  165. for line in lfile:
  166. values = line.split(',')
  167. SealPIR_gtime.append(float(values[0]))
  168. SealPIR_gtime_err.append(float(values[1]))
  169. SealPIR_ptime.append(float(values[2]))
  170. SealPIR_ptime_err.append(float(values[3]))
  171. SealPIR_etime.append(float(values[4]))
  172. SealPIR_etime_err.append(float(values[5]))
  173. SealPIR_query_size.append(int(values[6]))
  174. SealPIR_response_size.append(int(values[7]))
  175. SealPIR_PPT=float(values[8])
  176. ########################
  177. XPIR_QE_TIME=[]
  178. XPIR_RE_TIME=[]
  179. XPIR_PQ_TIME=[]
  180. XPIR_REQUEST_SIZE=[]
  181. XPIR_RESPONSE_SIZE=[]
  182. XPIR_QE_STD=[]
  183. XPIR_RE_STD=[]
  184. XPIR_PQ_STD=[]
  185. XPIR_CLIENT_TIME=[]
  186. XPIR_CLIENT_STD=[]
  187. XPIR_d=[]
  188. XPIR_alpha=[]
  189. for n in N:
  190. FILE_NAME=FOLDER_XPIR+"XPIR_"+str(n)+"_"+str(DESC_SIZE)+"_0"
  191. qe_time=[]
  192. re_time=[]
  193. pq_time=[]
  194. client_time=[]
  195. request_size=0
  196. response_size=0
  197. d=0
  198. alpha=0
  199. with open(FILE_NAME,'r') as file_handle:
  200. ctr=0
  201. for line in file_handle:
  202. if(ctr!=0):
  203. words=(line.strip()).split(',')
  204. qe_time.append(float(words[0]))
  205. d=int(words[4])
  206. alpha=int(words[5])
  207. pq_time.append(float(words[6]))
  208. re_time.append(float(words[1]))
  209. client_time.append(float(words[0])+float(words[1]))
  210. request_size=(float(words[2]))
  211. response_size=(float(words[3]))
  212. ctr=ctr+1
  213. XPIR_REQUEST_SIZE.append(request_size)
  214. XPIR_RESPONSE_SIZE.append(response_size)
  215. XPIR_QE_TIME.append(np.mean(qe_time))
  216. XPIR_PQ_TIME.append(np.mean(pq_time))
  217. XPIR_RE_TIME.append(np.mean(re_time))
  218. XPIR_CLIENT_TIME.append(np.mean(client_time))
  219. XPIR_QE_STD.append(np.std(qe_time))
  220. XPIR_PQ_STD.append(np.std(pq_time))
  221. XPIR_RE_STD.append(np.std(re_time))
  222. XPIR_CLIENT_STD.append(np.std(client_time))
  223. XPIR_d.append(d)
  224. XPIR_alpha.append(alpha)
  225. ########################
  226. LSIPRM_ctime = np.add(LSIPRM_gtime, LSIPRM_etime)
  227. LSIPRM_ctime_err = np.add(LSIPRM_gtime_err, LSIPRM_etime_err)
  228. LSOPRM_ctime = np.add(LSOPRM_gtime, LSOPRM_etime)
  229. LSOPRM_ctime_err = np.add(LSOPRM_gtime_err, LSOPRM_etime_err)
  230. PathORAM_ctime = np.add(PathORAM_gtime, PathORAM_etime)
  231. PathORAM_ctime_err = np.add(PathORAM_gtime_err, PathORAM_etime_err)
  232. CircuitORAM_ctime = np.add(CircuitORAM_gtime, CircuitORAM_etime)
  233. CircuitORAM_ctime_err = np.add(CircuitORAM_gtime_err, CircuitORAM_etime_err)
  234. XPIR_ctime = np.add(XPIR_QE_TIME, XPIR_RE_TIME)
  235. XPIR_ctime_err = np.add(XPIR_QE_STD, XPIR_RE_STD)
  236. SealPIR_ctime = np.add(SealPIR_gtime, SealPIR_etime)
  237. SealPIR_ctime_err = np.add(SealPIR_gtime_err, SealPIR_etime_err)
  238. LSIPRM_time = np.add(LSIPRM_ctime, LSIPRM_ptime)
  239. LSIPRM_time_err = np.add(LSIPRM_ctime_err, LSIPRM_ptime_err)
  240. LSOPRM_time = np.add(LSOPRM_ctime, LSOPRM_ptime)
  241. LSOPRM_time_err = np.add(LSOPRM_ctime_err, LSOPRM_ptime_err)
  242. PathORAM_time = np.add(PathORAM_ctime, PathORAM_ptime)
  243. PathORAM_time_err = np.add(PathORAM_ctime_err, PathORAM_ptime_err)
  244. CircuitORAM_time = np.add(CircuitORAM_ctime, CircuitORAM_ptime)
  245. CircuitORAM_time_err = np.add(CircuitORAM_ctime_err, CircuitORAM_ptime_err)
  246. XPIR_time = np.add(XPIR_ctime, XPIR_PQ_TIME)
  247. XPIR_time_err = np.add(XPIR_ctime_err, XPIR_PQ_STD)
  248. SealPIR_time = np.add(SealPIR_ctime, SealPIR_ptime)
  249. SealPIR_time_err = np.add(SealPIR_ctime_err, SealPIR_ptime_err)
  250. plt.xlabel('Number of Hidden Service Descriptors')
  251. plt.ylabel('Server computation time per query (in ms)')
  252. plt.grid(True)
  253. plt.yscale('log')
  254. plt.xscale('log')
  255. c_ctr=0
  256. if(PLOT_PATHORAM):
  257. points1 = plt.plot(N, PathORAM_ptime, POINT_STYLES[c_ctr], label='PathORAM', color = str("C")+str(c_ctr))
  258. if(PLOT_CIRCUITORAM):
  259. points2 = plt.plot(N, CircuitORAM_ptime, POINT_STYLES[c_ctr+1], label='CircuitORAM', color = str("C")+str(c_ctr+1))
  260. if(PLOT_LSIPRM):
  261. points3 = plt.plot(N, LSIPRM_ptime, POINT_STYLES[c_ctr+2], label='Linear Scan (inside PRM)', color = str("C")+str(c_ctr+2))
  262. if(PLOT_ZEROTRACE):
  263. points4 = plt.plot(N, LSOPRM_ptime, POINT_STYLES[c_ctr+3], label='Linear Scan (outside PRM)', color = str("C")+str(c_ctr+3))
  264. points5 = plt.plot(N, XPIR_PQ_TIME, POINT_STYLES[c_ctr+4], label='XPIR', color = str("C")+str(c_ctr+4))
  265. points6 = plt.plot(N, SealPIR_ptime, POINT_STYLES[c_ctr+5], label='SealPIR', color = str("C")+str(c_ctr+5))
  266. points7 = plt.plot(N, SealPIR_ptime, POINT_STYLES[c_ctr+6], label='Trivial PIR', color = str("C")+str(c_ctr+6))
  267. if(PLOT_PATHORAM):
  268. errbar1 = plt.errorbar(N, PathORAM_ptime, PathORAM_ptime_err, None, 'r', ls='none', mew=3)
  269. if(PLOT_CIRCUITORAM):
  270. errbar2 = plt.errorbar(N, CircuitORAM_ptime, CircuitORAM_ptime_err, None, 'r', ls='none', mew=3)
  271. if(PLOT_LSIPRM):
  272. errbar3 = plt.errorbar(N, LSIPRM_ptime, LSIPRM_ptime_err, None, 'r', ls='none', mew=3)
  273. if(PLOT_ZEROTRACE):
  274. errbar4 = plt.errorbar(N, LSOPRM_ptime, LSOPRM_ptime_err, None, 'r', ls='none', mew=3)
  275. errbar5 = plt.errorbar(N, XPIR_PQ_TIME, XPIR_PQ_STD, None, 'r', ls='none', mew=3)
  276. errbar6 = plt.errorbar(N, SealPIR_ptime, SealPIR_ptime_err , None, 'r', ls='none', mew=3)
  277. if(PLOT_PATHORAM):
  278. plt.setp(points1, 'mew', '3.0')
  279. if(PLOT_CIRCUITORAM):
  280. plt.setp(points2, 'mew', '3.0')
  281. if(PLOT_LSIPRM):
  282. plt.setp(points3, 'mew', '3.0')
  283. if(PLOT_ZEROTRACE):
  284. plt.setp(points4, 'mew', '3.0')
  285. plt.setp(points5, 'mew', '3.0')
  286. plt.setp(points6, 'mew', '3.0')
  287. plt.setp(points7, 'mew', '0.0')
  288. #plt.setp(line1, 'linewidth', '2.0')
  289. #plt.setp(line2, 'linewidth', '2.0')
  290. ax = plt.subplot()
  291. handles, labels = ax.get_legend_handles_labels()
  292. labels_sort = [3,4,5,6,2,1,7]
  293. hl = sorted(zip(handles, labels, labels_sort),
  294. key=operator.itemgetter(2))
  295. handles2, labels2, labels_sort= zip(*hl)
  296. #ax.legend(handles2, labels2, loc = 7)
  297. plt.title('Server computation time (in ms) vs \nnumber of hidden service descriptors')
  298. ax.legend(handles2, labels2, loc='upper center', bbox_to_anchor=(0.5, -0.15), ncol=7, shadow=True, handletextpad=0.1, columnspacing=0.5)
  299. plt.savefig('server_time_microbenchmark.png', bbox_inches='tight')
  300. plt.close()
  301. ############################################################
  302. plt.xlabel('Number of Hidden Service Descriptors')
  303. plt.ylabel('Client query generation time per query (in ms)')
  304. plt.grid(True)
  305. plt.yscale('log')
  306. plt.xscale('log')
  307. c_ctr=0
  308. if(PLOT_PATHORAM):
  309. points1 = plt.plot(N, PathORAM_ctime, POINT_STYLES[c_ctr], label='PathORAM', color = str("C")+str(c_ctr))
  310. if(PLOT_CIRCUITORAM):
  311. points2 = plt.plot(N, CircuitORAM_ctime, POINT_STYLES[c_ctr+1], label='CircuitORAM', color = str("C")+str(c_ctr+1))
  312. if(PLOT_LSIPRM):
  313. points3 = plt.plot(N, LSIPRM_ctime, POINT_STYLES[c_ctr+2], label='Linear Scan (inside PRM)', color = str("C")+str(c_ctr+2))
  314. if(PLOT_ZEROTRACE):
  315. points4 = plt.plot(N, LSOPRM_gtime, POINT_STYLES[c_ctr+3], label='ZeroTrace', color = str("C")+str(c_ctr+3))
  316. points5 = plt.plot(N, XPIR_QE_TIME, POINT_STYLES[c_ctr+4], label='XPIR', color = str("C")+str(c_ctr+4))
  317. points6 = plt.plot(N, SealPIR_gtime, POINT_STYLES[c_ctr+5], label='SealPIR', color = str("C")+str(c_ctr+5))
  318. if(PLOT_PATHORAM):
  319. errbar1 = plt.errorbar(N, PathORAM_ctime, PathORAM_ctime_err, None, 'r', ls='none', mew=3)
  320. if(PLOT_CIRCUITORAM):
  321. errbar2 = plt.errorbar(N, CircuitORAM_ctime, CircuitORAM_ctime_err, None, 'r', ls='none', mew=3)
  322. if(PLOT_LSIPRM):
  323. errbar3 = plt.errorbar(N, LSIPRM_ctime, LSIPRM_ctime_err, None, 'r', ls='none', mew=3)
  324. if(PLOT_ZEROTRACE):
  325. errbar4 = plt.errorbar(N, LSOPRM_gtime, LSOPRM_gtime_err, None, 'r', ls='none', mew=3)
  326. errbar5 = plt.errorbar(N, XPIR_QE_TIME, XPIR_QE_STD, None, 'r', ls='none', mew=3)
  327. errbar6 = plt.errorbar(N, SealPIR_gtime, SealPIR_gtime_err , None, 'r', ls='none', mew=3)
  328. if(PLOT_PATHORAM):
  329. plt.setp(points1, 'mew', '3.0')
  330. if(PLOT_CIRCUITORAM):
  331. plt.setp(points2, 'mew', '3.0')
  332. if(PLOT_LSIPRM):
  333. plt.setp(points3, 'mew', '3.0')
  334. if(PLOT_ZEROTRACE):
  335. plt.setp(points4, 'mew', '3.0')
  336. plt.setp(points5, 'mew', '3.0')
  337. plt.setp(points6, 'mew', '3.0')
  338. #plt.setp(line1, 'linewidth', '2.0')
  339. #plt.setp(line2, 'linewidth', '2.0')
  340. ax = plt.subplot()
  341. handles, labels = ax.get_legend_handles_labels()
  342. labels_sort = [3,2,1]
  343. hl = sorted(zip(handles, labels, labels_sort),
  344. key=operator.itemgetter(2))
  345. handles2, labels2, labels_sort= zip(*hl)
  346. #ax.legend(handles2, labels2, loc = 7)
  347. plt.title('Client query generation time (in ms) \nvs number of hidden service descriptors')
  348. ax.legend(handles2, labels2, loc='upper center', bbox_to_anchor=(0.5, -0.15), ncol=2, shadow=True)
  349. plt.savefig('client_query_time_microbenchmark.png', bbox_inches='tight')
  350. plt.close()
  351. print("Done with client query time graph..")
  352. ############################################################
  353. plt.xlabel('Number of Hidden Service Descriptors')
  354. plt.ylabel('Client reply extraction time per query (in ms)')
  355. plt.grid(True)
  356. plt.yscale('log')
  357. plt.xscale('log')
  358. c_ctr=0
  359. if(PLOT_PATHORAM):
  360. points1 = plt.plot(N, PathORAM_ctime, POINT_STYLES[c_ctr], label='PathORAM', color = str("C")+str(c_ctr))
  361. if(PLOT_CIRCUITORAM):
  362. points2 = plt.plot(N, CircuitORAM_ctime, POINT_STYLES[c_ctr+1], label='CircuitORAM', color = str("C")+str(c_ctr+1))
  363. if(PLOT_LSIPRM):
  364. points3 = plt.plot(N, LSIPRM_ctime, POINT_STYLES[c_ctr+2], label='Linear Scan (inside PRM)', color = str("C")+str(c_ctr+2))
  365. if(PLOT_ZEROTRACE):
  366. points4 = plt.plot(N, LSOPRM_etime, POINT_STYLES[c_ctr+3], label='ZeroTrace', color = str("C")+str(c_ctr+3))
  367. points5 = plt.plot(N, XPIR_RE_TIME, POINT_STYLES[c_ctr+4], label='XPIR', color = str("C")+str(c_ctr+4))
  368. points6 = plt.plot(N, SealPIR_etime, POINT_STYLES[c_ctr+5], label='SealPIR', color = str("C")+str(c_ctr+5))
  369. if(PLOT_PATHORAM):
  370. errbar1 = plt.errorbar(N, PathORAM_ctime, PathORAM_ctime_err, None, 'r', ls='none', mew=3)
  371. if(PLOT_CIRCUITORAM):
  372. errbar2 = plt.errorbar(N, CircuitORAM_ctime, CircuitORAM_ctime_err, None, 'r', ls='none', mew=3)
  373. if(PLOT_LSIPRM):
  374. errbar3 = plt.errorbar(N, LSIPRM_ctime, LSIPRM_ctime_err, None, 'r', ls='none', mew=3)
  375. if(PLOT_ZEROTRACE):
  376. errbar4 = plt.errorbar(N, LSOPRM_etime, LSOPRM_etime_err, None, 'r', ls='none', mew=3)
  377. errbar5 = plt.errorbar(N, XPIR_RE_TIME, XPIR_RE_STD, None, 'r', ls='none', mew=3)
  378. errbar6 = plt.errorbar(N, SealPIR_etime, SealPIR_etime_err , None, 'r', ls='none', mew=3)
  379. if(PLOT_PATHORAM):
  380. plt.setp(points1, 'mew', '3.0')
  381. if(PLOT_CIRCUITORAM):
  382. plt.setp(points2, 'mew', '3.0')
  383. if(PLOT_LSIPRM):
  384. plt.setp(points3, 'mew', '3.0')
  385. if(PLOT_ZEROTRACE):
  386. plt.setp(points4, 'mew', '3.0')
  387. plt.setp(points5, 'mew', '3.0')
  388. plt.setp(points6, 'mew', '3.0')
  389. #plt.setp(line1, 'linewidth', '2.0')
  390. #plt.setp(line2, 'linewidth', '2.0')
  391. ax = plt.subplot()
  392. handles, labels = ax.get_legend_handles_labels()
  393. labels_sort = [3,2,1]
  394. hl = sorted(zip(handles, labels, labels_sort),
  395. key=operator.itemgetter(2))
  396. handles2, labels2, labels_sort= zip(*hl)
  397. #ax.legend(handles2, labels2, loc = 7)
  398. plt.title('Client reply extraction time (in ms) \nvs number of hidden service descriptors')
  399. ax.legend(handles2, labels2, loc='upper center', bbox_to_anchor=(0.5, -0.15), ncol=2, shadow=True)
  400. plt.savefig('client_reply_time_microbenchmark.png', bbox_inches='tight')
  401. plt.close()
  402. print("Done with client reply extraction time graph..")
  403. ############################################################
  404. plt.xlabel('Number of Hidden Service Descriptors')
  405. plt.ylabel('Client computation time per query (in ms)')
  406. plt.grid(True)
  407. plt.yscale('log')
  408. plt.xscale('log')
  409. c_ctr=0
  410. if(PLOT_PATHORAM):
  411. points1 = plt.plot(N, PathORAM_ctime, POINT_STYLES[c_ctr], label='PathORAM', color = str("C")+str(c_ctr))
  412. if(PLOT_CIRCUITORAM):
  413. points2 = plt.plot(N, CircuitORAM_ctime, POINT_STYLES[c_ctr+1], label='CircuitORAM', color = str("C")+str(c_ctr+1))
  414. if(PLOT_LSIPRM):
  415. points3 = plt.plot(N, LSIPRM_ctime, POINT_STYLES[c_ctr+2], label='Linear Scan (inside PRM)', color = str("C")+str(c_ctr+2))
  416. if(PLOT_ZEROTRACE):
  417. points4 = plt.plot(N, LSOPRM_ctime, POINT_STYLES[c_ctr+3], label='ZeroTrace', color = str("C")+str(c_ctr+3))
  418. points5 = plt.plot(N, XPIR_ctime, POINT_STYLES[c_ctr+4], label='XPIR', color = str("C")+str(c_ctr+4))
  419. points6 = plt.plot(N, SealPIR_ctime, POINT_STYLES[c_ctr+5], label='SealPIR', color = str("C")+str(c_ctr+5))
  420. if(PLOT_PATHORAM):
  421. errbar1 = plt.errorbar(N, PathORAM_ctime, PathORAM_ctime_err, None, 'r', ls='none', mew=3)
  422. if(PLOT_CIRCUITORAM):
  423. errbar2 = plt.errorbar(N, CircuitORAM_ctime, CircuitORAM_ctime_err, None, 'r', ls='none', mew=3)
  424. if(PLOT_LSIPRM):
  425. errbar3 = plt.errorbar(N, LSIPRM_ctime, LSIPRM_ctime_err, None, 'r', ls='none', mew=3)
  426. if(PLOT_ZEROTRACE):
  427. errbar4 = plt.errorbar(N, LSOPRM_ctime, LSOPRM_ctime_err, None, 'r', ls='none', mew=3)
  428. errbar5 = plt.errorbar(N, XPIR_ctime, XPIR_ctime_err, None, 'r', ls='none', mew=3)
  429. errbar6 = plt.errorbar(N, SealPIR_ctime, SealPIR_ctime_err , None, 'r', ls='none', mew=3)
  430. if(PLOT_PATHORAM):
  431. plt.setp(points1, 'mew', '3.0')
  432. if(PLOT_CIRCUITORAM):
  433. plt.setp(points2, 'mew', '3.0')
  434. if(PLOT_LSIPRM):
  435. plt.setp(points3, 'mew', '3.0')
  436. if(PLOT_ZEROTRACE):
  437. plt.setp(points4, 'mew', '3.0')
  438. plt.setp(points5, 'mew', '3.0')
  439. plt.setp(points6, 'mew', '3.0')
  440. #plt.setp(line1, 'linewidth', '2.0')
  441. #plt.setp(line2, 'linewidth', '2.0')
  442. ax = plt.subplot()
  443. handles, labels = ax.get_legend_handles_labels()
  444. labels_sort = [3,2,1]
  445. hl = sorted(zip(handles, labels, labels_sort),
  446. key=operator.itemgetter(2))
  447. handles2, labels2, labels_sort= zip(*hl)
  448. #ax.legend(handles2, labels2, loc = 7)
  449. plt.title('Client computation time (in ms) vs \nnumber of hidden service descriptors')
  450. ax.legend(handles2, labels2, loc='upper center', bbox_to_anchor=(0.5, -0.15), ncol=2, shadow=True)
  451. plt.savefig('client_time_microbenchmark.png', bbox_inches='tight')
  452. plt.close()
  453. print("Done with client computation time graph..")
  454. ###################################################################
  455. plt.xlabel('Number of Hidden Service Descriptors')
  456. plt.ylabel('Total time per query (in ms)')
  457. plt.grid(True)
  458. plt.yscale('log')
  459. plt.xscale('log')
  460. c_ctr=0
  461. if(PLOT_PATHORAM):
  462. points1 = plt.plot(N, PathORAM_time, POINT_STYLES[c_ctr], label='PathORAM', color = str("C")+str(c_ctr))
  463. if(PLOT_CIRCUITORAM):
  464. points2 = plt.plot(N, CircuitORAM_time, POINT_STYLES[c_ctr+1], label='CircuitORAM', color = str("C")+str(c_ctr+1))
  465. if(PLOT_LSIPRM):
  466. points3 = plt.plot(N, LSIPRM_time, POINT_STYLES[c_ctr+2], label='Linear Scan (inside PRM)', color = str("C")+str(c_ctr+2))
  467. if(PLOT_ZEROTRACE):
  468. points4 = plt.plot(N, LSOPRM_time, POINT_STYLES[c_ctr+3], label='Linear Scan (outside PRM)', color = str("C")+str(c_ctr+3))
  469. points5 = plt.plot(N, XPIR_time, POINT_STYLES[c_ctr+4], label='XPIR', color = str("C")+str(c_ctr+4))
  470. points6 = plt.plot(N, SealPIR_time, POINT_STYLES[c_ctr+5], label='SealPIR', color = str("C")+str(c_ctr+5))
  471. #points7 = plt.plot(N, SealPIR_D1_time, POINT_STYLES[c_ctr+6], label='SealPIR D=1', color = str("C")+str(c_ctr+5))
  472. if(PLOT_PATHORAM):
  473. errbar1 = plt.errorbar(N, PathORAM_time, PathORAM_time_err, None, 'r', ls='none', mew=3)
  474. if(PLOT_CIRCUITORAM):
  475. errbar2 = plt.errorbar(N, CircuitORAM_time, CircuitORAM_time_err, None, 'r', ls='none', mew=3)
  476. if(PLOT_LSIPRM):
  477. errbar3 = plt.errorbar(N, LSIPRM_time, LSIPRM_time_err, None, 'r', ls='none', mew=3)
  478. if(PLOT_ZEROTRACE):
  479. errbar4 = plt.errorbar(N, LSOPRM_time, LSOPRM_time_err, None, 'r', ls='none', mew=3)
  480. errbar5 = plt.errorbar(N, XPIR_time, XPIR_time_err, None, 'r', ls='none', mew=3)
  481. errbar6 = plt.errorbar(N, SealPIR_time, SealPIR_time_err , None, 'r', ls='none', mew=3)
  482. if(PLOT_PATHORAM):
  483. plt.setp(points1, 'mew', '3.0')
  484. if(PLOT_CIRCUITORAM):
  485. plt.setp(points2, 'mew', '3.0')
  486. if(PLOT_LSIPRM):
  487. plt.setp(points3, 'mew', '3.0')
  488. if(PLOT_ZEROTRACE):
  489. plt.setp(points4, 'mew', '3.0')
  490. plt.setp(points5, 'mew', '3.0')
  491. plt.setp(points6, 'mew', '3.0')
  492. #plt.setp(points7, 'mew', '3.0')
  493. #plt.setp(line1, 'linewidth', '2.0')
  494. #plt.setp(line2, 'linewidth', '2.0')
  495. ax = plt.subplot()
  496. handles, labels = ax.get_legend_handles_labels()
  497. #labels_sort = [4,5,6,7,3,2,1]
  498. labels_sort = [3,4,5,6,2,1]
  499. hl = sorted(zip(handles, labels, labels_sort),
  500. key=operator.itemgetter(2))
  501. handles2, labels2, labels_sort= zip(*hl)
  502. #ax.legend(handles2, labels2, loc = 7)
  503. plt.title('Total computation time (in ms) vs number of hidden service descriptors')
  504. ax.legend(handles2, labels2, loc='upper center', bbox_to_anchor=(0.5, -0.15), ncol=2, shadow=True)
  505. plt.savefig('total_time_microbenchmark.png', bbox_inches='tight')
  506. plt.close()
  507. print("Done with total time graph..")
  508. ###################################################################
  509. plt.xlabel('Number of Hidden Service Descriptors')
  510. plt.ylabel('Request size per query (in bytes)')
  511. plt.grid(True)
  512. plt.yscale('log')
  513. plt.xscale('log')
  514. c_ctr=0
  515. if(PLOT_ZEROTRACE):
  516. points4 = plt.plot(N, LSOPRM_query_size, POINT_STYLES[c_ctr+3], label='ZeroTrace', color = str("C")+str(c_ctr+3))
  517. points5 = plt.plot(N, XPIR_REQUEST_SIZE, POINT_STYLES[c_ctr+4], label='XPIR', color = str("C")+str(c_ctr+4))
  518. points6 = plt.plot(N, SealPIR_query_size, POINT_STYLES[c_ctr+5], label='SealPIR', color = str("C")+str(c_ctr+5))
  519. if(PLOT_ZEROTRACE):
  520. plt.setp(points4, 'mew', '3.0')
  521. plt.setp(points5, 'mew', '3.0')
  522. plt.setp(points6, 'mew', '3.0')
  523. ax = plt.subplot()
  524. handles, labels = ax.get_legend_handles_labels()
  525. labels_sort = [3,1,2]
  526. hl = sorted(zip(handles, labels, labels_sort),
  527. key=operator.itemgetter(2))
  528. handles2, labels2, labels_sort= zip(*hl)
  529. #ax.legend(handles2, labels2, loc = 7)
  530. plt.title('Request size (in bytes) vs \nnumber of hidden service descriptors')
  531. ax.legend(handles2, labels2, loc='upper center', bbox_to_anchor=(0.5, -0.15), ncol=2, shadow=True)
  532. plt.savefig('request_size.png', bbox_inches='tight')
  533. plt.close()
  534. print("Done with request size graph..")
  535. ###################################################################
  536. plt.xlabel('Number of Hidden Service Descriptors')
  537. plt.ylabel('Response size per query (in bytes)')
  538. plt.grid(True)
  539. plt.yscale('log')
  540. plt.xscale('log')
  541. c_ctr=0
  542. TrivialPIR_size = np.multiply(N, DESC_SIZE)
  543. if(PLOT_ZEROTRACE):
  544. points4 = plt.plot(N, LSOPRM_response_size, POINT_STYLES[c_ctr+3], label='ZeroTrace', color = str("C")+str(c_ctr+3))
  545. points5 = plt.plot(N, XPIR_RESPONSE_SIZE, POINT_STYLES[c_ctr+4], label='XPIR', color = str("C")+str(c_ctr+4))
  546. points6 = plt.plot(N, SealPIR_response_size, POINT_STYLES[c_ctr+5], label='SealPIR', color = str("C")+str(c_ctr+5))
  547. points7 = plt.plot(N, TrivialPIR_size, POINT_STYLES[c_ctr+6], label='Trivial PIR', color = str("C")+str(c_ctr+6))
  548. if(PLOT_ZEROTRACE):
  549. plt.setp(points4, 'mew', '3.0')
  550. plt.setp(points5, 'mew', '3.0')
  551. plt.setp(points6, 'mew', '3.0')
  552. plt.setp(points7, 'mew', '3.0')
  553. ax = plt.subplot()
  554. handles, labels = ax.get_legend_handles_labels()
  555. labels_sort = [4,2,3,1]
  556. hl = sorted(zip(handles, labels, labels_sort),
  557. key=operator.itemgetter(2))
  558. handles2, labels2, labels_sort= zip(*hl)
  559. #ax.legend(handles2, labels2, loc = 7)
  560. plt.title('Response size (in bytes) vs \nnumber of hidden service descriptors')
  561. ax.legend(handles2, labels2, loc='upper center', bbox_to_anchor=(0.5, -0.15), ncol=4, shadow=True)
  562. plt.savefig('response_size.png', bbox_inches='tight')
  563. plt.close()
  564. print("Done with response size graph..")
  565. ###################################################################
  566. plt.xlabel('Number of Hidden Service Descriptors')
  567. plt.ylabel('Total bandwidth per query (in bytes)')
  568. plt.grid(True)
  569. plt.yscale('log')
  570. plt.xscale('log')
  571. c_ctr=0
  572. LSOPRM_bw = np.add(LSOPRM_query_size, LSOPRM_response_size)
  573. XPIR_bw = np.add(XPIR_REQUEST_SIZE, XPIR_RESPONSE_SIZE)
  574. SealPIR_bw = np.add(SealPIR_query_size, SealPIR_response_size)
  575. if(PLOT_ZEROTRACE):
  576. points4 = plt.plot(N, LSOPRM_bw, POINT_STYLES[c_ctr+3], label='ZeroTrace', color = str("C")+str(c_ctr+3))
  577. points5 = plt.plot(N, XPIR_bw, POINT_STYLES[c_ctr+4], label='XPIR', color = str("C")+str(c_ctr+4))
  578. points6 = plt.plot(N, SealPIR_bw, POINT_STYLES[c_ctr+5], label='SealPIR', color = str("C")+str(c_ctr+5))
  579. points7 = plt.plot(N, TrivialPIR_size, POINT_STYLES[c_ctr+6], label='Trivial PIR', color = str("C")+str(c_ctr+6))
  580. if(PLOT_ZEROTRACE):
  581. plt.setp(points4, 'mew', '3.0')
  582. plt.setp(points5, 'mew', '3.0')
  583. plt.setp(points6, 'mew', '3.0')
  584. plt.setp(points7, 'mew', '3.0')
  585. ax = plt.subplot()
  586. handles, labels = ax.get_legend_handles_labels()
  587. #labels_sort = [4,1,3,2]
  588. labels_sort = [4,3,2,1]
  589. hl = sorted(zip(handles, labels, labels_sort),
  590. key=operator.itemgetter(2))
  591. handles2, labels2, labels_sort= zip(*hl)
  592. #ax.legend(handles2, labels2, loc = 7)
  593. plt.title('Total bandwidth required (in bytes) vs \nnumber of hidden service descriptors')
  594. ax.legend(handles2, labels2, loc='upper center', bbox_to_anchor=(0.5, -0.15), ncol=4, shadow=True)
  595. plt.savefig('total_bw.png', bbox_inches='tight')
  596. plt.close()
  597. print("Done with total bandwidth graph..")
  598. ###################################################################