Commit ee84158b authored by Jack Doerner's avatar Jack Doerner

Huge set of changes in preparation for plublic releases.

Renamed many variables in RP for the sake of consistency with paper.
Rebuilt test/benchmark system to read CLI options instead of using hardcoded parameters.
Added 3-clause BSD license.
parent 7e0b1282
Copyright (c) 2016, Jack Doerner
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
OBLIVCC = $(OBLIVC_PATH)/bin/oblivcc
OBLIVCH = $(OBLIVC_PATH)/src/ext/oblivc
OBLIVCA = $(OBLIVC_PATH)/_build/libobliv.a
CFLAGS+=-DREMOTE_HOST=$(REMOTE_HOST) -O3 -I/usr/include -I . -I $(SRC_PATH)
CFLAGS+= -O3 -I/usr/include -I . -I $(SRC_PATH)
SRC_PATH=src/
LIB_OUT_PATH=build/lib/
......@@ -16,11 +16,8 @@ OBJS=$(DEPS) $(ORAM_DEPS) obig.oo ochacha.oo ograph.oo omatch.oo oqueue.oo\
TEST_PATH=tests/
TEST_OUT_PATH=build/tests/
TEST_DEPS=test_main.o
REMOTE_HOST=localhost
TEST_BINS = test_obig test_osha256 test_osha512 test_osalsa test_ochacha test_oqueue test_oram test_oscrypt test_ograph test_omatch test_osearch\
bench_oram.sqrt bench_oram.linear bench_oram.circuit bench_oram_init.sqrt bench_oram_init.linear bench_oram_init.circuit\
bench_oscrypt.sqrt bench_oscrypt.linear bench_oscrypt.circuit bench_bfs.sqrt bench_bfs.linear bench_bfs.circuit\
bench_bst.sqrt bench_bst.linear bench_bst.circuit bench_gs.sqrt bench_gs.linear bench_gs.circuit
bench_oram bench_oram_init bench_oscrypt bench_bfs bench_bst bench_gs bench_rp
default: $(ACKLIB) tests
......
This diff is collapsed.
......@@ -10,47 +10,61 @@ typedef struct oroth_peranson_preference_share {
obliv int32_t rank_share;
} oroth_peranson_preference_share;
typedef struct oroth_peranson_resident_share {
typedef struct oroth_peranson_proposer_share {
size_t preferences_bound;
oroth_peranson_preference_share * preferences;
} oroth_peranson_resident_share;
} oroth_peranson_proposer_share;
typedef struct oroth_peranson_hospital_share {
typedef struct oroth_peranson_reviewer_share {
size_t preferences_bound;
oroth_peranson_preference_share * preferences;
obliv size_t positions_available_share;
} oroth_peranson_hospital_share;
} oroth_peranson_reviewer_share;
typedef struct oroth_peranson_preference {
obliv int32_t pid;
obliv int32_t rid;
obliv int32_t hid;
obliv bool is_h;
obliv bool is_r;
obliv int32_t rank;
} oroth_peranson_preference;
typedef struct oroth_peranson_preference_package {
size_t resident_count;
size_t hospital_count;
size_t proposer_count;
size_t reviewer_count;
size_t p_preferences_bound;
size_t r_preferences_bound;
size_t h_preferences_bound;
size_t h_positions_bound;
size_t r_positions_bound;
oroth_peranson_preference * p_prefs;
oroth_peranson_preference * r_prefs;
oroth_peranson_preference * h_prefs;
obliv uint32_t * h_positions_available;
obliv uint32_t * r_positions_available;
} oroth_peranson_preference_package;
typedef struct oroth_peranson_hospital_output {
typedef struct oroth_peranson_reviewer_output {
obliv size_t positions_available;
obliv int32_t * matches;
} oroth_peranson_hospital_output;
} oroth_peranson_reviewer_output;
#ifdef OMATCH_EXTENDED_BENCHMARK
typedef struct oroth_peranson_benchmark_output {
int64_t setup_time;
int64_t setup_gates;
int64_t permutation_time;
int64_t permutation_gates;
int64_t proposereject_time;
int64_t proposereject_gates;
} oroth_peranson_benchmark_output;
#endif
typedef struct oroth_peranson_output {
size_t hospital_count;
size_t reviewer_count;
size_t positions_bound;
oroth_peranson_hospital_output * hospitals;
oroth_peranson_reviewer_output * reviewers;
#ifdef OMATCH_EXTENDED_BENCHMARK
oroth_peranson_benchmark_output times;
#endif
} oroth_peranson_output;
oroth_peranson_preference_package * oroth_peranson_preference_package_from_shares(oroth_peranson_resident_share * ra, oroth_peranson_resident_share * rb, size_t resident_count, oroth_peranson_hospital_share * ha, oroth_peranson_hospital_share * hb, size_t hospital_count, size_t hospital_positions_bound);
oroth_peranson_preference_package * oroth_peranson_preference_package_from_shares(oroth_peranson_proposer_share * ra, oroth_peranson_proposer_share * rb, size_t proposer_count, oroth_peranson_reviewer_share * ha, oroth_peranson_reviewer_share * hb, size_t reviewer_count, size_t reviewer_positions_bound);
void oroth_peranson_preference_package_free(oroth_peranson_preference_package * pkg);
oroth_peranson_output * oroth_peranson(oroth_peranson_preference_package * pkg);
......
......@@ -3,33 +3,99 @@
#include "oram.oh"
#include "test_generic.h"
#define SAMPLES 30
static const char TESTNAME[] = "bfs_benchmark";
char* testName() {
#define TEXT_HELP_SUPPLEMENTARY "\
-e \x1b[4mNUMBER\x1b[0m, --edges=\x1b[4mNUMBER\x1b[0m \n\t\tgenerate graphs with \x1b[4mNUMBER\x1b[0m edges\n\n\
-v \x1b[4mNUMBER\x1b[0m, --vertices=\x1b[4mNUMBER\x1b[0m \n\t\tgenerate graphs with \x1b[4mNUMBER\x1b[0m vertices\n\n\
-o \x1b[4mTYPE\x1b[0m, --oram-type=\x1b[4mTYPE\x1b[0m \n\t\tforce all ORAMs to be \x1b[4mTYPE\x1b[0m ORAMs. Valid types are \033[1msqrt\033[0m, \033[1mcircuit\033[0m, and \033[1mlinear\033[0m.\n\n\
-i \x1b[4mNUMBER\x1b[0m, --samples=\x1b[4mNUMBER\x1b[0m \n\t\trun \x1b[4mNUMBER\x1b[0m iterations of the benchmark\n\n"
static const char options_string[] = "e:v:o:i:";
static struct option long_options[] = {
{"edges", required_argument, NULL, 'e'},
{"vertices", required_argument, NULL, 'v'},
{"oram-type", required_argument, NULL, 'o'},
{"samples", required_argument, NULL, 'i'},
{0, 0, 0, 0}
};
char* get_test_name() {
return TESTNAME;
}
int vcts[] = {4,8,16,32,64,128,256,512,1024};
int ects[] = {4,8};
int vn = sizeof(vcts)/sizeof(vcts[0]);
int en = sizeof(ects)/sizeof(ects[0]);
char* get_supplementary_options_string() {
return options_string;
}
void testMain(void*varg) {
struct option* get_long_options() {
return long_options;
}
void print_supplementary_help() {
fprintf(stderr, TEXT_HELP_SUPPLEMENTARY);
}
void test_main(void*varg) {
#ifdef ORAM_OVERRIDE
oram_set_default_type(ORAM_OVERRIDE);
#endif
fprintf(stdout, "==========\nBREADTH FIRST SEARCH (vertices, edge ratio, sample 1, sample 2, ... sample n)\n----------\n");
int adjacency_count = 4;
int vertices = 4;
int samples = 1;
args_t * args_pass = varg;
int arg;
optind = 0;
while ((arg = getopt_long(args_pass->argc, args_pass->argv, options_string, long_options, NULL)) != -1) {
if (arg == 'e') {
adjacency_count = atoi(optarg);
if (adjacency_count <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == 'v') {
vertices = atoi(optarg);
if (vertices <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == 'o') {
if (strcmp(optarg,"sqrt") == 0) {
oram_set_default_type(ORAM_TYPE_SQRT);
} else if (strcmp(optarg,"circuit") == 0) {
oram_set_default_type(ORAM_TYPE_CIRCUIT);
} else if (strcmp(optarg,"linear") == 0) {
oram_set_default_type(ORAM_TYPE_LINEAR);
} else {
fprintf (stderr, "Invalid argument for -%c.\n", arg);
return;
}
} else if (arg == 'i') {
samples = atoi(optarg);
if (samples <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == '?' || arg == ':') {
if (optopt == 'e' || optopt == 'v' || optopt == 'o' || optopt == 'i') {
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
return;
} else {
fprintf (stderr, "Option -%c not recognized.\n", optopt);
return;
}
} else {
abort();
}
}
fprintf(stdout, "# BREADTH FIRST SEARCH (vertices, edge ratio, sample 1, sample 2, ... sample n)\n");
fflush(stdout);
{
for (int jj = 0; jj < en; jj++) {
int adjacency_count = ects[jj];
for (int ii = 0; ii < vn; ii++) {
int vertices = vcts[ii];
ograph_edge * edges = calloc(adjacency_count * vertices, sizeof(ograph_edge));
uint64_t tally = 0;
......@@ -37,8 +103,6 @@ void testMain(void*varg) {
fprintf(stdout, "%d,%d", vertices, adjacency_count);
fflush(stdout);
int samples = (vertices < 256) ? SAMPLES : 3;
for (int kk = 0; kk < samples; kk++) {
for (int ll = 0; ll < adjacency_count * vertices; ll++) {
edges[ll].v1 = feedOblivInt(rand_range(0,vertices), 1);
......@@ -61,8 +125,6 @@ void testMain(void*varg) {
free(edges);
fprintf(stdout, "\n");
fprintf(stderr, "BFS (vertices:%d, edge ratio: %d): %llu microseconds avg\n", vertices, adjacency_count, tally/samples);
}
}
}
......
......@@ -3,42 +3,106 @@
#include "oram.oh"
#include "test_generic.h"
#define SAMPLES 30
static const char TESTNAME[] = "obst_benchmark";
char* testName() {
#define TEXT_HELP_SUPPLEMENTARY "\
-e \x1b[4mNUMBER\x1b[0m, --elements=\x1b[4mNUMBER\x1b[0m \n\t\tsearch through \x1b[4mNUMBER\x1b[0m elements\n\n\
-s \x1b[4mNUMBER\x1b[0m, --searches=\x1b[4mNUMBER\x1b[0m \n\t\tperform \x1b[4mNUMBER\x1b[0m searches on the same data\n\n\
-o \x1b[4mTYPE\x1b[0m, --oram-type=\x1b[4mTYPE\x1b[0m \n\t\tforce all ORAMs to be \x1b[4mTYPE\x1b[0m ORAMs. Valid types are \033[1msqrt\033[0m, \033[1mcircuit\033[0m, and \033[1mlinear\033[0m.\n\n\
-i \x1b[4mNUMBER\x1b[0m, --samples=\x1b[4mNUMBER\x1b[0m \n\t\trun \x1b[4mNUMBER\x1b[0m iterations of the benchmark\n\n"
static const char options_string[] = "e:s:o:i:";
static struct option long_options[] = {
{"elements", required_argument, NULL, 'e'},
{"searches", required_argument, NULL, 's'},
{"oram-type", required_argument, NULL, 'o'},
{"samples", required_argument, NULL, 'i'},
{0, 0, 0, 0}
};
char* get_test_name() {
return TESTNAME;
}
char* get_supplementary_options_string() {
return options_string;
}
struct option* get_long_options() {
return long_options;
}
void print_supplementary_help() {
fprintf(stderr, TEXT_HELP_SUPPLEMENTARY);
}
obliv int cmpInt(OcCopy * cpy, void * a, void * b) obliv {
obliv uint32_t * aa = (obliv uint32_t *) a;
obliv uint32_t * bb = (obliv uint32_t *) b;
return (*aa > *bb) - (*aa < *bb);
}
int elcts[] = {32,1024,32768};
int searchcts[] = {1,2,4,8,16,32,64,128,256,512,1024};
int en = sizeof(elcts)/sizeof(elcts[0]);
int sn = sizeof(searchcts)/sizeof(searchcts[0]);
void testMain(void*varg) {
void test_main(void*varg) {
#ifdef ORAM_OVERRIDE
oram_set_default_type(ORAM_OVERRIDE);
#endif
fprintf(stdout, "==========\nBINARY SEARCH (elements, searches, sample 1, sample 2, ... sample n)\n----------\n");
int elct = 32;
int searchct = 1;
int samples = 1;
args_t * args_pass = varg;
int arg;
optind = 0;
while ((arg = getopt_long(args_pass->argc, args_pass->argv, options_string, long_options, NULL)) != -1) {
if (arg == 'e') {
elct = atoi(optarg);
if (elct <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == 's') {
searchct = atoi(optarg);
if (searchct <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == 'o') {
if (strcmp(optarg,"sqrt") == 0) {
oram_set_default_type(ORAM_TYPE_SQRT);
} else if (strcmp(optarg,"circuit") == 0) {
oram_set_default_type(ORAM_TYPE_CIRCUIT);
} else if (strcmp(optarg,"linear") == 0) {
oram_set_default_type(ORAM_TYPE_LINEAR);
} else {
fprintf (stderr, "Invalid argument for -%c.\n", arg);
return;
}
} else if (arg == 'i') {
samples = atoi(optarg);
if (samples <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == '?' || arg == ':') {
if (optopt == 'e' || optopt == 's' || optopt == 'o' || optopt == 'i') {
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
return;
} else {
fprintf (stderr, "Option -%c not recognized.\n", optopt);
return;
}
} else {
abort();
}
}
fprintf(stdout, "# BINARY SEARCH (elements, searches, sample 1, sample 2, ... sample n)\n");
fflush(stdout);
{
OcCopy cpy = ocCopyIntN(4);
for (int ii = 0; ii < en; ii++) {
int elct = elcts[ii];
for (int jj = 0; jj < sn; jj++) {
int searchct = searchcts[jj];
uint64_t tally = 0;
fprintf(stdout, "%d,%d", elct, searchct);
......@@ -49,8 +113,6 @@ void testMain(void*varg) {
obliv uint32_t needle;
obliv uint32_t otemp;
int samples = elct < 2048 ? SAMPLES : 3;
for (int kk = 0; kk < samples; kk++) {
otemp = 0;
......@@ -83,8 +145,5 @@ void testMain(void*varg) {
fprintf(stdout, "\n");
fprintf(stderr, "BINARY SEARCH (elements:%d, searches:%d): %llu microseconds avg\n", elct, searchct, tally/samples);
}
}
}
}
......@@ -3,14 +3,36 @@
#include "oram.oh"
#include "test_generic.h"
#define SAMPLES 30
#define TEXT_HELP_SUPPLEMENTARY "\
-n \x1b[4mNUMBER\x1b[0m, --pairs=\x1b[4mNUMBER\x1b[0m \n\t\tsimulate \x1b[4mNUMBER\x1b[0m pairs of participants\n\n\
-o \x1b[4mTYPE\x1b[0m, --oram-type=\x1b[4mTYPE\x1b[0m \n\t\tforce all ORAMs to be \x1b[4mTYPE\x1b[0m ORAMs. Valid types are \033[1msqrt\033[0m, \033[1mcircuit\033[0m, and \033[1mlinear\033[0m.\n\n\
-i \x1b[4mNUMBER\x1b[0m, --samples=\x1b[4mNUMBER\x1b[0m \n\t\trun \x1b[4mNUMBER\x1b[0m iterations of the benchmark\n\n"
static const char TESTNAME[] = "gs_benchmark";
char* testName() {
static const char options_string[] = "n:o:i:";
static struct option long_options[] = {
{"pairs", required_argument, NULL, 'n'},
{"oram-type", required_argument, NULL, 'o'},
{"samples", required_argument, NULL, 'i'},
{0, 0, 0, 0}
};
char* get_test_name() {
return TESTNAME;
}
char* get_supplementary_options_string() {
return options_string;
}
struct option* get_long_options() {
return long_options;
}
void print_supplementary_help() {
fprintf(stderr, TEXT_HELP_SUPPLEMENTARY);
}
void shuffle(uint32_t *array, size_t n) {
if (n > 1) {
size_t i;
......@@ -24,22 +46,59 @@ void shuffle(uint32_t *array, size_t n) {
}
}
int pcts[] = {4,8,16,32,64,128,256,512,1024};
int pn = sizeof(pcts)/sizeof(pcts[0]);
void testMain(void*varg) {
void test_main(void*varg) {
#ifdef ORAM_OVERRIDE
oram_set_default_type(ORAM_OVERRIDE);
#endif
fprintf(stdout, "==========\nGALE SHAPLEY (pair count, sample 1, sample 2, ... sample n)\n----------\n");
int pairs = 1;
int samples = 1;
args_t * args_pass = varg;
int arg;
optind = 0;
while ((arg = getopt_long(args_pass->argc, args_pass->argv, options_string, long_options, NULL)) != -1) {
if (arg == 'n') {
pairs = atoi(optarg);
if (pairs <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == 'o') {
if (strcmp(optarg,"sqrt") == 0) {
oram_set_default_type(ORAM_TYPE_SQRT);
} else if (strcmp(optarg,"circuit") == 0) {
oram_set_default_type(ORAM_TYPE_CIRCUIT);
} else if (strcmp(optarg,"linear") == 0) {
oram_set_default_type(ORAM_TYPE_LINEAR);
} else {
fprintf (stderr, "Invalid argument for -%c.\n", arg);
return;
}
} else if (arg == 'i') {
samples = atoi(optarg);
if (samples <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == '?' || arg == ':') {
if (optopt == 'n' || optopt == 'o' || optopt == 'i') {
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
return;
} else {
fprintf (stderr, "Option -%c not recognized.\n", optopt);
return;
}
} else {
abort();
}
}
fprintf(stdout, "# GALE SHAPLEY (pair count, sample 1, sample 2, ... sample n)\n");
fflush(stdout);
{
for (int ii = 0; ii < pn; ii++) {
int pairs = pcts[ii];
uint64_t tally = 0;
fprintf(stdout, "%d", pairs);
......@@ -54,8 +113,6 @@ void testMain(void*varg) {
obliv uint32_t * wPrefs = calloc(pairs * pairs, sizeof(obliv uint32_t));
obliv uint32_t * output = calloc(pairs, sizeof(obliv uint32_t));
uint64_t samples = pairs < 128 ? SAMPLES : (pairs < 1024 ? 3 : 1);
for (int kk = 0; kk < samples; kk++) {
for (int ll = 0; ll < pairs; ll++) {
shuffle(perm, pairs);
......@@ -87,6 +144,4 @@ void testMain(void*varg) {
fprintf(stderr, "GALE SHAPLEY (pairs:%d): %llu microseconds avg\n", pairs, tally/samples);
}
}
}
......@@ -3,31 +3,96 @@
#include "copy.oh"
#include "test_generic.h"
#define SAMPLES 1000
static const char TESTNAME[] = "oram_benchmark";
char* testName() {
#define TEXT_HELP_SUPPLEMENTARY "\
-e \x1b[4mNUMBER\x1b[0m, --element-count=\x1b[4mNUMBER\x1b[0m \n\t\tsearch through \x1b[4mNUMBER\x1b[0m elements\n\n\
-s \x1b[4mNUMBER\x1b[0m, --element-size=\x1b[4mNUMBER\x1b[0m \n\t\tperform \x1b[4mNUMBER\x1b[0m searches on the same data\n\n\
-o \x1b[4mTYPE\x1b[0m, --oram-type=\x1b[4mTYPE\x1b[0m \n\t\tforce all ORAMs to be \x1b[4mTYPE\x1b[0m ORAMs. Valid types are \033[1msqrt\033[0m, \033[1mcircuit\033[0m, and \033[1mlinear\033[0m.\n\n\
-i \x1b[4mNUMBER\x1b[0m, --samples=\x1b[4mNUMBER\x1b[0m \n\t\trun \x1b[4mNUMBER\x1b[0m iterations of the benchmark\n\n"
static const char options_string[] = "e:s:o:i:";
static struct option long_options[] = {
{"element-count", required_argument, NULL, 'e'},
{"element-size", required_argument, NULL, 's'},
{"oram-type", required_argument, NULL, 'o'},
{"samples", required_argument, NULL, 'i'},
{0, 0, 0, 0}
};
char* get_test_name() {
return TESTNAME;
}
int elcts[] = {4,8,16,32,64,128,256,512,1024};
int elszs[] = {1,2,4,8,16,32,64,128,256};
int en = sizeof(elcts)/sizeof(elcts[0]);
int sn = sizeof(elszs)/sizeof(elszs[0]);
char* get_supplementary_options_string() {
return options_string;
}
struct option* get_long_options() {
return long_options;
}
void print_supplementary_help() {
fprintf(stderr, TEXT_HELP_SUPPLEMENTARY);
}
void testMain(void*varg) {
void test_main(void*varg) {
#ifdef ORAM_OVERRIDE
oram_set_default_type(ORAM_OVERRIDE);
#endif
fprintf(stdout, "==========\nORAM ACCESS (WRITE) (elct, elsz, sample 1, sample 2, ... sample n)\n----------\n");
int elct = 4;
int elsz = 1;
int samples = 1;
args_t * args_pass = varg;
int arg;
optind = 0;
while ((arg = getopt_long(args_pass->argc, args_pass->argv, options_string, long_options, NULL)) != -1) {
if (arg == 'e') {
elct = atoi(optarg);
if (elct <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == 's') {
elsz = atoi(optarg);
if (elsz <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == 'o') {
if (strcmp(optarg,"sqrt") == 0) {
oram_set_default_type(ORAM_TYPE_SQRT);
} else if (strcmp(optarg,"circuit") == 0) {
oram_set_default_type(ORAM_TYPE_CIRCUIT);
} else if (strcmp(optarg,"linear") == 0) {
oram_set_default_type(ORAM_TYPE_LINEAR);
} else {
fprintf (stderr, "Invalid argument for -%c.\n", arg);
return;
}
} else if (arg == 'i') {
samples = atoi(optarg);
if (samples <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == '?' || arg == ':') {
if (optopt == 'e' || optopt == 's' || optopt == 'o' || optopt == 'i') {
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
return;
} else {
fprintf (stderr, "Option -%c not recognized.\n", optopt);
return;
}
} else {
abort();
}
}
for (int ii = 0; ii < en; ii++) {
int elct = elcts[ii];
for (int jj = 0; jj < sn; jj++) {
int elsz = elszs[jj];
fprintf(stdout, "# ORAM ACCESS (WRITE) (elct, elsz, sample 1, sample 2, ... sample n)\n");
OcCopy cpy = ocCopyIntN(elsz);
......@@ -39,7 +104,7 @@ void testMain(void*varg) {
fprintf(stdout, "%d,%d", elct, elsz);
for (int kk = 0; kk < SAMPLES; kk++) {
for (int kk = 0; kk < samples; kk++) {
uint32_t index_raw = ocBroadcastInt(rand() % elct, 2);
obliv uint32_t index = feedOblivInt(index_raw, 2);
uint64_t startTime = current_timestamp();
......@@ -53,9 +118,6 @@ void testMain(void*varg) {
free(input);
oram_free(o);
fprintf(stdout, "\n");
fprintf(stderr, "Write (count:%d, size: %d): %llu microseconds avg\n", elct, elsz, tally / (SAMPLES));
}
}
fprintf(stderr, "Write (count:%d, size: %d): %llu microseconds avg\n", elct, elsz, tally / samples);
}
......@@ -7,37 +7,103 @@
static const char TESTNAME[] = "oram_init_benchmark";
char* testName() {
#define TEXT_HELP_SUPPLEMENTARY "\
-e \x1b[4mNUMBER\x1b[0m, --element-count=\x1b[4mNUMBER\x1b[0m \n\t\tsearch through \x1b[4mNUMBER\x1b[0m elements\n\n\
-s \x1b[4mNUMBER\x1b[0m, --element-size=\x1b[4mNUMBER\x1b[0m \n\t\tperform \x1b[4mNUMBER\x1b[0m searches on the same data\n\n\
-o \x1b[4mTYPE\x1b[0m, --oram-type=\x1b[4mTYPE\x1b[0m \n\t\tforce all ORAMs to be \x1b[4mTYPE\x1b[0m ORAMs. Valid types are \033[1msqrt\033[0m, \033[1mcircuit\033[0m, and \033[1mlinear\033[0m.\n\n\
-i \x1b[4mNUMBER\x1b[0m, --samples=\x1b[4mNUMBER\x1b[0m \n\t\trun \x1b[4mNUMBER\x1b[0m iterations of the benchmark\n\n"
static const char options_string[] = "e:s:o:i:";
static struct option long_options[] = {
{"element-count", required_argument, NULL, 'e'},
{"element-size", required_argument, NULL, 's'},
{"oram-type", required_argument, NULL, 'o'},
{"samples", required_argument, NULL, 'i'},
{0, 0, 0, 0}
};
char* get_test_name() {
return TESTNAME;
}
int elcts[] = {4,8,16,32,64,128,256,512,1024};
int elszs[] = {1,2,4,8,16,32,64,128,256};
int en = sizeof(elcts)/sizeof(elcts[0]);
int sn = sizeof(elszs)/sizeof(elszs[0]);
char* get_supplementary_options_string() {
return options_string;
}
struct option* get_long_options() {
return long_options;
}
void print_supplementary_help() {
fprintf(stderr, TEXT_HELP_SUPPLEMENTARY);
}
void testMain(void*varg) {
void test_main(void*varg) {
#ifdef ORAM_OVERRIDE
oram_set_default_type(ORAM_OVERRIDE);
#endif
fprintf(stdout, "==========\nORAM INIT (elct, elsz, sample 1, sample 2, ... sample n)\n----------\n");
int elct = 4;
int elsz = 1;
int samples = 1;
args_t * args_pass = varg;
int arg;
optind = 0;
while ((arg = getopt_long(args_pass->argc, args_pass->argv, options_string, long_options, NULL)) != -1) {
if (arg == 'e') {
elct = atoi(optarg);
if (elct <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == 's') {
elsz = atoi(optarg);
if (elsz <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == 'o') {
if (strcmp(optarg,"sqrt") == 0) {
oram_set_default_type(ORAM_TYPE_SQRT);
} else if (strcmp(optarg,"circuit") == 0) {
oram_set_default_type(ORAM_TYPE_CIRCUIT);
} else if (strcmp(optarg,"linear") == 0) {
oram_set_default_type(ORAM_TYPE_LINEAR);
} else {
fprintf (stderr, "Invalid argument for -%c.\n", arg);
return;
}
} else if (arg == 'i') {
samples = atoi(optarg);
if (samples <= 0) {
fprintf (stderr, "Argument for -%c must be positive.\n", arg);
return;
}
} else if (arg == '?' || arg == ':') {
if (optopt == 'e' || optopt == 's' || optopt == 'o' || optopt == 'i') {
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
return;
} else {
fprintf (stderr, "Option -%c not recognized.\n", optopt);
return;
}
} else {
abort();
}
}
for (int ii = 0; ii < en; ii++) {
int elct = elcts[ii];
for (int jj = 0; jj < sn; jj++) {
int elsz = elszs[jj];
fprintf(stdout, "# ORAM INIT (elct, elsz, sample 1, sample 2, ... sample n)\n");
OcCopy cpy = ocCopyIntN(elsz);
uint64_t tally = 0;
obliv uint32_t * input = calloc(elsz * elct, sizeof(obliv uint32_t));
fprintf(stdout, "%d,%d", elct, elsz);
for (int kk = 0; kk < SAMPLES; kk++) {
for (int kk = 0; kk < samples; kk++) {
for (int kkkkk = 0; kkkkk < (elsz * elct); kkkkk++) input[kkkkk] = feedOblivInt(rand(), 1);
uint64_t startTime = current_timestamp();
oram * o = oram_from_array(ORAM_TYPE_AUTO, &cpy, elct, input);
......@@ -52,9 +118,6 @@ void testMain(void*varg) {
free(input);
fprintf(stdout, "\n");
fprintf(stderr, "Init (count:%d, size: %d): %llu microseconds avg\n", elct, elsz, tally / (SAMPLES));
}
}
fprintf(stderr, "Init (count:%d, size: %d): %llu microseconds avg\n", elct, elsz, tally / samples);
}
......@@ -3,78 +3,108 @@
#include "oram.oh"
#include "test_generic.h"
#define SAMPLES 30
static const char TESTNAME[] = "oscrypt_benchmark";
char* testName() {
#define TEXT_HELP_SUPPLEMENTARY "\
-N \x1b[4mNUMBER\x1b[0m \n\t\tuse \x1b[4mNUMBER\x1b[0m for scrypt parameter N\n\n\
-R \x1b[4mNUMBER\x1b[0m \n\t\tuse \x1b[4mNUMBER\x1b[0m for scrypt parameter R\n\n\
-P \x1b[4mNUMBER\x1b[0m \n\t\tuse \x1b[4mNUMBER\x1b[0m for scrypt parameter P\n\n\
-o \x1b[4mTYPE\x1b[0m, --oram-type=\x1b[4mTYPE\x1b[0m \n\t\tforce all ORAMs to be \x1b[4mTYPE\x1b[0m ORAMs. Valid types are \033[1msqrt\033[0m, \033[1mcircuit\033[0m, and \033[1mlinear\033[0m.\n\n\
-i \x1b[4mNUMBER\x1b[0m, --samples=\x1b[4mNUMBER\x1b[0m \n\t\trun \x1b[4mNUMBER\x1b[0m iterations of the benchmark\n\n"
static const char options_string[] = "N:R:P:o:i:";
static struct option long_options[] = {