12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #include "duoram.hpp"
- template <>
- RegAS Duoram<RegAS>::Flat::obliv_binary_search(RegAS &target)
- {
- nbits_t depth = this->addr_size;
-
- RegAS index;
- index.set(this->tio.player() ? 0 : 1<<(depth-1));
-
-
- while (depth > 0) {
-
- RegAS val = operator[](index);
-
- CDPF cdpf = tio.cdpf(this->yield);
- auto [lt, eq, gt] = cdpf.compare(this->tio, this->yield,
- val-target, tio.aes_ops());
- if (depth > 1) {
-
-
-
-
-
-
- RegAS uncond;
- uncond.set(tio.player() ? 0 : address_t(1)<<(depth-2));
- RegAS cond;
- cond.set(tio.player() ? 0 : address_t(1)<<(depth-1));
- RegAS condprod;
- RegBS le = lt ^ eq;
- mpc_flagmult(this->tio, this->yield, condprod, le, cond);
- index -= uncond;
- index += condprod;
- } else {
-
-
-
- RegAS cond;
- cond.set(tio.player() ? 0 : 1);
- RegAS condprod;
- mpc_flagmult(this->tio, this->yield, condprod, gt, cond);
- index -= condprod;
- }
- --depth;
- }
- return index;
- }
|