|
@@ -6,7 +6,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -35,19 +35,6 @@ struct Node {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
- inline void zeronode() {
|
|
|
|
- key.set(0);
|
|
|
|
- pointers.set(0);
|
|
|
|
- value.set(0);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- inline void newnode() {
|
|
|
|
- key.randomize(8);
|
|
|
|
- pointers.set(0);
|
|
|
|
- value.randomize();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
inline void randomize() {
|
|
inline void randomize() {
|
|
key.randomize();
|
|
key.randomize();
|
|
pointers.randomize();
|
|
pointers.randomize();
|
|
@@ -151,9 +138,6 @@ T& operator<<(T& os, const Node &x)
|
|
|
|
|
|
DEFAULT_TUPLE_IO(Node)
|
|
DEFAULT_TUPLE_IO(Node)
|
|
|
|
|
|
-int num_items = 0;
|
|
|
|
-RegAS root;
|
|
|
|
-
|
|
|
|
std::tuple<RegBS, RegBS> compare_keys(Node n1, Node n2, MPCTIO tio, yield_t &yield) {
|
|
std::tuple<RegBS, RegBS> compare_keys(Node n1, Node n2, MPCTIO tio, yield_t &yield) {
|
|
CDPF cdpf = tio.cdpf(yield);
|
|
CDPF cdpf = tio.cdpf(yield);
|
|
auto [lt, eq, gt] = cdpf.compare(tio, yield, n2.key - n1.key, tio.aes_ops());
|
|
auto [lt, eq, gt] = cdpf.compare(tio, yield, n2.key - n1.key, tio.aes_ops());
|
|
@@ -200,7 +184,7 @@ inline void setRightPtr(RegXS &pointer, RegXS new_ptr){
|
|
pointer+=(new_ptr);
|
|
pointer+=(new_ptr);
|
|
}
|
|
}
|
|
|
|
|
|
-std::tuple<RegAS, RegBS> insert(RegAS &ptr, Node &new_node, auto A, int TTL, RegBS isDummy, MPCTIO &tio, yield_t &yield) {
|
|
+std::tuple<RegXS, RegBS> insert(MPCTIO &tio, yield_t &yield, RegXS &ptr, Node &new_node, Duoram<Node>::Flat A, int TTL, RegBS isDummy) {
|
|
if(TTL==0) {
|
|
if(TTL==0) {
|
|
RegBS zero;
|
|
RegBS zero;
|
|
return {ptr, zero};
|
|
return {ptr, zero};
|
|
@@ -230,12 +214,10 @@ std::tuple<RegAS, RegBS> insert(RegAS &ptr, Node &new_node, auto A, int TTL, Reg
|
|
isDummy^=1;
|
|
isDummy^=1;
|
|
}
|
|
}
|
|
|
|
|
|
- RegAS next_ptr_as;
|
|
|
|
- mpc_xs_to_as(tio, yield, next_ptr_as, next_ptr, 32);
|
|
|
|
isDummy^=F_i;
|
|
isDummy^=F_i;
|
|
- auto [wptr, direction] = insert(next_ptr_as, new_node, A, TTL-1, isDummy, tio, yield);
|
|
+ auto [wptr, direction] = insert(tio, yield, next_ptr, new_node, A, TTL-1, isDummy);
|
|
|
|
|
|
- RegAS ret_ptr;
|
|
+ RegXS ret_ptr;
|
|
RegBS ret_direction;
|
|
RegBS ret_direction;
|
|
mpc_select(tio, yield, ret_ptr, F_i, wptr, ptr);
|
|
mpc_select(tio, yield, ret_ptr, F_i, wptr, ptr);
|
|
|
|
|
|
@@ -247,10 +229,9 @@ std::tuple<RegAS, RegBS> insert(RegAS &ptr, Node &new_node, auto A, int TTL, Reg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-void insert(RegAS &root, Node &node, auto A, MPCTIO &tio, yield_t &yield) {
|
|
+void insert(MPCTIO &tio, yield_t &yield, RegXS &root, Node &node, Duoram<Node>::Flat A, size_t num_items) {
|
|
if(num_items==0) {
|
|
if(num_items==0) {
|
|
Node zero;
|
|
Node zero;
|
|
- zero.zeronode();
|
|
|
|
A[0] = zero;
|
|
A[0] = zero;
|
|
A[1] = node;
|
|
A[1] = node;
|
|
(root).set(1*tio.player());
|
|
(root).set(1*tio.player());
|
|
@@ -265,10 +246,9 @@ void insert(RegAS &root, Node &node, auto A, MPCTIO &tio, yield_t &yield) {
|
|
RegXS new_addr;
|
|
RegXS new_addr;
|
|
new_addr.set(new_id * tio.player());
|
|
new_addr.set(new_id * tio.player());
|
|
RegBS isDummy;
|
|
RegBS isDummy;
|
|
- isDummy.set(0);
|
|
|
|
|
|
|
|
|
|
|
|
- auto [wptr, direction] = insert(root, node, A, TTL, isDummy, tio, yield);
|
|
+ auto [wptr, direction] = insert(tio, yield, root, node, A, TTL, isDummy);
|
|
|
|
|
|
|
|
|
|
RegXS pointers = A[wptr].NODE_POINTERS;
|
|
RegXS pointers = A[wptr].NODE_POINTERS;
|
|
@@ -287,9 +267,14 @@ void insert(RegAS &root, Node &node, auto A, MPCTIO &tio, yield_t &yield) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+void newnode(Node &a) {
|
|
-
|
|
+ a.key.randomize(8);
|
|
|
|
+ a.pointers.set(0);
|
|
|
|
+ a.value.randomize();
|
|
|
|
+}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
void bst(MPCIO &mpcio,
|
|
void bst(MPCIO &mpcio,
|
|
const PRACOptions &opts, char **args)
|
|
const PRACOptions &opts, char **args)
|
|
{
|
|
{
|
|
@@ -306,13 +291,15 @@ void bst(MPCIO &mpcio,
|
|
Duoram<Node> oram(tio.player(), size);
|
|
Duoram<Node> oram(tio.player(), size);
|
|
auto A = oram.flat(tio, yield);
|
|
auto A = oram.flat(tio, yield);
|
|
|
|
|
|
|
|
+ size_t num_items = 0;
|
|
|
|
+ RegXS root;
|
|
|
|
+
|
|
Node c;
|
|
Node c;
|
|
for(int i = 0; i<30; i++) {
|
|
for(int i = 0; i<30; i++) {
|
|
- c.newnode();
|
|
+ newnode(c);
|
|
- insert(root, c, A, tio, yield);
|
|
+ insert(tio, yield, root, c, A, num_items);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
if (depth < 10) {
|
|
if (depth < 10) {
|
|
oram.dump();
|
|
oram.dump();
|
|
auto R = A.reconstruct();
|
|
auto R = A.reconstruct();
|