gen_graphs.py 24 KB

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