コード例 #1
0
int main(int argc, char *argv[]) 
{
  ArgMapping amap;

  long p=2;
  long r=1;
  long c=3;
  long L=600;
  long N=0;
  long t=0;
  long nthreads=1;

  long seed=0;
  long useCache=1;

  amap.arg("p", p, "plaintext base");

  amap.arg("r", r,  "exponent");
  amap.note("p^r is the plaintext-space modulus");

  amap.arg("c", c, "number of columns in the key-switching matrices");
  amap.arg("L", L, "# of levels in the modulus chain");
  amap.arg("N", N, "lower-bound on phi(m)");
  amap.arg("t", t, "Hamming weight of recryption secret key", "heuristic");
  amap.arg("dry", dry, "dry=1 for a dry-run");
  amap.arg("nthreads", nthreads, "number of threads");
  amap.arg("seed", seed, "random number seed");
  amap.arg("noPrint", noPrint, "suppress printouts");
  amap.arg("useCache", useCache, "0: zzX cache, 1: DCRT cache");

  amap.arg("force_bsgs", fhe_test_force_bsgs);
  amap.arg("force_hoist", fhe_test_force_hoist);

  //  amap.arg("disable_intFactor", fhe_disable_intFactor);
  amap.arg("chen_han", fhe_force_chen_han);

  amap.arg("debug", debug, "generate debugging output");
  amap.arg("scale", scale, "scale parameter");


  amap.parse(argc, argv);

  if (seed) 
    SetSeed(ZZ(seed));

  SetNumThreads(nthreads);

  for (long i=0; i<(long)num_mValues; i++)
    if (mValues[i][0]==p && mValues[i][1]>=N) {
      TestIt(i,p,r,L,c,t,useCache);
      break;
    }

  return 0;
}
コード例 #2
0
ファイル: Test_ThinEvalMap.cpp プロジェクト: lbathen/HElib
/* Usage: Test_EvalMap_x.exe [ name=value ]...
 *  p       plaintext base  [ default=2 ]
 *  r       lifting  [ default=1 ]
 *  c       number of columns in the key-switching matrices  [ default=2 ]
 *  k       security parameter  [ default=80 ]
 *  L       # of levels in the modulus chain  [ default=6 ]
 *  s       minimum number of slots  [ default=0 ]
 *  seed    PRG seed  [ default=0 ]
 *  mvec    use specified factorization of m
 *             e.g., mvec='[5 3 187]'
 *  gens    use specified vector of generators
 *             e.g., gens='[562 1871 751]'
 *  ords    use specified vector of orders
 *             e.g., ords='[4 2 -4]', negative means 'bad'
 */
int main(int argc, char *argv[])
{
  ArgMapping amap;

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

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

  long c=2;
  amap.arg("c", c, "number of columns in the key-switching matrices");
  
  long k=80;
  amap.arg("k", k, "security parameter");

  long L=6;
  amap.arg("L", L, "# of levels in the modulus chain");

  long s=0;
  amap.arg("s", s, "minimum number of slots");

  long seed=0;
  amap.arg("seed", seed, "PRG seed");

  Vec<long> mvec;
  amap.arg("mvec", mvec, "use specified factorization of m", NULL);
  amap.note("e.g., mvec='[7 3 221]'");

  Vec<long> gens;
  amap.arg("gens", gens, "use specified vector of generators", NULL);
  amap.note("e.g., gens='[3979 3095 3760]'");

  Vec<long> ords;
  amap.arg("ords", ords, "use specified vector of orders", NULL);
  amap.note("e.g., ords='[6 2 -8]', negative means 'bad'");

  amap.arg("dry", dry, "a dry-run flag to check the noise");

  long nthreads=1;
  amap.arg("nthreads", nthreads, "number of threads");

  amap.arg("noPrint", noPrint, "suppress printouts");

  long useCache=0;
  amap.arg("useCache", useCache, "0: zzX cache, 2: DCRT cache");

  amap.parse(argc, argv);

  SetNumThreads(nthreads);

  SetSeed(conv<ZZ>(seed));
  TestIt(p, r, c, k, /*Key Hamming weight=*/64, L, mvec, gens, ords, useCache);
}
コード例 #3
0
ファイル: tfactor.c プロジェクト: tell/ntl-unix
NTL_CLIENT



//namespace NTL { extern double ip_time; }

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

   long n = 1024;
   amap.arg("n", n, "degree bound");

   long l = 1024;
   amap.arg("l", l, "coeff bound");

   long nt = 1;
   amap.arg("nt", nt, "num threads");

   amap.parse(argc, argv);

   cerr << "\n\n=============================\n\n";

   cerr << "n=" << n << "\n";
   cerr << "l=" << l << "\n";
   cerr << "nt=" << nt << "\n";

   SetSeed(ZZ(0));

   SetNumThreads(nt);

   ZZ p;

   RandomPrime(p, l);
   ZZ_p::init(p);


   ZZ_pX f;

   random(f, n);
   SetCoeff(f, n);

   Vec< Pair<ZZ_pX, long> > fac;


   double t;

   ZZ_pXFileThresh = 1e9;



   FILE *fp;
   unsigned long A[4], B[4];
   int loadavg;

   fp = fopen("/proc/stat","r");
   fscanf(fp,"cpu %lu %lu %lu %lu",&A[0],&A[1],&A[2],&A[3]);
   fclose(fp);
   
   
   t = GetTime();
   CanZass(fac, f, 1);
   t = GetTime()-t;
   double NTLTime = t;

   fp = fopen("/proc/stat","r");
   fscanf(fp,"cpu %lu %lu %lu %lu",&B[0],&B[1],&B[2],&B[3]);
   fclose(fp);
   
   // we multiply by 20 -- that's the total number of cores
   loadavg = int(100.0*20.0*double((B[0]+B[1]+B[2]) - (A[0]+A[1]+A[2])) / 
      double((B[0]+B[1]+B[2]+B[3]) - (A[0]+A[1]+A[2]+A[3])));
   fprintf(stderr, "CPU utilization: %d\%\n",loadavg);

   struct rusage rusage;
   getrusage( RUSAGE_SELF, &rusage );

   cerr << "MAX_RSS="<<rusage.ru_maxrss <<  "KB" << endl;
   cerr << "Fac: " << t << "\n";

   //cerr << "ip_time: " << ip_time << "\n";

   delete NTLThreadPool;
   NTLThreadPool = 0;


}