示例#1
0
def test_GetGroupOrderFromHex(test_data_dir):

    # Generate a Random EC Point with default NID ==> NID_secp256k1
    ecPoint_value = PyECPoint.GenerateRandomEC(0, hex, True )

    # Check if the point is on the curve with the supplied NID default NID ==> NID_secp256k1
    assert PyECPoint.CheckOnCurve(ecPoint_value, 0, hex ), "Test failed"

    # EC Point Generator with the supplied curve ID
    generator_Point = PyECPoint.GetGenerator(ecPoint_value, nid_Id, hex, True)

    # Reading a Random generated EC Point with default NID ==> NID_secp256k1 from file
    with open(test_data_dir/"testData_GetGroupDegree", "r") as getGrpDegree_txt: #Test data are generated from https://svn.python.org/projects/external/openssl-0.9.8a/crypto/ec/ec_curve.c
        for x in getGrpDegree_txt:

            # Reading the line of the file as string and splitting into list
            nidID_Degree_Value = x.split(",")

            #EC Point Group Degree with supplied curve
            grpDegreeHex = PyECPoint.GetGroupDegree(generator_Point, int(nidID_Degree_Value[0]), hex)

            # Verifying the actual value with the expected value.
            assert grpDegreeHex == int(nidID_Degree_Value[1]), "Test failed"

            #EC Point Group Order with supplied curve
            actual_value = PyECPoint.GetGroupOrder(generator_Point, int(nidID_Degree_Value[0]), hex)
            assert actual_value == nidID_Degree_Value[2].rstrip("\n"), "Test failed"
示例#2
0
 def GetOrder(self):
     order = PyECPoint.GetGroupOrder(self.value, self.nid, self.isDec)
     return order