Example #1
0
 def test_priv_addition_is_pub_addition(self):
     # adding private keys gives the same address as adding their public keys
     key1 = key.generate_priv()
     key2 = key.generate_priv()
     self.assertEquals(
         byte_util.base58_encode(key.priv_to_address(key1 + key2)),
         byte_util.base58_encode(
             key.address_from_pubkey(
                 key.encode_pub(key.priv_to_pub(key1) + key.priv_to_pub(key2)))))
Example #2
0
 def test_priv_addition_is_pub_addition(self):
     # adding private keys gives the same address as adding their public keys
     key1 = key.generate_priv()
     key2 = key.generate_priv()
     self.assertEquals(
         byte_util.base58_encode(key.priv_to_address(key1 + key2)),
         byte_util.base58_encode(
             key.address_from_pubkey(
                 key.encode_pub(
                     key.priv_to_pub(key1) + key.priv_to_pub(key2)))))
Example #3
0
def main():
    priv = key.generate_priv()
    priv_enc = key.encode_privkey(priv)
    priv_cmp_enc = key.encode_privkey_compressed(priv)
    pub = key.priv_to_pub(priv)
    addr = byte_util.base58_encode(key.pub_to_address(pub))
    addr_comp = byte_util.base58_encode(key.pub_to_address_compressed(pub))
    print 'Address: %s\nPrivate Key Encoded: %s\nAddress (compressed): %s\nPrivate Key Encoded (compressed): %s' % (addr, priv_enc, addr_comp, priv_cmp_enc)
Example #4
0
def main():
    priv = key.generate_priv()
    priv_enc = key.encode_privkey(priv)
    priv_cmp_enc = key.encode_privkey_compressed(priv)
    pub = key.priv_to_pub(priv)
    addr = byte_util.base58_encode(key.pub_to_address(pub))
    addr_comp = byte_util.base58_encode(key.pub_to_address_compressed(pub))
    print 'Address: %s\nPrivate Key Encoded: %s\nAddress (compressed): %s\nPrivate Key Encoded (compressed): %s' % (
        addr, priv_enc, addr_comp, priv_cmp_enc)
Example #5
0
    def test_decode_pub_compressed(self):
        pub = key.priv_to_pub(
            key.decode_privkey('5JnKZDMUAddiGgFjWiHNVrX5pxGcEJ1miscs2Xhy7f9BrGffrps'))
        self.assertEquals(key.decode_pub(key.encode_pub_compressed(pub)), pub)

        for _ in xrange(100):
            print _
            priv = key.generate_priv()
            pub = key.priv_to_pub(priv)
            self.assertEquals(key.decode_pub(key.encode_pub_compressed(pub)), pub)
Example #6
0
    def test_decode_pub_compressed(self):
        pub = key.priv_to_pub(
            key.decode_privkey(
                '5JnKZDMUAddiGgFjWiHNVrX5pxGcEJ1miscs2Xhy7f9BrGffrps'))
        self.assertEquals(key.decode_pub(key.encode_pub_compressed(pub)), pub)

        for _ in xrange(100):
            print _
            priv = key.generate_priv()
            pub = key.priv_to_pub(priv)
            self.assertEquals(key.decode_pub(key.encode_pub_compressed(pub)),
                              pub)
Example #7
0
def mine(g_num, work):
    num = 0
    while True:
        try:
            priv = key.generate_priv()
            pub = key.priv_to_pub(priv)
            addr = byte_util.base58_encode(key.pub_to_address(pub))
            addr_comp = byte_util.base58_encode(
                key.pub_to_address_compressed(pub))
            num += 1
            if num % INC == 0:
                with g_num.get_lock():
                    g_num.value += INC
                # if g_num.value > 10000:
                #     return
            if any(VANITY_RE.match(a) for a in [addr, addr_comp]):
                try:
                    priv_enc = key.encode_privkey(priv)
                except Exception, e:
                    priv_enc = repr(e)
                try:
                    priv_cmp_enc = key.encode_privkey_compressed(priv)
                except Exception, e:
                    priv_cmp_enc = repr(e)
                msg = '\nI found one!\nAddress: %s\nAddress (compressed): %s\nPrivate Key (raw): %r\nPrivate Key Encoded: %s\nPrivate Key Encoded (compressed): %s\n' % (
                    addr, addr_comp, priv, priv_enc, priv_cmp_enc)
                print msg[:-1]
                with open('found_keys', 'a') as found_keys:
                    found_keys.write(msg)

            for rec in work:
                pub_sum = pub + rec['public_key']
                addr = byte_util.base58_encode(key.pub_to_address(pub_sum))
                addr_comp = byte_util.base58_encode(
                    key.pub_to_address_compressed(pub_sum))
                if not any(
                        a.startswith(rec['pattern'])
                        for a in [addr, addr_comp]):
                    continue

                try:
                    priv_hex = hex(priv)[2:].rstrip('L').upper()
                except Exception, e:
                    priv_hex = repr(e)
                try:
                    priv_enc = key.encode_privkey(priv)
                except Exception, e:
                    priv_enc = repr(e)