本文整理汇总了C++中OE类的典型用法代码示例。如果您正苦于以下问题:C++ OE类的具体用法?C++ OE怎么用?C++ OE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int c, char **a) {
OE oe = OperatingEnvironment_LinuxNew();
init_polynomial();
if (oe) {
MR mr = 0;
int i = 0;
MiniMacs mm = setup_generic_minimacs(oe, a[1]);
if (!mm) return -42;
mm->get_id();
mr = mm->connect("127.0.0.1",2020);
mm->init_heap(6);
C(mm->secret_input(0,0,0));
C(mm->open(0));
C(mm->secret_input(0,1,Data_shallow("\001\001",1)));
C(mm->secret_input(0,2,Data_shallow("\002\002",1)));
for(i = 0; i < 256;++i)
C(mm->mul(3,2,1));
C(mm->add(3,3,3));
C(mm->open(3));
oe->p(mm->heap_get(0)->codeword);
_p("Mul res", mm->heap_get(3)->codeword,8,8);
}
failure:
return 0;
}
示例2: tokenize_file
static int tokenize_file(OE oe) {
uint lbuffer = 1060365;
uint ands = 0, xors = 0, invs = 0, nums = 0, tokens = 0;
Tokenizer tk = 0;
Token tok = {0};
byte * buffer = oe->getmem(lbuffer);
uint fp = 0;
oe->open("file ../test/AES",&fp);
oe->read(fp,buffer,&lbuffer);
oe->close(fp);
tk = FunCallTokenizer_New(oe);
tk->start(buffer,lbuffer);
do {
tk->nextToken(&tok);
if (tok.type == INV) invs += 1;
if (tok.type == AND) ands +=1;
if (tok.type == XOR) xors += 1;
if (tok.type == NUM) nums += 1;
tokens++;
} while(tok.type != DONE);
DBG_P(oe,"\nANDS: %u\nXORS: %u\nINVS: %u\nNUMS: %u\nTOKENS: %u\n",ands,xors,invs,nums,tokens);
oe->putmem(buffer);
return ands == 6800 && xors == 24448 && nums == 139136 && tokens == 172076 && invs == 1691;
}
示例3: xor_commit
static XORcommitResult xor_commit(OE oe, Rnd rnd, CommitmentScheme cs, byte * circuit_string, uint lcircuit_string) {
XORcommitResult res = oe->getmem(sizeof(*res));
uint i = 0;
Data m0cmt = 0, m1cmt = 0;
res->m0 = oe->getmem(lcircuit_string);
res->m1 = oe->getmem(lcircuit_string);
rnd->rand(res->m0,lcircuit_string);
UserReport(oe,"m0 at random: ");
print_bit_string(oe,Data_shallow(res->m0,lcircuit_string));
res->lm0 = lcircuit_string;
res->lm1 = lcircuit_string;
for(i = 0; i < lcircuit_string; ++i) {
res->m1[i] = circuit_string[i] ^ res->m0[i];
}
// white box usage of commit we use 64 bits per commitment (sha512 with random value of length 16 bytes)
res->commitment = oe->getmem(128);
res->lcommitment = 128;
m0cmt = cs->commit(Data_shallow(res->m0,res->lm0));
m1cmt = cs->commit(Data_shallow(res->m1,res->lm1));
mcpy(m0cmt->data,res->commitment,m0cmt->ldata > 64 ? 64 : m0cmt->ldata);
mcpy(m1cmt->data,res->commitment+64,m1cmt->ldata > 64 ? 64 : m1cmt->ldata);
xor_commit_end:
Data_destroy(oe,&m0cmt);
Data_destroy(oe,&m1cmt);
return res;
}
示例4: MapEntry_destroy
void MapEntry_destroy(MapEntry * entry) {
OE oe = 0;
if (!entry) return;
if (!*entry) return;
oe = (*entry)->oe;
oe->putmem(*entry);
}
示例5: Cmaphore_new
// ------------------------------------------------------------
Cmaphore Cmaphore_new(OE oe, uint count) {
Cmaphore res = (Cmaphore)oe->getmem(sizeof(*res));
if (!res) return 0;
oe->newmutex(&(res->lock));
res->count = count;
res->oe = oe;
return res;
};
示例6: main
int main(int c, char **a) {
OE oe = OperatingEnvironment_New();
OE tmp = 0;
Map hmap = HashMap_new(oe,hfn,cfn,5);
hmap->put( (void*)(ull)1,oe);
if (hmap->size() == 1) oe->p("Testing size one [ok]");
else oe->p("Testing size one [fail]");
tmp = (OE)hmap->get( (void *)(ull)1 );
if (tmp == oe) oe->p("Testing get [ok]");
else oe->p("Testing get [fail]");
tmp = hmap->rem( (void*)(ull) 1);
if (tmp == oe) oe->p("Testing rem return [ok]");
else oe->p("Testing rem return [fail]");
if (hmap->size() == 0) oe->p("Testing rem size [ok]");
else {oe->p("Testing rem size [fail]"); }
OperatingEnvironment_Destroy( &oe );
return 0;
}
示例7: txt_book_fft
/*!
* {n} is the nth root number and f has that degree.
*
* {f} is an n vector of gf2^8 elements
*
* {omega} is root of unity of length n with 1, omega, omega^2 etc...
*
* TODO(rwl):
*
* I) Optimize the 1 of the omega list no need to have it there.
* II)
*/
void txt_book_fft(OE oe, uint n, byte * f, byte * omegas, byte * result) {
byte * r0 = 0;
byte * r1star = 0;
byte * new_omegas = 0;
byte * r0_result = 0;
byte * r1star_result = 0;
uint idx = 0;
byte omega = omegas[1];
byte q = 0;
// base case
if (n == 1) {
result[0] = f[0];
return;
}
r0 = oe->getmem(n/2+1);
r1star = oe->getmem(n/2+1);
// divide
for(idx = 0;idx<n/2;++idx) {
q = add(f[idx],f[idx+n/2]);
r0[idx] = q;
r1star[idx] = multiply(q,omegas[idx]);
}
if (n%2) {
r0[n/2] = f[n/2];
r1star[n/2]=multiply(f[n/2],omegas[n/2]);
}
new_omegas = oe->getmem(n);
r0_result = oe->getmem(n);
r1star_result = oe->getmem(n);
for(idx = 1;idx<n;++idx) {
new_omegas[idx] = multiply(omegas[idx],omega);
}
new_omegas[idx] = 1;
txt_book_fft(oe, n/2, r0, new_omegas, r0_result);
txt_book_fft(oe, n/2, r1star, new_omegas,r1star_result);
for(idx = 0;idx < 2*(n/2);idx+=2) {
result[idx] = eval_pol(r0_result,n/2,omegas[idx/2]);
result[idx+1]= eval_pol(r1star_result,n/2,omegas[idx/2]);
}
oe->putmem(r0);
oe->putmem(r1star);
oe->putmem(r0_result);
oe->putmem(r1star_result);
oe->putmem(new_omegas);
return;
}
示例8: main
int main(int c, char **a) {
char * material = 0, * bdt_material=0;
char * ip = "127.0.0.1";
uint count = 0, i = 0;
OE oe = OperatingEnvironment_LinuxNew();
MiniMacs mm = 0;
int * pids = 0;
InitStats(oe);
init_polynomial();
if (c < 3 || c > 5) {
printf("multirun <material> <bdt_material> <count> [< server >]\n");
return -1;
}
if ( c >= 3 ) {
material = a[1];
bdt_material = a[2];
}
if (c >= 4) {
count = atoi(a[3]);
}
if (c >= 5) {
ip =a[4];
}
// No bit encoder
mm=BitWiseMulPar2MiniMacs_DefaultLoadNew(oe, material, bdt_material, False);
if (!mm) {
printf("Unable to create MiniMacs, see errors above.\n");
return -1;
}
printf("Multirun CAES\n");
printf("material taken from: %s\n",material);
printf("ip: %s\n", ip);
printf("count: %u\n",count);
pids = (int*)oe->getmem(sizeof(int)*count);
for( i = 0; i < count; ++i) {
pids[i] = fork();
if (pids[i] == 0) {
return run(ip,i,count,oe,mm);
}
}
CHECK_POINT_S("TOTAL");
for(i = 0;i < count;++i) {
wait(pids[i]);
}
CHECK_POINT_E("TOTAL");
PrintMeasurements(oe);
}
示例9: main
int main(int c, char **a) {
char * material = 0, * bdt_material=0;
char * ip = "127.0.0.1";
uint count = 0, i = 0;
OE oe = OperatingEnvironment_LinuxNew();
MiniMacs mm = 0;
int * pids = 0;
InitStats(oe);
init_polynomial();
if (c < 3 || c > 5) {
printf("multirun <material> <bdt_material> <count> [< server >]\n");
return -1;
}
if ( c >= 3 ) {
material = a[1];
bdt_material = a[2];
}
if (c >= 4) {
count = atoi(a[3]);
}
if (c >= 5) {
ip =a[4];
}
// loads the preprocessing material making MiniMac ready
mm=BitWiseMulPar2MiniMacs_DefaultLoadFFTNew(oe, material, bdt_material, True);
printf("Multirun CAES\n");
printf("material taken from: %s\n",material);
printf("ip: %s\n", ip);
printf("count: %u\n",count);
pids = (int*)oe->getmem(sizeof(int)*count);
// create processes for parallel execution ({count} of them)
for( i = 0; i < count; ++i) {
pids[i] = fork();
if (pids[i] == 0) {
return run(ip,i,count,oe,mm);
}
}
// wait for everybody to complete
CHECK_POINT_S("TOTAL");
for(i = 0;i < count;++i) {
wait(pids[i]);
}
CHECK_POINT_E("TOTAL");
PrintMeasurements(oe);
}
示例10: test_listen
static int test_listen(OE oe) {
uint fd = 0;
oe->open("listen 2020",&fd);
if (!fd) {
oe->p("Unable to listen on port 2020");
return 0;
}
else {
oe->p("Accepting connections on 2020");
return 1;
}
}
示例11: test_open_file
static int test_open_file(OE oe) {
uint fd = 0;
oe->open("file C:\\Users\\rwl\\test.txt",&fd);
if (!fd) {
oe->p("unable to open file test.txt");
return 0;
}
else {
oe->p("test.txt successfully opened");
oe->close(fd);
return 1;
}
}
示例12: main
int main(int c, char **a) {
char * material = 0;
char * ip = "127.0.0.1";
uint count = 0, i = 0;
OE oe = OperatingEnvironment_LinuxNew();
MiniMacs mm = 0;
int * pids = 0;
InitStats(oe);
init_polynomial();
if (c < 2 || c > 4) {
printf("multirun <material> <count> [< server >]\n");
return -1;
}
if ( c >= 2 ) {
material = a[1];
}
if (c >= 3) {
count = atoi(a[2]);
}
if (c >= 4) {
ip =a[3];
}
mm=GenericFFTMiniMacs_new(oe,a[1]);
printf("Multirun CAES\n");
printf("material taken from: %s\n",material);
printf("ip: %s\n", ip);
printf("count: %u\n",count);
pids = (int*)oe->getmem(sizeof(int)*count);
for( i = 0; i < count; ++i) {
pids[i] = fork();
if (pids[i] == 0) {
return run(material,ip,i,oe,mm);
}
}
CHECK_POINT_S("TOTAL");
for(i = 0;i < count;++i) {
wait(pids[i]);
}
CHECK_POINT_E("TOTAL");
PrintMeasurements(oe);
}
示例13: run
static
int run(char * material, char * ip, uint count, OE oe, MiniMacs mm) {
CArena mc = CArena_new(oe);
MpcPeer mission_control = 0;
mc->connect("87.104.238.146", 65000);
mission_control = mc->get_peer(0);
if (!mission_control) {
oe->p("Failed connection to mission control. aborting.\n");
return -1;
}
if (mm->get_id() == 0) {
mm->invite(1,2020+count);
} else {
if (mm->connect(ip,2020+count) != 0) {
return 0;
}
}
{
byte key[128] = {0};
byte ptxt[128] = {0};
mpc_aes(mm,ptxt, key,mission_control);
CArena_destroy(&mc);
}
PrintMeasurements(oe);
return 0;
}
示例14: Aes_destroy
void Aes_destroy(OE oe, Aes * aes) {
if (!aes) return;
if (!*aes) return;
oe->putmem(*aes);
*aes = 0;
}
示例15: print_bit_string
static void print_bit_string(OE oe, Data bs) {
char buf[512] = {0};
uint idx = 0;
uint i = 0;
uint length = (sizeof(buf)-2) > bs->ldata*8 ? bs->ldata*8 : sizeof(buf)-2;
AddCh(buf,'\n',idx);
for(i = 0; i < bs->ldata*8 && idx < sizeof(buf)-2;++i) {
byte bit = get_bit(bs->data,i);
// add white space
if (i > 0 && i % 24 == 0) {
AddCh(buf,'\n',idx);
} else {
if (i > 0 && i % 8 == 0) {
AddCh(buf,' ',idx);
}
}
if (bit == 1) {
AddCh(buf,'1',idx);
} else {
AddCh(buf,'0',idx);
}
}
AddCh(buf,'\n',idx);
AddCh(buf,0,idx);
oe->p(buf);
}