MCPcopy Index your code
hub / github.com/petertodd/python-bitcoinlib / test_sign

Method test_sign

bitcoin/tests/test_wallet.py:257–272  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

255 True)
256
257 def test_sign(self):
258 key = CBitcoinSecret('5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hS')
259 hash = b'\x00' * 32
260 sig = key.sign(hash)
261
262 # Check a valid signature
263 self.assertTrue(key.pub.verify(hash, sig))
264 self.assertTrue(IsLowDERSignature(sig))
265
266 # Check that invalid hash returns false
267 self.assertFalse(key.pub.verify(b'\xFF'*32, sig))
268
269 # Check that invalid signature returns false.
270 #
271 # Note the one-in-four-billion chance of a false positive :)
272 self.assertFalse(key.pub.verify(hash, sig[0:-4] + b'\x00\x00\x00\x00'))
273
274 def test_sign_invalid_hash(self):
275 key = CBitcoinSecret('5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hS')

Callers

nothing calls this directly

Calls 4

IsLowDERSignatureFunction · 0.90
CBitcoinSecretClass · 0.85
signMethod · 0.45
verifyMethod · 0.45

Tested by

no test coverage detected