def test_sign_to_contract_ssa() -> None: m = sha256(b"to be signed").digest() c = sha256(b"to be committed").digest() prvkey, pub = ssa.gen_keys() ssa_sig, ssa_receipt = ecssa_commit_sign(c, m, prvkey) ssa._assert_as_valid(m, pub, ssa_sig, ec, sha256) assert verify_commit(c, ssa_receipt) k = 1 + secrets.randbelow(ec.n - 1) ssa_sig, ssa_receipt = ecssa_commit_sign(c, m, prvkey, k) ssa._assert_as_valid(m, pub, ssa_sig, ec, sha256) assert verify_commit(c, ssa_receipt)
def test_signtocontract(self): prv = 0x1 pub = mult(prv) m = b"to be signed" c = b"to be committed" dsa_sig, dsa_receipt = ecdsa_commit_sign(c, m, prv, None) self.assertIsNone(dsa._verify(m, pub, dsa_sig, ec, sha256)) self.assertTrue(verify_commit(c, dsa_receipt)) # 32 bytes message for ECSSA m = sha256(m).digest() ssa_sig, ssa_receipt = ecssa_commit_sign(c, m, prv, None) self.assertIsNone(ssa._verify(m, pub, ssa_sig, ec, sha256)) self.assertTrue(verify_commit(c, ssa_receipt))
def test_signtocontract(): m = b"to be signed" c = b"to be committed" prv, pub = dsa.gen_keys() dsa_sig, dsa_receipt = ecdsa_commit_sign(c, m, prv, None) dsa.assert_as_valid(m, pub, dsa_sig, ec, sha256) assert verify_commit(c, dsa_receipt) # 32 bytes message for ECSSA m = sha256(m).digest() prv, pub = ssa.gen_keys() ssa_sig, ssa_receipt = ecssa_commit_sign(c, m, prv, None) ssa.assert_as_valid(m, pub, ssa_sig, ec, sha256) assert verify_commit(c, ssa_receipt)
def test_signtocontract(self): prv = 0x1 pub = mult(ec, prv, ec.G) m = "to be signed".encode() c = "to be committed".encode() dsa_sig, dsa_receipt = ecdsa_commit_sign(c, ec, hf, m, prv, None) self.assertTrue(dsa.verify(ec, hf, m, pub, dsa_sig)) self.assertTrue(verify_commit(c, ec, hf, dsa_receipt)) # 32 bytes message for ECSSA m = hf(m).digest() ssa_sig, ssa_receipt = ecssa_commit_sign(c, ec, hf, m, prv, None) self.assertTrue(ssa.verify(ec, hf, m, pub, ssa_sig)) self.assertTrue(verify_commit(c, ec, hf, ssa_receipt))