G_XOR_2_1.java 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (C) 2010 by Yan Huang <yhuang@virginia.edu>
  2. package YaoGC;
  3. import java.math.BigInteger;
  4. import sprout.oram.PID;
  5. import sprout.oram.TID;
  6. import Cipher.Cipher;
  7. class G_XOR_2_1 extends XOR_2_1 {
  8. public G_XOR_2_1() {
  9. super();
  10. }
  11. protected void sendOutBitEncPair() {
  12. if (outputWires[0].outBitEncPair != null) {
  13. BigInteger[] lb = new BigInteger[2];
  14. lb[0] = outputWires[0].lbl;
  15. lb[1] = Wire.conjugate(lb[0]);
  16. int lsb = lb[0].testBit(0) ? 1 : 0;
  17. int k = outputWires[0].serialNum;
  18. timing.stopwatch[PID.sha1][TID.offline].start();
  19. outputWires[0].outBitEncPair[lsb] = Cipher.encrypt(k, lb[0], 0);
  20. outputWires[0].outBitEncPair[1 - lsb] = Cipher.encrypt(k, lb[1], 1);
  21. timing.stopwatch[PID.sha1][TID.offline].stop();
  22. timing.stopwatch[PID.gcf][TID.offline].stop();
  23. timing.stopwatch[PID.gcf][TID.offline_write].start();
  24. receiver.write(outputWires[0].outBitEncPair);
  25. timing.stopwatch[PID.gcf][TID.offline_write].stop();
  26. timing.stopwatch[PID.gcf][TID.offline].start();
  27. }
  28. }
  29. }