class BitcoinKeypairTest(unittest.TestCase): reference = _reference_info def setUp(self): self.keypair = BitcoinKeypair(self.reference['hex_private_key']) def tearDown(self): pass def test_hex_private_key(self): self.assertEqual( self.keypair.private_key(), self.reference['hex_private_key']) def test_wif_private_key(self): self.assertEqual( self.keypair.wif_pk(), self.reference['wif_private_key']) def test_address(self): self.assertEqual( self.keypair.address(), self.reference['address']) def test_hex_hash160(self): self.assertEqual(self.keypair.hash160(), self.reference['hex_hash160']) def test_public_key(self): self.assertEqual( self.keypair.public_key(), self.reference['hex_public_key'])
class BitcoinKeypairTest(unittest.TestCase): reference = _reference_info def setUp(self): self.keypair = BitcoinKeypair(self.reference['hex_private_key']) def tearDown(self): pass def test_hex_private_key(self): self.assertEqual(self.keypair.private_key(), self.reference['hex_private_key']) def test_wif_private_key(self): self.assertEqual(self.keypair.wif_pk(), self.reference['wif_private_key']) def test_address(self): self.assertEqual(self.keypair.address(), self.reference['address']) def test_hex_hash160(self): self.assertEqual(self.keypair.hash160(), self.reference['hex_hash160']) def test_public_key(self): self.assertEqual(self.keypair.public_key(), self.reference['hex_public_key'])
def main(addr, *primes): addrs = {} prod = 1 for p in primes: if int(p) >= 1 << 256: raise CrackException("Factor too large: %s" % p) prod *= int(p) if prod >= 1 << 512: raise CrackException( "Superfluous factors or incorrect factorization detected!") i = 1 while i < 1 << len(primes): x = 1 for j in range(len(primes)): if i & 1 << j: x *= int(primes[j]) if x < 1 << 256 and prod / x < 1 << 256: if x not in addrs: addrs[x] = BitcoinKeypair(x).address() if addr == addrs[x]: return "Found Bitcoin private key: %064X" % x i += 1 raise CrackException("No keys found, check your factors!")
class RandomBitcoinKeypairsTest(unittest.TestCase): def setUp(self): self.keypair = BitcoinKeypair() self.brainwallet_keypair = BitcoinKeypair.from_passphrase() def tearDown(self): pass def test_keypair(self): # self.assertTrue(is_256bit_hex_string(self.keypair.private_key())) # self.assertTrue(is_wif_pk(self.keypair.wif_pk())) self.assertTrue(is_b58check_address(self.keypair.address())) def test_brainwallet_keypair(self): self.assertTrue(len(self.brainwallet_keypair.passphrase().split()) > 1)
def setUp(self): self.keypair = BitcoinKeypair() self.brainwallet_keypair = BitcoinKeypair.from_passphrase()
def setUp(self): BitcoinKeypairTest.setUp(self) self.keypair = BitcoinKeypair.from_private_key( self.reference['wif_private_key'])
def test_random_passphrase_length(self): random_keypair = BitcoinKeypair.from_passphrase() self.assertTrue(len(random_keypair.passphrase().split()) > 1)
def setUp(self): BitcoinKeypairTest.setUp(self) self.keypair = BitcoinKeypair.from_passphrase( self.reference['passphrase'])
def setUp(self): self.keypair = BitcoinKeypair(self.reference['hex_private_key'])