Пример #1
0
    def _run_test(self, curve, x, message, H, k, expected_sig):
        ecdsa = ECDSA(curve.G, H, d=x)
        r, s = ecdsa.sign(message, k=k)
        sig = (int(r), int(s))

        self.assertEqual(sig, expected_sig)
        self.assertTrue(ecdsa.verify(message, sig))
Пример #2
0
    def test_k_derivation(self):
        ecdsa = ECDSA(P256.G)
        k = Bytes.random(32).int()
        msgA = b'my first message'
        msgB = b'uh oh, two messages?!'

        sigA = ecdsa.sign(msgA, k)
        sigB = ecdsa.sign(msgB, k)

        found_k = ecdsa.derive_k_from_sigs(msgA, sigA, msgB, sigB)
        self.assertEqual(found_k, k)

        d = ecdsa.d
        self.assertEqual(ecdsa.derive_x_from_k(msgA, found_k, sigA), d)