当前位置: 首页>>代码示例>>C++>>正文


C++ OE::getmem方法代码示例

本文整理汇总了C++中OE::getmem方法的典型用法代码示例。如果您正苦于以下问题:C++ OE::getmem方法的具体用法?C++ OE::getmem怎么用?C++ OE::getmem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OE的用法示例。


在下文中一共展示了OE::getmem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:29,代码来源:rtz14.c

示例2: 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;
}
开发者ID:diegode,项目名称:MiniTrix,代码行数:66,代码来源:fft.c

示例3: 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;
}
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:26,代码来源:test_funtokenizer.c

示例4: Observer_DefaultNew

Observer Observer_DefaultNew( OE oe,  void (*fn)(void *data) ) {
  Observer res = (Observer)oe->getmem(sizeof(*res));
  if (!res) return 0;

  res->notify = fn;

  return res;
}
开发者ID:AarhusCrypto,项目名称:MiniAES,代码行数:8,代码来源:minimacs.c

示例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;
};
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:9,代码来源:osal.c

示例6: NodeNew

static Node NodeNew(OE oe, void * element, Node next)
{
  Node res = oe->getmem(sizeof(*res));
  if (!res) return res;
  
  res->element = element;
  res->next = next;

  return res;
}
开发者ID:diegode,项目名称:MiniTrix,代码行数:10,代码来源:singlelinkedlist.c

示例7: 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);
}
开发者ID:diegode,项目名称:MiniTrix,代码行数:54,代码来源:mulpar2mxt.c

示例8: FDEntry_new

static uint FDEntry_new(OE oe, List entries, int osfd) {
  FDEntry r = (FDEntry)oe->getmem(sizeof(*r));
  if (!r) return 0;

  r->osfd = osfd;
  r->fd = ++fd_pool;

  entries->add_element(r);

  return r->fd;
}
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:11,代码来源:osal.c

示例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);
}
开发者ID:diegode,项目名称:MiniTrix,代码行数:53,代码来源:manymulpar2bitfft.c

示例10: MapEntry_new

MapEntry MapEntry_new(OE oe, void * key, void * elm) {
  MapEntry ent = (MapEntry)oe->getmem(sizeof(*ent));
  if (!ent) return 0;

  if (!oe) return 0;

  ent->key = key;
  ent->elm = elm;
  ent->oe = oe;

  return ent;
}
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:12,代码来源:map.c

示例11: 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);
}
开发者ID:diegode,项目名称:MiniTrix,代码行数:48,代码来源:multifftrun.c

示例12: main

int main(int c, char **a) {
    OE oe = (OE)OperatingEnvironment_LinuxNew();
    MiniMacs mm = 0;
    Data input = 0;
    uint count=0,i=0;
    init_polynomial();

    mm = GenericMiniMacs_DefaultLoadNew(oe,a[1]);

    InitStats(oe);

    if (!mm) {
        oe->p("Error could not create instance of MiniMacs");
        OperatingEnvironment_LinuxDestroy(&oe);
        return -1;
    }

    {
        CliArg arg = (CliArg)oe->getmem(sizeof(*arg));
        arg->file = a[2];
        arg->oe = oe;
        oe->newthread(client,arg);
    }

    mm->init_heap(2);
    mm->invite(1,8080);
    printf("Got client ... \n");

    input = Data_new(oe, mm->get_ltext());
    for(i = 0; i < mm->get_ltext(); ++i) {
        input->data[i] = 'r';
    }

    mm->secret_input(0,0,input);

    for(count = 0; count < COUNT; ++count) {
        CHECK_POINT_S("Mul server");
        mm->mul(1,0,0);
        CHECK_POINT_E("Mul server");
    }

    usleep(5);
    PrintMeasurements(oe);

    return 0;
}
开发者ID:diegode,项目名称:MiniTrix,代码行数:46,代码来源:perf.c

示例13: test_large_file

static int test_large_file(OE oe) {
	_Bool ok = 1;
	uint lbuffer = 1060365;
	uint ands = 0, xors = 0, nums = 0, tokens = 0;
	Tokenizer tk = 0;CircuitParser cp = 0;
	List ast = 0;
	byte * buffer = oe->getmem(lbuffer);
	uint fp = 0, i = 0;
	CircuitVisitor cv = 0; 
	Map input_gates = 0;
	List aoig = 0;
	DateTime clock = 0;
	ull start = 0;
	oe->open("file ../test/AES",&fp);
	cv = InputGateVisitor_New(oe);
	clock = DateTime_New(oe);
	start = clock->getMicroTime();
	oe->read(fp,buffer,&lbuffer);
	oe->close(fp);
	DBG_P(oe,"reading file took %u microseconds",clock->getMicroTime()-start);
	tk = FunCallTokenizer_New(oe);
	cp = CircuitParser_New(oe,tk);
	start = clock->getMicroTime();
	ast = cp->parseSource(buffer,lbuffer);
	DBG_P(oe,"parsing circuit took %u microseconds.",clock->getMicroTime()-start);
	oe->putmem(buffer);


	start = clock->getMicroTime();
	input_gates = cv->visit(ast);
	AssertTrue(input_gates != 0)

	aoig = input_gates->get_keys();
	if (aoig) {
		DBG_P(oe,"#Input: %u analysis took %u microseconds",aoig->size(),clock->getMicroTime()-start);
	}

	AssertTrue( aoig != 0 );
	test_end:
	return ok;
}
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:41,代码来源:test_inputgatevisitor.c

示例14: Aes_new

Aes Aes_new(OE oe) {
  Aes res = (Aes)oe->getmem(sizeof(*res));
  return res;
}
开发者ID:AarhusCrypto,项目名称:MiniAES,代码行数:4,代码来源:cheetah.c

示例15: string

COO_DEF(Rtz14,bool,executeProof, List circuit, byte * witness, char * ip, uint port) {
	Rtz14Impl impl = (Rtz14Impl)this->impl;
	OE oe = impl->oe;
	Map input_gates = 0;
	CircuitVisitor emitter = 0;
	// TODO(rwz): take the igv as constructor argument.
	CircuitVisitor igv = 0;
	EmiterResult emitter_res = 0;
	byte * emitted_circuit = 0;
	CArena conn = 0;
	CircuitVisitor proof_task_builder = 0;
	List proof_tasks = 0;
	CircuitVisitor gpam = 0;
	CircuitVisitor poc = 0;
	CircuitVisitor ogv = 0;
	List output_gates = 0;
	Rnd rnd = 0;
	GPam gpam_res = 0;
	DateTime d = DateTime_New(oe);
	ull start = d->getMilliTime();
	uint no_inputs = 0;

	_Bool accept = 0;
	ProofTask check_out_bit = (ProofTask)oe->getmem(sizeof(*check_out_bit));


	// create and call helper strategies
	// TODO(rwz): strategies should be given as constructor arguments instead
	// of being created here. (for testability and maintainability)

	// default one address is 0, however it can be set during create of
	// RTZ14.
	poc = PatchOneConstants_New(oe,impl->address_of_one);
	if (!poc) return False;

	// patch addresses.
	poc->visit(circuit);

	// compute map mapping addresses to input
	igv = InputGateVisitor_New(oe);
	if (!igv) return False;

	input_gates = igv->visit(circuit);
	if (!input_gates) return False;
	no_inputs = input_gates->size();

	ogv = OutputGateVisitor_New(oe);
	if (!ogv) return False;

	output_gates = ogv->visit(circuit);
	if (!output_gates) {
		return False;
	}

	if (output_gates->size() != 1) {
		oe->syslog(OSAL_LOGLEVEL_FATAL,"The provided circuit does not have one unique output.");
		return False;
	}
	check_out_bit->indicies[0] = output_gates->get_element(0);
	check_out_bit->indicies[1] = impl->address_of_one;
	check_out_bit->indicies[2] = impl->address_of_one;


	OutputGateVisitor_Destroy(&ogv);
	SingleLinkedList_destroy(&output_gates);



	// go online
	conn = CArena_new(oe);
	if (!conn) return False;


	if (ip == 0) {
		// -----------------------------
		// ----------- Prover ----------
		// -----------------------------
		MpcPeer verifier = 0;
		byte and_challenge[1] = {0};
		Data challenge_commitment = Data_new(oe,80);
		XORcommitResult xom = 0;
		Data epsilon = Data_new(oe,1);
		Data delta = 0;
		Data judgement = Data_new(oe,8);
		// The message containing the evaluated circuit, input bits (witness)
		// and the auxiliary informations for each and-gate.
		Data message = 0;

		if (witness == 0) {
			oe->syslog(OSAL_LOGLEVEL_FATAL,"No witness !");
			return False;
		}

		UserReport(oe,"Prover preparing ... ");
		// compute evaluated circuit
		emitter = EvaluationStringEmitter_New(oe, input_gates, witness);
		if (!emitter) return False;

		emitter_res = emitter->visit(circuit);
		if (!emitter_res) return False;
//.........这里部分代码省略.........
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:101,代码来源:rtz14.c


注:本文中的OE::getmem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。