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


C++ EncryptedArray::decrypt方法代码示例

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


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

示例1: p

vector<PlaintextArray> decryptVotes(vector<Ctxt> votes, EncryptedArray ea, const FHESecKey secretKey) {
  vector<PlaintextArray> ret;
  for(int i = 0; i < votes.size(); i++) {
    PlaintextArray p(ea);
    ea.decrypt(votes[i], secretKey, p);
    ret.push_back(p);
  }

  return ret;
}
开发者ID:ruescasd,项目名称:FHLD,代码行数:10,代码来源:FHLD.cpp

示例2: check_replicate

NTL_CLIENT

#include "FHE.h"
#include "replicate.h"
#include "timing.h"

static bool check_replicate(const Ctxt& c1, const Ctxt& c0, long i,
			    const FHESecKey& sKey, const EncryptedArray& ea)
{
  PlaintextArray pa0(ea), pa1(ea);
  ea.decrypt(c0, sKey, pa0);
  ea.decrypt(c1, sKey, pa1);
  pa0.replicate(i);
  
  return pa1.equals(pa0); // returns true if replication succeeded
}
开发者ID:bbigcookie,项目名称:HElib,代码行数:16,代码来源:Test_Replicate.cpp

示例3: decrypt

PlaintextArray decrypt(Ctxt ctxt, EncryptedArray ea, const FHESecKey secretKey) {
  PlaintextArray p(ea);
  ea.decrypt(ctxt, secretKey, p);

  return p;
}
开发者ID:ruescasd,项目名称:FHLD,代码行数:6,代码来源:FHLD.cpp

示例4: show

void show(Ctxt ctxt, EncryptedArray ea, const FHESecKey secretKey) {
  PlaintextArray p(ea);
  ea.decrypt(ctxt, secretKey, p);

  printVoteFull(p);
}
开发者ID:ruescasd,项目名称:FHLD,代码行数:6,代码来源:FHLD.cpp

示例5: main

int main(int argc, char *argv[]) 
{
  ArgMapping amap;

  long m=53;
  amap.arg("m", m, "use specified value as modulus");

  long p=17;
  amap.arg("p", p, "plaintext base");

  long r=1;
  amap.arg("r", r,  "lifting");

  long levels=5;
  amap.arg("L", levels,  "levels");

  long nb_coeffs=5;
  amap.arg("n", nb_coeffs,  "nb coefficients to extract");

  amap.parse(argc, argv);

  cout << "\n\n******** generate parameters"
       << " m=" << m 
       << ", p=" << p
       << ", r=" << r
       << ", n=" << nb_coeffs
       << endl;

  setTimersOn();

  FHEcontext context(m, p, r);
  buildModChain(context, /*L=*/levels);
  // cout << context << endl;
  // context.zMStar.printout();
  // cout << endl;

  cout << "Generating keys and key-switching matrices... " << std::flush;
  FHESecKey secretKey(context);
  secretKey.GenSecKey(/*w=*/64);// A Hamming-weight-w secret key
  addFrbMatrices(secretKey); // compute key-switching matrices that we need
  add1DMatrices(secretKey); // compute key-switching matrices that we need
  const FHEPubKey& publicKey = secretKey;
  cout << "done\n";

  resetAllTimers();

  EncryptedArray ea = *(context.ea);
  ea.buildLinPolyMat(false);

  Ctxt ctxt(publicKey);
  NewPlaintextArray ptxt(ea);
  random(ea, ptxt);
  // ea.encrypt(ctxt, publicKey, ptxt);
  ea.skEncrypt(ctxt, secretKey, ptxt);


  cout << "Extracting " << nb_coeffs << " coefficients...";
  vector<Ctxt> coeffs;
  extractCoeffs(ea, coeffs, ctxt, nb_coeffs);
  cout << "done\n";

  vector<ZZX> ptxtDec;
  ea.decrypt(ctxt, secretKey, ptxtDec);

  for (long i=0; i<(long)coeffs.size(); i++) {
    if (!coeffs[i].isCorrect()) {
      cerr << " potential decryption error for "<<i<<"th coeffs " << endl;
      CheckCtxt(coeffs[i], "");
      exit(0);
    }
    vector<ZZX> pCoeffs;
    ea.decrypt(coeffs[i], secretKey, pCoeffs);

    assert(pCoeffs.size() == ptxtDec.size());

    for (int j = 0; j < pCoeffs.size(); ++j) {
      if (coeff(pCoeffs[j], 0) != coeff(ptxtDec[j], i)) {
        cerr << "error: extracted coefficient " << i << " from " 
          "slot " << j << " is " << coeff(pCoeffs[j], 0) << " instead of " << 
          coeff(ptxtDec[j], i) << endl;
        exit(0);
      }
    }

  }  
  cerr << "Extracted coefficient successfully verified!\n";
}
开发者ID:ssmiler,项目名称:HElib,代码行数:87,代码来源:Test_extractCoeffs.cpp


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