Exemplo n.º 1
0
    def testP192SignAndVerifyKFixe(self):
        A, B, p, G, n = tp3.P192()

        k = random.randint(1, n - 1)

        # cle prive alice
        a = random.randint(1, n - 1)

        # cle public alice
        Apub = tp3.double_and_add(A, B, p, G, a)

        m1, m2 = 11, 23

        t1, s1 = tp3.signP192(k, a, m1)
        t2, s2 = tp3.signP192(k, a, m2)

        kDeduce = (m1 - m2) * tp3.inverse(s1 - s2, n)
        tDeduce = tp3.double_and_add(A, B, p, G, k)[0]

        self.assertEquals(t1, tDeduce)

        privateKeyDeduce = (kDeduce * s1 - m1) * tp3.inverse(tDeduce, n) % n
        # <=> privateKeyDeduce = (m1*s2 - m2*s1) * tp3.inverse(tDeduce * (s1 - s2), n) % n

        self.assertEquals(a, privateKeyDeduce)
Exemplo n.º 2
0
    def testP192SignAndVerify(self):
        A, B, p, G, n = tp3.P192()

        k = random.randint(1, n - 1)

        # cle prive alice
        a = random.randint(1, n - 1)

        # cle public alice
        Apub = tp3.double_and_add(A, B, p, G, a)

        m = 11

        t, signe = tp3.signP192(k, a, m)

        self.assertTrue(tp3.verifyP192(t, signe, Apub, m))