Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made changes to highest #5

Open
wants to merge 38 commits into
base: obliv-c
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
51b9292
Update ptranal.ml
michael-mahoney May 27, 2014
bfa78b1
Change (&) to (&&) in line 287
michael-mahoney May 27, 2014
bed100e
Merge branch 'obliv-c' of https://github.com/michael-mahoney/obliv-c …
michael-mahoney May 27, 2014
6cd55ba
New example that prints out the highest integer value
Jun 2, 2014
de337a3
Create README.txt
mdh3hc Jun 2, 2014
a36ad0c
Added comments to highest.c
mdh3hc Jun 2, 2014
e4759d2
Added comments to highest.oc
Jun 2, 2014
f04b9bc
Made the number of integers secretive
mdh3hc Jun 5, 2014
d5d05b8
Merge pull request #1 from mdh3hc/obliv-c
michael-mahoney Jun 5, 2014
f59326b
June 5 commit
michael-mahoney Jun 5, 2014
53e9711
Merge branch 'obliv-c' of https://github.com/michael-mahoney/obliv-c …
michael-mahoney Jun 5, 2014
4003f37
Update README.md
mdh3hc Jun 9, 2014
1a069f3
Merge pull request #2 from mdh3hc/patch-1
mdh3hc Jun 9, 2014
3f71be4
Merge branch 'obliv-c', remote-tracking branch 'origin' into obliv-c
mdh3hc Jun 10, 2014
4127f72
Private Set Intersection Example
mdh3hc Jun 10, 2014
fc073a8
Merge branch 'obliv-c' of https://github.com/mdh3hc/obliv-c into obliv-c
mdh3hc Jun 10, 2014
cf90c8b
Trying alice
mdh3hc Jun 10, 2014
6dc0ee7
Was defining the type as an unsigned int
mdh3hc Jun 10, 2014
1b4c2dc
Made changes to highest
mdh3hc Jun 10, 2014
aceff81
Adding mutual files
michael-mahoney Jun 10, 2014
e6a5066
Should add Alice and Bob
michael-mahoney Jun 10, 2014
2f5558a
Adding average
michael-mahoney Jun 10, 2014
3be25a4
Works sort method works
mdh3hc Jun 12, 2014
e04b869
Merge sort method
michael-mahoney Jun 12, 2014
2f668f9
Changes to mutual
mdh3hc Jun 13, 2014
87d99b0
Update .gitignore
mdh3hc Jun 13, 2014
02e7acd
More mutual and average
mdh3hc Jun 13, 2014
08b6c95
Merge branch 'obliv-c' of https://github.com/mdh3hc/obliv-c into obliv-c
mdh3hc Jun 13, 2014
4ae72d3
Update .gitignore
mdh3hc Jun 16, 2014
366c3d5
Delete mutualStringTest.c
mdh3hc Jun 16, 2014
f826424
Private Set Intersection example with working Sort-Compare-Shuffle me…
mdh3hc Jun 17, 2014
5ef5415
fixed the bitonic sort method
mdh3hc Jun 17, 2014
cc89bbd
More fix to bitonic sort
mdh3hc Jun 18, 2014
9e3ace7
update to mutual files
michael-mahoney Jun 19, 2014
71173b8
Merge branch 'obliv-c' of https://github.com/michael-mahoney/obliv-c …
mdh3hc Jun 19, 2014
a923a79
Cleaned up mutual
mdh3hc Jun 19, 2014
f0a2c43
Mutual example now in mutualfriends
mdh3hc Jun 19, 2014
28c08f3
Final touches to mutual
mdh3hc Jun 20, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,12 @@
/test/small2/merge-ar
/test/small2/libmerge.a

#mutual
/test/oblivc/mutual/*.oc.*
/test/oblivc/mutual/*.txt

*.oc.*


# /ocamlutil
/ocamlutil/perfcount.c
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Obliv-C Compiler (`oblivcc`)
============================

This readme is still under construction. But there is already a language tutorial at http://goo.gl/TXzxD0

This requires libgcrypt to run. this can be downloaded on Ubuntu with `sudo apt-get install libgcrypt` then it also requires libgcrypt11-dev, which can be downlaoded with `sudo apt-get install libgcrypt11-dev`.

Once in the source folder, a simple `./configure && make` should build it all. The compiler is a GCC wrapper script found in `bin/oblivcc`. Example codes are in `test/oblivc`

Most of this code was forked from the project CIL (C Intermediate Language). You can diff with the master branch to see which part was added on later.
Expand Down
8 changes: 4 additions & 4 deletions src/ext/oblivc/obliv_bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ static int sizeCheckSend(ProtocolTransport* pt,int dest,const void* s,size_t n)
{ int sent = osend(&((SizeCheckTransportAdapter*)pt)->pd,dest,s,n);
if(sent==n) return n;
else
{ fprintf(stderr,"Was going to send %lu bytes to %d, sent %d\n",
n,dest,sent);
{ fprintf(stderr,"Was going to send bytes to %d, sent %d\n",
dest,sent);
if(sent<0) fprintf(stderr,"That means %s\n",strerror(sent));
exit(-1);
}
Expand All @@ -195,8 +195,8 @@ static int sizeCheckRecv(ProtocolTransport* pt,int src,void* s,size_t n)
{ int recv = orecv(&((SizeCheckTransportAdapter*)pt)->pd,src,s,n);
if(recv==n) return n;
else
{ fprintf(stderr,"Was going to recv %lu bytes from %d, received %d\n",
n,src,recv);
{ fprintf(stderr,"Was going to recv bytes from %d, received %d\n",
src,recv);
if(recv<0) fprintf(stderr,"That means %s\n",strerror(recv));
exit(-1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ext/oblivc/obliv_bits.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef OBLIV_BITS_H
#define OBLIV_BITS_H
void* memset(void* s, int c, unsigned long n); // Hack, had to declare memset
//void* memset(void* s, int c, unsigned long n); // Hack, had to declare memset
#include<stddef.h> // size_t
//#include<stdlib.h> // memset to zero
#include<stdbool.h>
Expand Down
44 changes: 44 additions & 0 deletions test/oblivc/average/average.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include<stdio.h>
#include<obliv.h>

#include "average.h"

int currentParty;

const char* mySide()
{
if(currentParty==1) return "Generator";
else return "Evaluator";
}

int main(int argc,char *argv[])
{
//these variables are used everytime
ProtocolDesc pd;
protocolIO io;

//checking that the input has the correct number of variables
if(argc<3)
{ if(argc<2) fprintf(stderr,"Party missing\n");
else fprintf(stderr,"string missing\n");
fprintf(stderr,"Usage: %s <1|2> <string>\n",argv[0]);
return 1;
}

//sets the size of the array
io.n = argc-2;
//the the values in the array to the input values
int j;
for(j = 0; j<io.n; j++){
io.i[j] = atoi(argv[j+2]);
}
//these steps are done everytime to set-up the oc file
protocolUseStdio(&pd);
currentParty = (argv[1][0]=='1'?1:2);
setCurrentParty(&pd,currentParty);
execYaoProtocol(&pd,highest,&io);
cleanupProtocol(&pd);
//prints out the result
fprintf(stderr,"Result: %d\n",io.res);
return 0;
}
15 changes: 15 additions & 0 deletions test/oblivc/average/average.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#define MAXN 100

typedef struct protocolIO
{
int i[100];
int n;
int res;

} protocolIO;

void highest(void* args);

const char* mySide();
34 changes: 34 additions & 0 deletions test/oblivc/average/average.oc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include<stdio.h>
#include<obliv.oh>

#include "average.h"

void readValues(obliv int* dest, int n, const int* src,int party)
{
OblivInputs specs[MAXN];
int i;
for(i=0;i<n;++i) setupOblivInt(specs+i,dest+i,src[i]);
feedOblivInputs(specs,n,party);
}

void highest(void* args){
protocolIO *io = args;
int n1, n2;
int i, j;
obliv int sum1 = 0;
obliv int sum2 = 0;
obliv int i1[MAXN], i2[MAXN];
n1 = ocBroadcastInt(1, io->n);
n2 = ocBroadcastInt(2, io->n);
readValues(i1, n1, io->i, 1);
readValues(i2, n2, io->i, 2);
//runs the actual algorithm to find average
for(i=0; i<n1; i++){
sum1 = i1[i] + sum1;
}
for(j =0; j<n2; j++){
sum2 = i2[j] + sum2;
}
obliv int average = (sum1 + sum2)/(n1+n2);
revealOblivInt(&io->res,average,0);
}
9 changes: 9 additions & 0 deletions test/oblivc/highest/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Prints out the highest value that is entered by two parties on the command line

# compile using our GCC wrapper
/path/to/oblivcc highest.c highest.oc -I .
# run: party 1 enters the numbers 1,2, and 3 and party 2 entered the numbers 2,4, and 6
cycle './a.out 1 1 2 3 | ./a.out 2 2 4 6'
#this result will be 6

The cycle command is a handy bash script that you can find at https://github.com/samee/cmd
44 changes: 44 additions & 0 deletions test/oblivc/highest/highest.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include<stdio.h>
#include<obliv.h>

#include "highest.h"

int currentParty;

const char* mySide()
{
if(currentParty==1) return "Generator";
else return "Evaluator";
}

int main(int argc,char *argv[])
{
//these variables are used everytime
ProtocolDesc pd;
protocolIO io;

//checking that the input has the correct number of variables
if(argc<3)
{ if(argc<2) fprintf(stderr,"Party missing\n");
else fprintf(stderr,"string missing\n");
fprintf(stderr,"Usage: %s <1|2> <string>\n",argv[0]);
return 1;
}

//sets the size of the array
io.n = argc-2;
//the the values in the array to the input values
int j;
for(j = 0; j<io.n; j++){
io.i[j] = atoi(argv[j+2]);
}
//these steps are done everytime to set-up the oc file
protocolUseStdio(&pd);
currentParty = (argv[1][0]=='1'?1:2);
setCurrentParty(&pd,currentParty);
execYaoProtocol(&pd,highest,&io);
cleanupProtocol(&pd);
//prints out the result
fprintf(stderr,"Result: %d\n",io.res);
return 0;
}
13 changes: 13 additions & 0 deletions test/oblivc/highest/highest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#define MAXN 100

typedef struct protocolIO
{
int i[MAXN];
int n;
int res;

} protocolIO;

void highest(void* args);
38 changes: 38 additions & 0 deletions test/oblivc/highest/highest.oc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include<stdio.h>
#include<obliv.oh>

#include "highest.h"
//dest is the pointer to the array of obliv ints
//n is the size of the array
//src is where the data is coming from
void readValues(obliv int* dest, int n, const int* src,int party)
{
OblivInputs specs[MAXN];
int i;
for( i = 0;i<n;++i) setupOblivInt(specs+i,dest+i,src[i]);
feedOblivInputs(specs,n,party);
}

void highest(void* args){
protocolIO *io = args;
obliv int n1, n2;
int k, j;
obliv int i1[MAXN], i2[MAXN];
n1 = feedOblivInt(io->n, 1);
n2 = feedOblivInt(io->n, 2);
readValues(i1, MAXN, io->i, 1);
readValues(i2, MAXN, io->i, 2);
//runs the actual algorithm of higher value
obliv int high = i1[0];
for(k=0; k<MAXN; k++){
obliv if(k<n1)
obliv if(i1[k] > high)
high = i1[k];
}
for(j =0; j<MAXN; j++){
obliv if(j<n2)
obliv if(i2[j] > high)
high = i2[j];
}
revealOblivInt(&io->res,high,0);
}
Loading