Esempio n. 1
0
int main(int argc, char *argv[]) 
{
  argmap_t argmap;
  argmap["c"] = "2";
  argmap["k"] = "80";
  argmap["L"] = "20";
  argmap["m"] = "0";
  argmap["n"] = "0";

  // get parameters from the command line
  if (!parseArgs(argc, argv, argmap)) usage(argv[0]);

  long c = atoi(argmap["c"]);
  long k = atoi(argmap["k"]);
  long L = atoi(argmap["L"]);
  long chosen_m = atoi(argmap["m"]);
  long n = atoi(argmap["n"]);

  long w = 64; // Hamming weight of secret key
  //  long L = z*R; // number of levels

  long m = FindM(k, L, c, 2, 1, 0, chosen_m, true);

  setTimersOn();
  TestIt(c, k, w, L, m, n);

  cerr << endl;
  printAllTimers();
  cerr << endl;

}
Esempio n. 2
0
/*
 * Function:	TestLedHC1
 *
 * Description:	test the LEDx on the High Clearence Dome #1
 *
 * Parameters:
 *		int   row
 *		int   column
 * 
 * Return Values
 *		none
 *
 * Discussion:
 *
 *				1. determine the LED row & colume
 *				2. test it. (displays the camera picture too)
 *				3. draw a circle where we thing the LED is.
 *				4. measure the pixel value.
 *				5. if below minimum value, indicate LED failed at ROW, COLUMN
 */
void
TCDSti::TestLedHC1(int row, int column)
{
	int x = 0, y = 0, led;
	CString msg;

	switch (row)
	{
		case 8:  // ????
		case 9:
		case 10:
		case 11:
			if (column ==  3 || column ==  4 || column ==  5 || column ==  6 ||
				column == 13 || column == 14 || column == 15 || column == 16 ||
				column == 23 || column == 24 || column == 25 || column == 26 ||
				column == 33 || column == 34 || column == 35 || column == 36)
					break;
		default:
			TestIt(row, column);
			PositionLED(x, y, row, column);
			DrawCircle(x, y);
	}
	// test pixel results for LED
	if ((led = GetLEDValue(x, y)) < MIN_LEDVALUE)
	{
		msg.Format("Row %d Column %d failed at %d", row, column, led);
		DiagOutput(msg);
		m_DomePF     = DIAG_FAILED;
	}
	if (::SendMessage(m_SlowButton.m_hWnd, BM_GETCHECK, 0, 0) == TRUE)
		Sleep(200);
}
Esempio n. 3
0
int main(int argc, char *argv[]) 
{
  ArgMapping amap;

  bool dry=false;
  amap.arg("dry", dry, "dry=1 for a dry-run");

  long m=2047;
  amap.arg("m", m, "cyclotomic ring");

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

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

  long d=1;
  amap.arg("d", d, "degree of the field extension");
  amap.note("d == 0 => factors[0] defines extension");

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

  long bnd = 64;
  amap.arg("bnd", bnd, "recursion bound for replication");

  long B = 0;
  amap.arg("B", B, "bound for # of replications", "all");

  amap.parse(argc, argv);
  setDryRun(dry);

  TestIt(m, p, r, d, L, bnd, B);
  cout << endl;
}
Esempio n. 4
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;
}
Esempio n. 5
0
/* 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);
}
Esempio n. 6
0
int main(int argc, char *argv[]) 
{
  argmap_t argmap;
  argmap["R"] = "1";
  argmap["p"] = "2";
  argmap["r"] = "1";
  argmap["d"] = "1";
  argmap["c"] = "2";
  argmap["k"] = "80";
  argmap["L"] = "0";
  argmap["s"] = "0";
  argmap["m"] = "0";
  argmap["repeat"] = "1";

  // get parameters from the command line
  if (!parseArgs(argc, argv, argmap)) usage(argv[0]);

  long R = atoi(argmap["R"]);
  long p = atoi(argmap["p"]);
  long r = atoi(argmap["r"]);
  long d = atoi(argmap["d"]);
  long c = atoi(argmap["c"]);
  long k = atoi(argmap["k"]);
  //  long z = atoi(argmap["z"]);
  long L = atoi(argmap["L"]);
  if (L==0) { // determine L based on R,r
    L = 3*R+3;
    if (p>2 || r>1) { // add some more primes for each round
      long addPerRound = 2*ceil(log((double)p)*r*3)/(log(2.0)*NTL_SP_NBITS) +1;
      L += R * addPerRound;
    }
  }
  long s = atoi(argmap["s"]);
  long chosen_m = atoi(argmap["m"]);

  long repeat = atoi(argmap["repeat"]);

  long w = 64; // Hamming weight of secret key
  //  long L = z*R; // number of levels

  long m = FindM(k, L, c, p, d, s, chosen_m, true);

  setTimersOn();
  for (long repeat_cnt = 0; repeat_cnt < repeat; repeat_cnt++) {
    TestIt(R, p, r, d, c, k, w, L, m);
  }

}
Esempio n. 7
0
/*
 * Function:	TestLedSTD
 *
 * Description:	test the LEDx on the Standard Dome
 *
 * Parameters:
 *		int   row
 *		int   column
 * 
 * Return Values
 *		none
 *
 * Discussion:
 *
 *				1. determine the LED row & colume
 *				2. test it. (displays the camera picture too)
 *				3. draw a circle where we thing the LED is.
 *				4. measure the pixel value.
 *				5. if below minimum value, indicate LED failed at ROW, COLUMN
 */
void
TCDSti::TestLedSTD(int row, int column)
{
	/*	pixel coordinates with in camera view
		origin ((0, 0) is the center of view.

		         |
          -X, -Y | +X,-Y	
                 |
        --------0+0--------
                 |
          -X, +Y | +X,+Y	
                 |
	*/

	int x = 0, y = 0, led;
	CString msg;

	switch (row)
	{
		case 0: //row 0 has two LEDs
			PositionLED_STD0(x, y, column, /* led */0); // x & y values are from here
			DrawCircle(x, y);                         // draw target

			// test pixel results for LED 0
			if ((led = GetLEDValue(x, y)) < MIN_LEDVALUE)
			{
				msg.Format("Row 0A, Column %d failed at %d", column, led);
				DiagOutput(msg);
				m_DomePF     = DIAG_FAILED;
			}

			TestIt(row, column);
			PositionLED_STD0(x, y, column, /* led */1);
			DrawCircle(x, y);

			// test pixel results for LED 1
			if ((led = GetLEDValue(x, y)) < MIN_LEDVALUE)
			{
				msg.Format("Row 0B, Column %d failed at %d", column, led);
				DiagOutput(msg);
				m_DomePF     = DIAG_FAILED;
			}
			break;

		case 9:
			if (column ==  3 || column ==  4 || column ==  5 || column ==  6 ||
				column == 13 || column == 14 || column == 15 || column == 16 ||
				column == 23 || column == 24 || column == 25 || column == 26 ||
				column == 33 || column == 34 || column == 35 || column == 36)
					break;

			TestIt(row, column);
			PositionLED_STD9(x, y, column);
			DrawCircle(x, y);

			// test pixel results for LED
			if ((led = GetLEDValue(x, y)) < MIN_LEDVALUE)
			{
				msg.Format("Row 9, Column %d failed at %d", column, led);
				DiagOutput(msg);
				m_DomePF     = DIAG_FAILED;
			}
			break;

		case 21:
		case 22:
		case 23:
				TestIt(row, column);
		break;

		case 7:
		case 8:
			if (column ==  3 || column ==  4 || column ==  5 || column ==  6 ||
				column == 13 || column == 14 || column == 15 || column == 16 ||
				column == 23 || column == 24 || column == 25 || column == 26 ||
				column == 33 || column == 34 || column == 35 || column == 36)
					break;
		default:

			TestIt(row, column);
			PositionLED(x, y, row, column);
			DrawCircle(x, y);
			// test pixel results for LED
			if ((led = GetLEDValue(x, y)) < MIN_LEDVALUE)
			{
				msg.Format("Row %d Column %d failed at %d", row, column, led);
				DiagOutput(msg);
				m_DomePF     = DIAG_FAILED;
			}
			break;
	}
	if (::SendMessage(m_SlowButton.m_hWnd, BM_GETCHECK, 0, 0) == TRUE)
		Sleep(200);

}
Esempio n. 8
0
REG_T GetCpFromXp(EDIT *pMem, REG_T lpChars, DWORD x, DWORD fNoAdjust)
{
	REG_T eax = 0, ecx, edx, esi, edi;
	REG_T temp1, temp2, temp3;
	REG_T hDC;
	RECT rect;
	DWORD lastright;

	auto void TestIt(void);

	eax = GetDC(pMem->hwnd);
	hDC = eax;
	eax = SelectObject(hDC, pMem->fnt.hFont);
	temp1 = eax;
	eax = pMem->cpx;
	eax = -eax;
	eax += pMem->linenrwt;
	eax += pMem->selbarwt;
	x -= eax;
	eax = 0;
	rect.left = eax;
	rect.right = eax;
	rect.top = eax;
	rect.bottom = eax;
	lastright = eax;
	esi = lpChars;
	edi = ((CHARS *)esi)->len;
	edi /= 2;
	edx = edi;
	ecx = 0;
anon_8:
	temp2 = ecx;
	temp3 = edx;
	TestIt();
	edx = temp3;
	ecx = temp2;
	edx /= 2;
	if(R_SIGNED(eax) > (SDWORD)x)
	{
		edi -= edx;
		if(edx!=0)
		{
			goto anon_8;
		} // endif
	}
	else if(R_SIGNED(eax) < (SDWORD)x)
	{
		eax = rect.right;
		lastright = eax;
		ecx = edi;
		edi += edx;
		if(edx!=0)
		{
			goto anon_8;
		} // endif
	} // endif
	edi = ecx;
	if(edi)
	{
		eax = lastright;
		rect.right = eax;
	}
	else
	{
		rect.right = edi;
	} // endif
	while(edi<((CHARS *)esi)->len)
	{
		if(*(BYTE *)(esi+edi+sizeof(CHARS))==0x0D)
		{
			break;
		} // endif
		temp2 = rect.right;
		edi++;
		TestIt();
		edi--;
		edx = temp2;
		if(!fNoAdjust)
		{
			edx -= eax;
			edx = -edx;
			edx /= 2;
			eax -= edx;
		} // endif
		if(R_SIGNED(eax) > (SDWORD)x)
		{
			break;
		} // endif
		edi++;
	} // endw
	eax = temp1;
	eax = SelectObject(hDC, eax);
	eax = ReleaseDC(pMem->hwnd, hDC);
	eax = edi;
	return eax;

	void TestIt(void)
	{
		eax = GetTextWidth(pMem, hDC, esi+sizeof(CHARS), edi, &rect);
		eax = rect.right;
		return;

	}