Browse Source

Compute indoffset so as to avoid having to negate it later

When it might be an XOR index share later, we don't want to have to deal
with that.
Ian Goldberg 3 years ago
parent
commit
56b4c8f2e2
1 changed files with 4 additions and 4 deletions
  1. 4 4
      duoram.tcc

+ 4 - 4
duoram.tcc

@@ -126,8 +126,8 @@ Duoram<T>::Shape::MemRefAS::operator T()
         RDPFTriple dt = shape.tio.rdpftriple(shape.addr_size);
         RDPFTriple dt = shape.tio.rdpftriple(shape.addr_size);
 
 
         // Compute the index offset
         // Compute the index offset
-        RegAS indoffset = idx;
-        indoffset -= dt.as_target;
+        RegAS indoffset = dt.as_target;
+        indoffset -= idx;
 
 
         // We only need two of the DPFs for reading
         // We only need two of the DPFs for reading
         RDPFPair dp(std::move(dt), 0, player == 0 ? 2 : 1);
         RDPFPair dp(std::move(dt), 0, player == 0 ? 2 : 1);
@@ -146,7 +146,7 @@ Duoram<T>::Shape::MemRefAS::operator T()
         auto indshift = combine(indoffset, peerindoffset, shape.addr_size);
         auto indshift = combine(indoffset, peerindoffset, shape.addr_size);
 
 
         // Evaluate the DPFs and compute the dotproducts
         // Evaluate the DPFs and compute the dotproducts
-        StreamEval ev(dp, -indshift, shape.tio.aes_ops());
+        StreamEval ev(dp, indshift, shape.tio.aes_ops());
         for (size_t i=0; i<shape.shape_size; ++i) {
         for (size_t i=0; i<shape.shape_size; ++i) {
             auto L = ev.next();
             auto L = ev.next();
             // The values from the two DPFs
             // The values from the two DPFs
@@ -175,7 +175,7 @@ Duoram<T>::Shape::MemRefAS::operator T()
 
 
         // Evaluate the DPFs to compute the cancellation terms
         // Evaluate the DPFs to compute the cancellation terms
         T gamma0, gamma1;
         T gamma0, gamma1;
-        StreamEval ev(dp, -indshift, shape.tio.aes_ops());
+        StreamEval ev(dp, indshift, shape.tio.aes_ops());
         for (size_t i=0; i<shape.shape_size; ++i) {
         for (size_t i=0; i<shape.shape_size; ++i) {
             auto L = ev.next();
             auto L = ev.next();