Przeglądaj źródła

changed the heap diagram to display the need for MAXINT

avadapal 7 miesięcy temu
rodzic
commit
4baf948729
2 zmienionych plików z 15 dodań i 3 usunięć
  1. 3 3
      heap.cpp
  2. 12 0
      heap.hpp

+ 3 - 3
heap.cpp

@@ -16,11 +16,11 @@ All the unused array indicies have MAX_INT stored in them
                                /   \
                               x2    x3
                              /  \   / \
-                            x4  x5 x6  x7
+                            x4  x5 x6  ()
 
   A Heap like above is stored in array like below.
 
-  NULL| x1 | x2 | x3 | x4 | x5 | x6 | x7 |
+  NULL| x1 | x2 | x3 | x4 | x5 | x6 | MAXINT |
 
 */
 
@@ -61,7 +61,7 @@ and adds the the value into the heap while keeping the heap property intact
  The bits of 'flag' and 'u' are then used in parallel Flag-Word multiplications, totaling 2 times the logarithm of the heap size, to shift the elements greater than 'insertval' down one position 
  And write 'insertval' into the resulting empty location in the path
  This process requires a single message of communication
- Overall, the insert protocol achieves efficient insertion of a new element into the heap, with a complexity of log(heap size) oblivious comparisons and log(heap size) oblivious swaps
+ Overall, the insert protocol achieves efficient insertion of a new element into the heap, with a complexity of log(log(heap size)) oblivious comparisons and 2xlog(heap size) oblivious swaps
 */
 void MinHeap::insert_optimized(MPCTIO tio, yield_t & yield, RegAS val) {
     auto HeapArray = oram.flat(tio, yield);

+ 12 - 0
heap.hpp

@@ -14,12 +14,23 @@ private:
     size_t num_items;
 
     // Basic restore heap property at a secret shared index
+    // Takes in as an input the XOR shares of the index at which
+    // the heap property has to be restored
+    // Returns the XOR shares of the smaller index
     RegXS restore_heap_property(MPCIO &mpcio, MPCTIO tio, yield_t & yield, RegXS index);
     
     // Optimized restore heap property at a secret shared index
+    // Takes in as an input the XOR shares of the index at which
+    // the heap property has to be restored
+    // Returns the XOR shares of the smaller index and 
+    // comparison between the left and right child
     std::pair<RegXS, RegBS> restore_heap_property_optimized(MPCTIO tio, yield_t & yield, RegXS index, size_t layer, typename Duoram<RegAS>::template OblivIndex<RegXS,3> oidx);
     
     // Restore heap property at an index in clear
+    // Takes in as an input the index (in clear) at which
+    // the heap property has to be restored
+    // Returns the XOR shares of the smaller index and 
+    // comparison between the left and right child
     std::pair<RegXS, RegBS> restore_heap_property_at_explicit_index(MPCTIO tio, yield_t & yield,  size_t index);
 
 public: 
@@ -28,6 +39,7 @@ public:
     // The extractmin protocol returns the minimum element (the root), removes it
     // and restores the heap property
     // and takes in a boolean parameter to decide if the basic or the optimized version needs to be run
+    // return value is the share of the minimum value (the root)
     RegAS extract_min(MPCIO &mpcio, MPCTIO tio, yield_t & yield, int is_optimized);
     
     // Intializes the heap array with 0x7fffffffffffff