Commit 169bbd89 authored by Jack Doerner's avatar Jack Doerner

Using ocShared* to make XOR sharing much faster (via point and permute bits)

parent 32322f2c
......@@ -10,7 +10,6 @@ struct bitpropagator {
uint32_t endlevel;
size_t size;
obliv uint8_t * toplevel;
obliv uint8_t * toplevel2;
uint8_t * toplevel_local;
obliv uint8_t * blockzero;
obliv uint8_t * blocktemp_A;
......@@ -130,9 +129,7 @@ void bitpropagator_getblockvector_with_callback(obliv uint8_t * activeblock_delt
//Collect a set of random blocks for the top level
get_random_bytes(bp->toplevel_local, ((1ll << bp->startlevel) + 1) * BLOCKSIZE);
feedOblivCharArray(bp->toplevel, bp->toplevel_local, ((1ll << bp->startlevel) + 1) * BLOCKSIZE, 1);
feedOblivCharArray(bp->toplevel2, bp->toplevel_local, ((1ll << bp->startlevel) + 1) * BLOCKSIZE, 2);
for (size_t ii = 0; ii < ((1ll << bp->startlevel) + 1) * BLOCKSIZE; ii++) bp->toplevel[ii] ^= bp->toplevel2[ii];
ocFromSharedCharN(ocCurrentProto(), bp->toplevel, bp->toplevel_local, ((1ll << bp->startlevel) + 1) * BLOCKSIZE);
//now send identical blocks for all except the one branch that we're interested in.
obliv size_t levelindex = index >> (bp->endlevel - bp->startlevel);
......@@ -180,7 +177,6 @@ bitpropagator * bitpropagator_new(size_t size, uint32_t startlevel) {
bp->endlevel = LOG2LL(size) + (((1ll << LOG2LL(size)) < size)? 1:0);
bp->startlevel = MIN(startlevel,bp->endlevel-1);
bp->toplevel = calloc((1ll << bp->startlevel) + 1, BLOCKSIZE * sizeof(obliv uint8_t));
bp->toplevel2 = calloc((1ll << bp->startlevel) + 1, BLOCKSIZE * sizeof(obliv uint8_t));
bp->toplevel_local = malloc(((1ll << bp->startlevel) + 1) * BLOCKSIZE);
bp->blockzero = calloc(1, BLOCKSIZE * sizeof(obliv uint8_t));
bp->blocktemp_A = calloc((1ll << bp->startlevel), BLOCKSIZE * sizeof(obliv uint8_t));
......@@ -222,7 +218,6 @@ bitpropagator * bitpropagator_new(size_t size, uint32_t startlevel) {
void bitpropagator_free(bitpropagator * bp) {
free(bp->toplevel);
free(bp->toplevel2);
free(bp->toplevel_local);
free(bp->blockzero);
free(bp->blocktemp_A);
......
......@@ -4,14 +4,12 @@
#include "floram_util.oh"
#include "ackutil.h"
#include <obliv.h>
#include <stdio.h>
#include <copy.oh>
struct bitpropagator_cprg {
uint32_t startlevel;
uint32_t endlevel;
size_t size;
obliv uint8_t * blocktemp_L;
obliv uint8_t * blocktemp_R;
obliv uint8_t * diff_L;
obliv uint8_t * diff_R;
obliv uint8_t * Z;
......@@ -33,14 +31,8 @@ void bitpropagator_cprg_traverselevels(obliv uint8_t * active_block_delta, uint8
levelindex = (index >> (bp->endlevel - ii)) & 1;
feedOblivCharArray(bp->diff_L, bp->L_local, BLOCKSIZE, 1);
feedOblivCharArray(bp->diff_R, bp->R_local, BLOCKSIZE, 1);
feedOblivCharArray(bp->blocktemp_L, bp->L_local, BLOCKSIZE, 2);
feedOblivCharArray(bp->blocktemp_R, bp->R_local, BLOCKSIZE, 2);
for( size_t jj=0; jj< BLOCKSIZE/sizeof(uint64_t); jj++) {
((obliv uint64_t *)bp->diff_L)[jj] ^= ((obliv uint64_t *)bp->blocktemp_L)[jj];
((obliv uint64_t *)bp->diff_R)[jj] ^= ((obliv uint64_t *)bp->blocktemp_R)[jj];
}
ocFromSharedCharN(ocCurrentProto(), bp->diff_L, bp->L_local, BLOCKSIZE);
ocFromSharedCharN(ocCurrentProto(), bp->diff_R, bp->R_local, BLOCKSIZE);
obliv if (levelindex == 0) {
ocCopyN(&ocCopyChar, bp->Z, bp->diff_R, BLOCKSIZE);
......@@ -67,11 +59,7 @@ void bitpropagator_cprg_traverselevels(obliv uint8_t * active_block_delta, uint8
}
}
feedOblivCharArray(active_block_delta, bp->L_local, BLOCKSIZE, 1);
feedOblivCharArray(bp->blocktemp_L, bp->L_local, BLOCKSIZE, 2);
for( size_t jj=0; jj< BLOCKSIZE/sizeof(uint64_t); jj++) {
((obliv uint64_t *)active_block_delta)[jj] ^= ((obliv uint64_t *)bp->blocktemp_L)[jj];
}
ocFromSharedCharN(ocCurrentProto(), active_block_delta, bp->L_local, BLOCKSIZE);
}
void bitpropagator_cprg_getblockvector(obliv uint8_t * active_block_delta, uint8_t * local_output, bool * local_bit_output, bitpropagator_cprg * bp, obliv size_t index) {
......@@ -104,8 +92,6 @@ bitpropagator_cprg * bitpropagator_cprg_new(size_t size) {
bp->endlevel = LOG2LL(size) + (((1ll << LOG2LL(size)) < size)? 1:0);
bp->diff_L = calloc(1, BLOCKSIZE * sizeof(obliv uint8_t));
bp->diff_R = calloc(1, BLOCKSIZE * sizeof(obliv uint8_t));
bp->blocktemp_L = calloc(1, BLOCKSIZE * sizeof(obliv uint8_t));
bp->blocktemp_R = calloc(1, BLOCKSIZE * sizeof(obliv uint8_t));
bp->Z = calloc(1, BLOCKSIZE * sizeof(obliv uint8_t));
bp->advicebits = calloc(1, 2*sizeof(obliv bool));
bp->Z_local = malloc(BLOCKSIZE);
......@@ -134,8 +120,6 @@ bitpropagator_cprg * bitpropagator_cprg_new(size_t size) {
void bitpropagator_cprg_free(bitpropagator_cprg * bp) {
free(bp->diff_L);
free(bp->diff_R);
free(bp->blocktemp_L);
free(bp->blocktemp_R);
free(bp->Z);
free(bp->Z_local);
free(bp->L_local);
......
......@@ -5,6 +5,7 @@
#include "bitpropagate_cprg.oh"
#include "ackutil.h"
#include <obliv.h>
#include <copy.oh>
struct floram {
OcCopy* cpy;
......@@ -177,14 +178,6 @@ floram* floram_new(OcCopy* cpy, void* data, size_t n, bool cprg) {
uint8_t * loadtemp_local;
floram_pma(&loadtemp_local, 16, ram->blockcount * ram->blockmultiple * BLOCKSIZE);
obliv uint8_t * loadtemp = calloc(ram->blockcount, ram->blockcpy.eltsize);
get_random_bytes(loadtemp_local, BLOCKSIZE * ram->blockcount * ram->blockmultiple);
feedOblivCharArray(loadtemp, loadtemp_local, BLOCKSIZE * ram->blockcount * ram->blockmultiple, 2);
for (size_t ii = 0; ii<(ram->blockmultiple * BLOCKSIZE * ram->blockcount)/sizeof(uint64_t);ii++) ((obliv uint64_t *)loadtemp)[ii] ^= feedOblivLLong(((uint64_t *)loadtemp_local)[ii], 1);
for (size_t ii = 0; ii<(ram->blockmultiple * BLOCKSIZE * ram->blockcount)/sizeof(uint64_t);ii++) revealOblivLLong(&(((uint64_t *)loadtemp_local)[ii]), ((obliv uint64_t *)loadtemp)[ii], 2);
size_t blockid, subblockid;
for (size_t ii = 0; ii < ram->size; ii++) {
......@@ -193,14 +186,8 @@ floram* floram_new(OcCopy* cpy, void* data, size_t n, bool cprg) {
size_t elosize = cpy->eltsize/sizeof(obliv uint8_t);
for (size_t jj = 0; jj < elosize; jj++){
loadtemp[blockid * BLOCKSIZE * ram->blockmultiple + subblockid*elosize + jj] ^= ((obliv uint8_t *)element(cpy,data,ii))[jj];
}
ocToSharedCharN(ocCurrentProto(), &loadtemp_local[blockid * BLOCKSIZE * ram->blockmultiple + subblockid*elosize], ((obliv uint8_t *)element(cpy,data,ii)), elosize);
}
for (size_t ii = 0; ii<(ram->blockmultiple * BLOCKSIZE * ram->blockcount)/sizeof(uint64_t);ii++) revealOblivLLong(&(((uint64_t *)loadtemp_local)[ii]), ((obliv uint64_t *)loadtemp)[ii], 1);
free(loadtemp);
ram->wrom = scanwrom_new(&ram->blockcpy, ram->blockcount);
scanwrom_write_xor_shares(ram->wrom, loadtemp_local, 0, ram->blockcount);
......
......@@ -5,6 +5,8 @@
#include "bitpropagate.oh"
#include "bitpropagate.h"
#include "floram_util.oh"
#include <obliv.h>
#include <copy.oh>
struct scanrom {
OcCopy * blockcpy;
......@@ -34,9 +36,7 @@ struct scanwrom {
void scanrom_read_with_bitvector(obliv uint8_t * data, scanrom * rom, obliv size_t index, bool * bitvector) obliv {
~obliv() {
scanrom_read_with_bitvector_offline(rom->local_blocktemp, rom->local_data, bitvector, rom->fullblocksize, rom->blockcount);
feedOblivCharArray(data, rom->local_blocktemp, rom->fullblocksize, 1);
feedOblivCharArray(&rom->blocktemp[rom->fullblocksize], rom->local_blocktemp, rom->fullblocksize, 2);
for (size_t ii=0; ii < rom->fullblocksize; ii++) data[ii] ^= rom->blocktemp[rom->fullblocksize+ii];
ocFromSharedCharN(ocCurrentProto(), data, rom->local_blocktemp, rom->fullblocksize);
memset(&rom->blocktemp[rom->fullblocksize], 0, rom->fullblocksize * sizeof(obliv uint8_t));
}
......@@ -154,8 +154,7 @@ void scanrom_free(scanrom* rom) {
void scanwrom_read(obliv uint8_t* data, scanwrom* rom, size_t index) {
for (size_t ii = 0; ii < rom->fullblocksize; ii++) data[ii] = feedOblivChar(rom->local_data[index * (rom->fullblocksize) + ii], 1);
for (size_t ii = 0; ii < rom->fullblocksize; ii++) data[ii] ^= feedOblivChar(rom->local_data[index * (rom->fullblocksize) + ii], 2);
ocFromSharedCharN(ocCurrentProto(), data, &rom->local_data[index * (rom->fullblocksize)], rom->fullblocksize);
}
void scanwrom_write_with_blockvector(scanwrom* rom, obliv uint8_t * active_block_delta, uint8_t * blockvector, bool * bitvector, obliv uint8_t * old_data, obliv uint8_t * new_data) obliv {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment