|
@@ -199,12 +199,12 @@ int MinHeap::insert(MPCTIO tio, yield_t & yield, RegAS val) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-#ifdef HEAP_DEBUG
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
void MinHeap::verify_heap_property(MPCTIO tio, yield_t & yield) {
|
|
|
|
|
@@ -237,8 +237,9 @@ void MinHeap::verify_heap_property(MPCTIO tio, yield_t & yield) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-#endif
|
|
|
+
|
|
|
|
|
|
+#ifdef HEAP_DEBUG
|
|
|
|
|
|
|
|
|
|
|
@@ -257,6 +258,7 @@ void verify_parent_children_heaps(MPCTIO tio, yield_t & yield, RegAS parent, Reg
|
|
|
assert(parent_reconstruction <= leftchild_reconstruction);
|
|
|
assert(parent_reconstruction <= rightchild_reconstruction);
|
|
|
}
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
Protocol 6 from PRAC: Round-Efficient 3-Party MPC for Dynamic Data Structures
|
|
@@ -311,7 +313,7 @@ RegXS MinHeap::restore_heap_property(MPCIO & mpcio, MPCTIO tio, yield_t & yield,
|
|
|
RegXS leftchildindex = index;
|
|
|
leftchildindex = index << 1;
|
|
|
RegXS rightchildindex;
|
|
|
- rightchildindex.xshare = leftchildindex.xshare ^ (tio.player());
|
|
|
+ rightchildindex.xshare = leftchildindex.xshare ^ (!tio.player());
|
|
|
|
|
|
RegAS parent, leftchild, rightchild;
|
|
|
|
|
@@ -387,9 +389,11 @@ RegXS MinHeap::restore_heap_property(MPCIO & mpcio, MPCTIO tio, yield_t & yield,
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
-std::pair<RegXS, RegBS> MinHeap::restore_heap_property_optimized(MPCTIO tio, yield_t & yield, RegXS index, size_t layer, size_t depth, typename Duoram < RegAS > ::template OblivIndex < RegXS, 3 > oidx) {
|
|
|
+std::pair<RegXS, RegBS> MinHeap::restore_heap_property_optimized(MPCTIO tio, yield_t & yield, RegXS index, size_t layer, typename Duoram < RegAS > ::template OblivIndex < RegXS, 3 > oidx) {
|
|
|
|
|
|
auto HeapArray = oram.flat(tio, yield);
|
|
|
|
|
@@ -639,7 +643,7 @@ RegAS MinHeap::extract_min(MPCIO & mpcio, MPCTIO tio, yield_t & yield, int is_op
|
|
|
oidx.incr(outroot.second);
|
|
|
|
|
|
for (size_t i = 0; i < height-1; ++i) {
|
|
|
- auto out = restore_heap_property_optimized(tio, yield, smaller, i + 1, height, oidx);
|
|
|
+ auto out = restore_heap_property_optimized(tio, yield, smaller, i + 1, oidx);
|
|
|
smaller = out.first;
|
|
|
oidx.incr(out.second);
|
|
|
}
|
|
@@ -722,9 +726,9 @@ void Heap(MPCIO & mpcio, const PRACOptions & opts, char ** args, int argc) {
|
|
|
tio.sync_lamport();
|
|
|
mpcio.dump_stats(std::cout);
|
|
|
|
|
|
- #ifdef HEAP_DEBUG
|
|
|
+
|
|
|
if(run_sanity == 1 && n_inserts != 0) tree.verify_heap_property(tio, yield);
|
|
|
- #endif
|
|
|
+
|
|
|
|
|
|
mpcio.reset_stats();
|
|
|
tio.reset_lamport();
|
|
@@ -742,9 +746,9 @@ void Heap(MPCIO & mpcio, const PRACOptions & opts, char ** args, int argc) {
|
|
|
std::cout << "minval_reconstruction = " << minval_reconstruction << std::endl;
|
|
|
#endif
|
|
|
|
|
|
- #ifdef HEAP_DEBUG
|
|
|
+
|
|
|
tree.verify_heap_property(tio, yield);
|
|
|
- #endif
|
|
|
+
|
|
|
|
|
|
#ifdef HEAP_VERBOSE
|
|
|
tree.print_heap(tio, yield);
|
|
@@ -760,9 +764,9 @@ void Heap(MPCIO & mpcio, const PRACOptions & opts, char ** args, int argc) {
|
|
|
tree.print_heap(tio, yield);
|
|
|
#endif
|
|
|
|
|
|
- #ifdef HEAP_DEBUG
|
|
|
+
|
|
|
if(run_sanity == 1 && n_extracts != 0) tree.verify_heap_property(tio, yield);
|
|
|
- #endif
|
|
|
+
|
|
|
}
|
|
|
);
|
|
|
}
|