forked from bargavj/distributedMachineLearning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodelAggregate.c
More file actions
93 lines (77 loc) · 2.17 KB
/
modelAggregate.c
File metadata and controls
93 lines (77 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <stdio.h>
#include <stdlib.h>
#include <obliv.h>
#include "modelAggregate.oh"
int main(int argc, char *argv[]) {
ProtocolDesc pd; // Protocol Descriptor used for passing message between the parties
protocolIO io; // Data structure to store the input parameters
double start, end; // Variables to measure start and end time of Wall Clock
int party; // CommandLine Argument: 1 -> Generator and 2 -> Evaluator
FILE *fptr1, *fptr2, *fptr3, *fptr4;
int i, j, bytes;
char c[20];
if (strcmp(argv[2], "--") == 0) {
party = 1;
} else {
party = 2;
}
if(party == 1) {
fptr1=fopen("Inputs/beta1.txt","r");
for(i = 0; i < M; i++) {
for(j = 0; j < D; j++) {
bytes = fscanf(fptr1,"%s", c);
io.beta1[i][j] = atoll(c);
}
}
fclose(fptr1);
}
if(party == 2) {
fptr2=fopen("Inputs/beta2.txt","r");
for(i = 0; i < M; i++) {
for(j = 0; j < D; j++) {
bytes = fscanf(fptr2,"%s", c);
io.beta2[i][j] = atoll(c);
}
}
fclose(fptr2);
}
fptr3=fopen("Inputs/random_vals.txt","r");
for(i = 0; i < M; i++) {
for(j = 0; j < D; j++) {
bytes = fscanf(fptr3,"%s", c);
io.random_vals[i][j] = atoll(c);
}
}
fclose(fptr3);
for(i = 0; i < M; i++) {
io.sizes[i] = 300;
}
io.epsilon = 0.5;
io.lambda = 0.00316227766;//0.00316227766;// 10^-2.5//0.03162277660168379; // 10^-1.5
setCurrentParty(&pd, party);
const char* remote_host = (strcmp(argv[2], "--") == 0 ? NULL : argv[2]);
ocTestUtilTcpOrDie(&pd, remote_host, argv[1]);
if (strcmp(argv[3], "yao") == 0) {
io.proto = 1;
} else if (strcmp(argv[3], "dualex") == 0) {
io.proto = 2;
} else {
io.proto = 0;
}
start = wallClock();
if (io.proto == 1) {
execYaoProtocol(&pd, aggregate, &io);
} else {
execDualexProtocol(&pd, aggregate, &io);
}
end = wallClock();
fprintf(stderr, "\nParty %d, Elapsed Time: %f seconds \n", party, end - start);
if (party == 1) {
fptr4=fopen("Output/beta_avg.txt","w");
for(i = 0; i < D; i++)
fprintf(fptr4, "%.8f ", io.beta_avg[i]*1.0/SCALE);
fclose(fptr4);
}
cleanupProtocol(&pd);
return 0;
}