def verifyCorrectness(self, groupId, hiddenEvals, hiddenPolys): group = self.groups[groupId] ordinalList = group.allOrdinals() #ordinalList = [] #for i in group.ordinalList : # ordinalList.append( i[0] ) #ordinalList.append(group.ordinal) for Ordinal in ordinalList: curvepoint = [] for ofOrdinal, pubPoly in hiddenEvals[Ordinal].items(): pubPoly = Player.getECPoint(pubPoly) points = pubPoly.GetAffineCoOrdinates() curvepoint.append((str(ofOrdinal), points[0], points[1])) interpolator = Nakasendo.LGECInterpolator(xfx=curvepoint, modulo=self.modulo, decimal=False) zero_interpolator = interpolator(xValue='0') if (str(zero_interpolator) != str(hiddenPolys[Ordinal][0])): msg = ("Verification of Correctness " + str(Ordinal) + " is failed.") raise PlayerError(msg)
def test_LGECInterpolatorFull(): # modulo = PyBigNumbers.GenerateRandPrimeHex(1000) modulo = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141" xValue = Nakasendo.BigNum().value listTupleObj = [] hex_value = False # Generating Random EC for x in range(10, 50): # Generate a Random EC Point with default NID ==> NID_secp256k1 hexValue = Nakasendo.ECPoint() print(hexValue.value) # Check if the point is on the curve with the supplied NID default NID ==> NID_secp256k1 assert hexValue.IsPointOnCurve(), "Test failed" x_Axis, y_axis = hexValue.GetAffineCoOrdinates() # EC Point GetAffineCoOrdinates_GFp with default NID => NID_secp256k1 listTupleObj.append((str(x), x_Axis, y_axis)) lgInterpolatorX = Nakasendo.LGECInterpolator(listTupleObj, modulo, hex_value) lgInterpolatorX = lgInterpolatorX(xValue) assert type(lgInterpolatorX) == Nakasendo.ECPoint, "Test failed"
G = ecdsa.SECP256k1.generator print (G) #create a list of ECPoints ECPoints = [] for i in range (1,5): pt = Nakasendo.ECPoint() coords = pt.GetAffineCoOrdinates() ECPoints.append((str(i),coords[0],coords[1] )) #create interpolator modulo='FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141' print (ECPoints) lgECInterpolator = Nakasendo.LGECInterpolator( ECPoints, modulo,False ) print ("lgInterpolator = ", lgECInterpolator ) xValue = 0; valueECPoint = lgECInterpolator( str(xValue)) print ("Full LG EC Interpolation evaluation for xValue=%s is %s" % (xValue, valueECPoint.GetAffineCoOrdinates() ) ) xValue = 1; valueECPoint = lgECInterpolator( str(xValue)) print ("Full LG EC Interpolation evaluation for xValue=%s is %s" % (xValue, valueECPoint.GetAffineCoOrdinates() ) ) print ("Hiding the BigNumber %s by multiplying it by the CurveGenerator Point %s" % ( bigNumA, GENPOINTA.GetAffineCoOrdinates())) hiddenVal = Nakasendo.MultiplyByGenerator(bigNumA) print(hiddenVal)
for i in range(len(Players)): #for i in subGroupPlayersIndex: label_j = Players[i].getOrdinal() k_j = vect_v[i] w_j = vect_w[i] w_j_points = w_j.GetAffineCoOrdinates() xfx_v.append((int(label_j), k_j.value)) xfx_w.append((str(label_j), w_j_points[0], w_j_points[1])) v_interpolator = Nakasendo.LGInterpolator(xfx_v, modulo_n.value, decimal=False) vZeroVal = v_interpolator('0') w_interpolator = Nakasendo.LGECInterpolator(xfx_w, modulo_n.value, decimal=False) wZeroVal = w_interpolator('0') vZeroValInv = vZeroVal.inverse() interpolated_r = wZeroVal.multipleScalar(vZeroValInv) if (interpolated_r.IsPointOnCurve() is not True): print("point not on curve") exit(1) interpolated_r_points = interpolated_r.GetAffineCoOrdinates() #print('interpolated_r (%s,%s)' % ( interpolated_r_points[0],interpolated_r_points[1]))