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)
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)
def getwork(): url = GETWORK_URL data = requests.get(url).text headers = [ 'pattern', 'public_key_hex', 'network_byte', 'reward', 'comment' ] work = [] for line in data.split('\n'): if ';' not in line: continue fields = line.split(';') if ':' not in fields[0]: continue fields = fields[0].split(':') + fields[-1:] if len(fields) != len(headers): print 'fields do not match headers: %r' % (fields, ) rec = dict(zip(headers, fields)) if rec['pattern'][0] != '1': print 'pattern does not start with 1: %s' % (rec['pattern'], ) continue rec['reward'] = float(rec['reward']) rec['work_to_reward'] = pow(58, len(rec['pattern']) - 1) / rec['reward'] rec['public_key_enc'] = binascii.unhexlify(rec['public_key_hex']) rec['public_key'] = key.decode_pub(rec['public_key_enc']) work.append(rec) return work
def test_decode_pub_encode_pub_symmetric(self): pub = binascii.unhexlify( '04EAB82662C4A329F573E96801CCFCF9337446D2742EFDC5A6E8EA8F617AD0197B387DDFA' '56684EF2F4E2325F298F5F418ADCB00F560B75F4DEEAF90ABD5A3CEB0') self.assertEquals(key.encode_pub(key.decode_pub(pub)), pub)
def test_decode_pub_encode_pub_symmetric(self): pub = binascii.unhexlify('04EAB82662C4A329F573E96801CCFCF9337446D2742EFDC5A6E8EA8F617AD0197B387DDFA' '56684EF2F4E2325F298F5F418ADCB00F560B75F4DEEAF90ABD5A3CEB0') self.assertEquals(key.encode_pub(key.decode_pub(pub)), pub)