#define ARRSIZE(a) (sizeof(a)/sizeof(*a)) #define XBYTES 6 #include #include // for npotRecverNew()/npotSenderNew() #include #include typedef struct NpotSender NpotSender; typedef struct NpotRecver NpotRecver; double wallClock() { struct timespec t; clock_gettime(CLOCK_REALTIME,&t); return t.tv_sec+1e-9*t.tv_nsec; } void clockExtension(int argc, char* argv[]) { int i,n; ProtocolDesc pd; protocolUseStdio(&pd); if(argc<3) { fprintf(stderr,"Too few parameters\n"); return; } if(argv[1][0]=='R') { struct HonestOTExtRecver* r; char *buf; bool *sel; int i,n; clock_t lap; double wlap; setCurrentParty(&pd,2); sscanf(argv[2],"%d",&n); buf = malloc(11*n); sel = malloc(n); for(i=0;i20) { fprintf(stderr,"n too large, using n=20\n"); n=20; } for(i=0;i20) { fprintf(stderr,"n too large, using n=20\n"); n=20; } for(i=0;i20) { fprintf(stderr,"n too large, using n=20\n"); n=20; } for(i=0;i20) { fprintf(stderr,"n too large, using n=20\n"); n=20; } for(i=0;i=n) { fprintf(stderr,"index out of range\n"); return; } npotRecvLong(r,buf,i,n,len); buf[len-1]=0; fprintf(stderr,"Data received: %s\n",buf); npotRecverRelease(r); free(buf); } } void testBaseFour(int argc, char* argv[]) { int n = 4; ProtocolDesc pd; protocolUseStdio(&pd); if(argc<=2 || argv[1][0]=='S') { char* buf[] = {"Hello", "World", "Seven", "More!" }; setCurrentParty(&pd,1); NpotSender* s = npotSenderNew(n,&pd,2); npotSend(s,buf,n,XBYTES); npotSenderRelease(s); }else { char buf[XBYTES]; setCurrentParty(&pd,2); NpotRecver* r = npotRecverNew(n,&pd,1); npotRecv(r,buf,argv[2][0]-'0',n,XBYTES); npotRecverRelease(r); buf[XBYTES-1]=0; fprintf(stderr,"Data received: %s\n",buf); } } void showhex(const unsigned char* c,size_t len) { size_t i; for(i=0;i