Exemplo n.º 1
0
 def verify(self, h, sig, pub):
     while h > self.N:
         h >>= 1
     r = self.bytes2int(sig[:self.bytes])
     s = self.bytes2int(sig[self.bytes:])    
     if 0 < r < self.N and 0 < s < self.N:
         w = inv(s, self.N)
         u1 = (h * w) % self.N
         u2 = (r * w) % self.N
         x, y = muladdp(self.a, self.b, self.p, self.G, u1, pub, u2)
         return r % self.N == x % self.N
     return False
Exemplo n.º 2
0
 def verify(self, h, sig, pub):
     while h > self.N:
         h >>= 1
     r = self.bytes2int(sig[:self.bytes])
     s = self.bytes2int(sig[self.bytes:])
     if 0 < r < self.N and 0 < s < self.N:
         w = inv(s, self.N)
         u1 = (h * w) % self.N
         u2 = (r * w) % self.N
         x, y = muladdp(self.a, self.b, self.p, self.G, u1, pub, u2)
         return r % self.N == x % self.N
     return False
Exemplo n.º 3
0
def verify(h, sig, qk):
    '''Verify that 'sig' is a valid signature of h using public key qk'''
    bits, q = qk
    try:
        bits, cn, n, cp, cq, g = get_curve(bits)
    except KeyError:
        return False
    h = truncate(h, cn)
    r, s = sig
    if 0 < r < n and 0 < s < n:
        w = inv(s, n)
        u1 = (h * w) % n
        u2 = (r * w) % n
        x, y = muladdp(cp, cq, cn, g, u1, q, u2)
        return r % n == x % n
    return False
Exemplo n.º 4
0
def verify(h, sig, qk):
    '''Verify that 'sig' is a valid signature of h using public key qk'''
    bits, q = qk
    try:
        bits, cn, n, cp, cq, g = get_curve(bits)
    except KeyError:
        return False
    h = truncate(h, cn)
    r, s = sig
    if 0 < r < n and 0 < s < n:
        w = inv(s, n)
        u1 = (h * w) % n
        u2 = (r * w) % n
        x, y = muladdp(cp, cq, cn, g, u1, q, u2)
        return r % n == x % n
    return False