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


C++ Benchmark::CollectTiming方法代码示例

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


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

示例1: gettimeofday

BOOL 
PRE1_reencrypt(CurveParams &params, ProxyCiphertext_PRE1 &origCiphertext, 
	       DelegationKey_PRE1 &delegationKey, 
	       ProxyCiphertext_PRE1 &newCiphertext)
{
#ifdef BENCHMARKING
  gettimeofday(&gTstart, &gTz);
#endif

  SAFESTATIC ZZn2 res1;

  // Compute the pairing res1 = e(kP, delegation)
  if (ecap(origCiphertext.c1a, delegationKey, params.q, params.cube, res1) == FALSE) {
    // Pairing failed.  Oops.
    PRINT_DEBUG_STRING("Re-encryption pairing failed."); 
    return false;
  }

  // Set the result ciphertext to (res1, c2)
  newCiphertext.set(CIPH_REENCRYPTED, res1, origCiphertext.c2);
  
#ifdef BENCHMARKING
  gettimeofday(&gTend, &gTz);
  gBenchmark.CollectTiming(REENCTIMING, CalculateUsecs(gTstart, gTend));
#endif

  return true;
}
开发者ID:iqman,项目名称:MACMSC,代码行数:28,代码来源:proxylib_pre1.cpp

示例2: PRE1_level2_encrypt

BOOL PRE1_level2_encrypt(CurveParams &params, Big &plaintext, ProxyPK_PRE1 &publicKey, ProxyCiphertext_PRE1 &ciphertext)
{
#ifdef BENCHMARKING
  gettimeofday(&gTstart, &gTz);
#endif

  SAFESTATIC Big k;
  SAFESTATIC ECn c1;
  SAFESTATIC ZZn2 temp, c2;
  SAFESTATIC ZZn2 zPlaintext;
  
  // Select a random value k \in Z*q and compute res1 = (k * P)  
  k = rand(params.q);
  c1 = k * params.P;

  // Compute res2 = plaintext * Zpub1^k
  zPlaintext.set(plaintext, 0);
  temp = pow(publicKey.Zpub1, k);
  c2 = zPlaintext * temp;
  
  // Set the ciphertext structure with (c1, c2)
  ciphertext.set(CIPH_SECOND_LEVEL, c1, c2);

#ifdef BENCHMARKING
  gettimeofday(&gTend, &gTz);
  gBenchmark.CollectTiming(LEVELTWOENCTIMING, CalculateUsecs(gTstart, gTend));
#endif

  return true;
}
开发者ID:iqman,项目名称:MACMSC,代码行数:30,代码来源:proxylib_pre1.cpp

示例3: PRE1_delegate

BOOL PRE1_delegate(CurveParams &params, ProxyPK_PRE1 &delegatee, ProxySK_PRE1 &delegator, DelegationKey_PRE1 &reskey)
{
#ifdef BENCHMARKING
  gettimeofday(&gTstart, &gTz);
#endif
 
  // Compute reskey = delegator.a1 * delegatee.Ppub2
  reskey = delegator.a1 * (delegatee.Ppub2);

#ifdef BENCHMARKING
  gettimeofday(&gTend, &gTz);
  gBenchmark.CollectTiming(DELEGATETIMING, CalculateUsecs(gTstart, gTend));
#endif

  return true;
}
开发者ID:iqman,项目名称:MACMSC,代码行数:16,代码来源:proxylib_pre1.cpp

示例4: PRE1_decrypt

BOOL PRE1_decrypt(CurveParams &params, ProxyCiphertext_PRE1 &ciphertext, ProxySK_PRE1 &secretKey, Big &plaintext)
{
#ifdef BENCHMARKING
  gettimeofday(&gTstart, &gTz);
#endif

  SAFESTATIC ECn del;
  SAFESTATIC ZZn2 temp;
  SAFESTATIC ZZn2 result;

 // Handle each type of ciphertext
 switch(ciphertext.type) {
 case CIPH_FIRST_LEVEL:
   // temp = c1^inv(a1)
   temp = pow(ciphertext.c1b, inverse(secretKey.a1, params.qsquared));
   //cout << "decrypt: temp = " << temp << endl;
   break;
 case CIPH_REENCRYPTED:
   // temp = c1^inv(a2)
   temp = pow(ciphertext.c1b, inverse(secretKey.a2, params.qsquared));
   break;
 case CIPH_SECOND_LEVEL:
   // temp = e(c1, a1 * P)
   del = secretKey.a1 * params.P;
   if (ecap(ciphertext.c1a, del, params.q, params.cube, temp) == FALSE) {
     PRINT_DEBUG_STRING("Decryption pairing failed.");
     return FALSE;
   }
   break;
 default:
   PRINT_DEBUG_STRING("Decryption failed: invalid ciphertext type.");
   break;
 }
 
 // Compute plaintext = c2 / temp
 result = ciphertext.c2 / temp;
 result.get(plaintext);

#ifdef BENCHMARKING
  gettimeofday(&gTend, &gTz);
  gBenchmark.CollectTiming(LEVELONEDECTIMING, CalculateUsecs(gTstart, gTend));
#endif

  return true;
}
开发者ID:iqman,项目名称:MACMSC,代码行数:45,代码来源:proxylib_pre1.cpp

示例5: PRE2_delegate

BOOL PRE2_delegate(CurveParams &params, ProxyPK_PRE2 &delegatee,
		   ProxySK_PRE2 &delegator, DelegationKey_PRE2 &reskey)
{
#ifdef BENCHMARKING
  gettimeofday(&gTstart, &gTz);
#endif
 
  // Compute reskey = delegator.a1 * delegatee.Ppub2
  Big a1inv = inverse(delegator.a1, params.q);
  reskey = a1inv * (delegatee.Ppub2);

  ECn Q = delegator.a1 * params.P;
 
  ZZn2 res1;
  
#ifdef BENCHMARKING
  gettimeofday(&gTend, &gTz);
  gBenchmark.CollectTiming(DELEGATETIMING, CalculateUsecs(gTstart, gTend));
#endif

  return true;
}
开发者ID:iqman,项目名称:MACMSC,代码行数:22,代码来源:proxylib_pre2.cpp


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