コード例 #1
0
struct msgOneArrays_ECC *proverMessageOne_ECC(int stat_SecParam, struct eccParams *params,
											unsigned char *J_set, struct eccPoint *alpha,
											struct eccPoint *g_0, struct eccPoint *g_1,
											struct eccPoint **h_0_List, struct eccPoint **h_1_List, gmp_randstate_t state)
{
	struct msgOneArrays_ECC *msgArray = initMsgOneArray_ECC(stat_SecParam);
	struct eccPoint *topHalf, *bottomHalf;
	int i, j_in_I = 0, j_not_I = 0;


	for(i = 0; i < stat_SecParam; i ++)
	{
		// If i IS in I
		if(0x00 == J_set[i])
		{
			msgArray -> notI_Struct -> not_in_I_index[j_not_I] = i + 1;

			// Generate a random exponent pair C and Z.
			mpz_urandomm(msgArray -> notI_Struct -> C_array[j_not_I], state, params -> n);
			mpz_urandomm(msgArray -> notI_Struct -> Z_array[j_not_I], state, params -> n);


			// Compute the A share using C and Z
			topHalf = windowedScalarPoint(msgArray -> notI_Struct -> Z_array[j_not_I], g_0, params);
			bottomHalf = windowedScalarPoint(msgArray -> notI_Struct -> C_array[j_not_I], h_0_List[i], params);
			msgArray -> A_array[i] = invertPoint(bottomHalf, params);
			groupOp_PlusEqual(msgArray -> A_array[i], topHalf, params);

			clearECC_Point(topHalf);
			clearECC_Point(bottomHalf);


			// Compute the B share using C and Z
			topHalf = windowedScalarPoint(msgArray -> notI_Struct -> Z_array[j_not_I], g_1, params);
			bottomHalf = windowedScalarPoint(msgArray -> notI_Struct -> C_array[j_not_I], h_1_List[i], params);
			msgArray -> B_array[i] = invertPoint(bottomHalf, params);
			groupOp_PlusEqual(msgArray -> B_array[i], topHalf, params);			

			clearECC_Point(topHalf);
			clearECC_Point(bottomHalf);

			j_not_I ++;
		}
		else
		{
			// Raise the A and B to the power of a random (and stored) exponent
			msgArray -> in_I_index[j_in_I] = i + 1;

			mpz_urandomm(msgArray -> roeArray[j_in_I], state, params -> n);

			msgArray -> A_array[i] = windowedScalarPoint(msgArray -> roeArray[j_in_I], g_0, params);
			msgArray -> B_array[i] = windowedScalarPoint(msgArray -> roeArray[j_in_I], g_1, params);

			j_in_I ++;
		}
	}


	return msgArray;
}
コード例 #2
0
ファイル: GoblinTransform.cpp プロジェクト: bachi95/Goblin
 BBox Transform::invertBBox(const BBox& b) const {
     BBox rv(invertPoint(b.pMin));
     rv.expand(invertPoint(Vector3(b.pMax.x, b.pMin.y, b.pMin.z)));
     rv.expand(invertPoint(Vector3(b.pMin.x, b.pMax.y, b.pMin.z)));
     rv.expand(invertPoint(Vector3(b.pMin.x, b.pMin.y, b.pMax.z)));
     rv.expand(invertPoint(Vector3(b.pMax.x, b.pMax.y, b.pMin.z)));
     rv.expand(invertPoint(Vector3(b.pMax.x, b.pMin.y, b.pMax.z)));
     rv.expand(invertPoint(Vector3(b.pMin.x, b.pMax.y, b.pMax.z)));
     rv.expand(invertPoint(b.pMax));
     return rv;
 }
コード例 #3
0
ファイル: GoblinTransform.cpp プロジェクト: bachi95/Goblin
 Ray Transform::invertRay(const Ray& r) const {
     return Ray(invertPoint(r.o), invertVector(r.d), 
         r.mint, r.maxt, r.depth);
 }
コード例 #4
0
// Verifer does the final checks to give a decision.
int verifierChecks_ECC(struct eccParams *params, int stat_SecParam,
					struct eccPoint *g_0, struct eccPoint *g_1,
					struct eccPoint **h_0_List, struct eccPoint **h_1_List,
					mpz_t *Z_array, struct eccPoint **A_array, struct eccPoint **B_array,
					struct alphaAndA_Struct *alphaAndA, mpz_t *codewords, mpz_t c)
{
	struct Fq_poly *secretPoly;
	struct eccPoint *A_check, *B_check, *alpha;
	struct eccPoint *topHalf, *bottomHalf;

	mpz_t cShares2Check, cShares2CheckAbs;
	int *delta_i = (int*) calloc(stat_SecParam, sizeof(int*));
	int i, alphaCheck = 0, AB_check = 0, finalDecision = 0;



	A_check = (struct eccPoint*) calloc(1, sizeof(struct eccPoint));
	B_check = (struct eccPoint*) calloc(1, sizeof(struct eccPoint));


	alpha = windowedScalarPoint(alphaAndA -> a, g_0, params);
	alphaCheck = eccPointsEqual(alpha, alphaAndA -> alpha);


	for(i = 0; i < stat_SecParam; i ++)
	{
		delta_i[i] = i + 1;
	}


	if(2 != stat_SecParam)
	{
		secretPoly = getPolyFromCodewords(codewords, delta_i, stat_SecParam / 2 + 1, params -> n);
		finalDecision = testSecretScheme(secretPoly, c, params -> n, (stat_SecParam / 2) + 1, stat_SecParam);
	}
	else
	{
		mpz_init(cShares2Check);
		mpz_init(cShares2CheckAbs);

		mpz_sub(cShares2Check, codewords[0], codewords[1]);
		mpz_abs(cShares2CheckAbs, cShares2Check);

		finalDecision = mpz_cmp(c, cShares2CheckAbs);
	}


	for(i = 0; i < stat_SecParam; i ++)
	{
		topHalf = windowedScalarPoint(Z_array[i], g_0, params);
		bottomHalf = windowedScalarPoint(codewords[i], h_0_List[i], params);
		A_check = invertPoint(bottomHalf, params);
		groupOp_PlusEqual(A_check, topHalf, params);
		
		clearECC_Point(topHalf);
		clearECC_Point(bottomHalf);


		topHalf = windowedScalarPoint(Z_array[i], g_1, params);
		bottomHalf = windowedScalarPoint(codewords[i], h_1_List[i], params);
		B_check = invertPoint(bottomHalf, params);
		groupOp_PlusEqual(B_check, topHalf, params);
		
		clearECC_Point(topHalf);
		clearECC_Point(bottomHalf);

		AB_check |= eccPointsEqual(A_array[i], A_check);
		AB_check |= eccPointsEqual(B_array[i], B_check);

		clearECC_Point(A_check);
		clearECC_Point(B_check);
	}

	finalDecision |= AB_check;
	finalDecision |= alphaCheck;

	return finalDecision;
}