PrePIRAccess.java 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package pir.precomputation;
  2. import communication.Communication;
  3. //import crypto.Crypto;
  4. import oram.Forest;
  5. import oram.Metadata;
  6. //import oram.Tuple;
  7. import protocols.Protocol;
  8. import protocols.struct.Party;
  9. import protocols.struct.PreData;
  10. import util.M;
  11. import util.P;
  12. import util.Timer;
  13. import util.Util;
  14. public class PrePIRAccess extends Protocol {
  15. private int pid = P.ACC;
  16. public PrePIRAccess(Communication con1, Communication con2) {
  17. super(con1, con2);
  18. }
  19. public void runE(PreData predata, int twotaupow, int numTuples, int[] tupleParam, Timer timer) {
  20. timer.start(pid, M.offline_comp);
  21. // SSCOT
  22. PrePIRCOT presscot = new PrePIRCOT(con1, con2);
  23. presscot.runE(predata, numTuples, timer);
  24. // SSIOT
  25. PrePIRIOT pressiot = new PrePIRIOT(con1, con2);
  26. pressiot.runE(predata, twotaupow, timer);
  27. // Access
  28. // predata.access_sigma = Util.randomPermutation(numTuples, Crypto.sr);
  29. predata.access_sigma = Util.identityPermutation(numTuples);
  30. // predata.access_p = new Tuple[numTuples];
  31. // for (int i = 0; i < numTuples; i++)
  32. // predata.access_p[i] = new Tuple(tupleParam[0], tupleParam[1],
  33. // tupleParam[2], tupleParam[3], Crypto.sr);
  34. timer.start(pid, M.offline_write);
  35. con1.write(predata.access_sigma);
  36. // con1.write(predata.access_p);
  37. timer.stop(pid, M.offline_write);
  38. timer.stop(pid, M.offline_comp);
  39. }
  40. public void runD(PreData predata, Timer timer) {
  41. timer.start(pid, M.offline_comp);
  42. // SSCOT
  43. PrePIRCOT presscot = new PrePIRCOT(con1, con2);
  44. presscot.runD(predata, 0, timer); // TODO: this is incorrect due to update
  45. // SSIOT
  46. PrePIRIOT pressiot = new PrePIRIOT(con1, con2);
  47. pressiot.runD(predata, timer);
  48. // Access
  49. timer.start(pid, M.offline_read);
  50. predata.access_sigma = con1.readIntArray();
  51. // predata.access_p = con1.readTupleArray();
  52. timer.stop(pid, M.offline_read);
  53. timer.stop(pid, M.offline_comp);
  54. }
  55. public void runC(Timer timer) {
  56. timer.start(pid, M.offline_comp);
  57. // SSCOT
  58. PrePIRCOT presscot = new PrePIRCOT(con1, con2);
  59. presscot.runC(null, timer);// TODO: this is incorrect due to update
  60. // SSIOT
  61. PrePIRIOT pressiot = new PrePIRIOT(con1, con2);
  62. pressiot.runC();
  63. timer.stop(pid, M.offline_comp);
  64. }
  65. @Override
  66. public void run(Party party, Metadata md, Forest forest) {
  67. }
  68. @Override
  69. public void run(Party party, Metadata md, Forest[] forest) {
  70. // TODO Auto-generated method stub
  71. }
  72. }