Example #1
0
def validate_public_key(qk):
    '''Check whether public key qk is valid'''
    bits, q = qk
    x, y = q
    bits, cn, n, cp, cq, g = get_curve(bits)
    return q and 0 < x < cn and 0 < y < cn and \
        element(q, cp, cq, cn) and (mulp(cp, cq, cn, q, n) == None)
Example #2
0
def validate_public_key(qk):
    '''Check whether public key qk is valid'''
    bits, q = qk
    x, y = q
    bits, cn, n, cp, cq, g = get_curve(bits)
    return q and 0 < x < cn and 0 < y < cn and \
        element(q, cp, cq, cn) and (mulp(cp, cq, cn, q, n) == None)
Example #3
0
 def check_public_key(self, other_key):
     """
     Check the other party's public key to make sure it's valid.
     """
     if (
         other_key is not None
         and other_key[0] >= 0
         and other_key[0] <= self.params["p"] - 1
         and other_key[1] >= 0
         and other_key[1] <= self.params["p"] - 1
         and ec.element(other_key, self.params["a"], self.params["b"], self.params["p"])
     ):
         return True
     return False