def btc( seed = None ):
'''Generate BTC address and key from seed'''
if not seed: return 32
private_key = b'\x80' + seed + b'\x01'
private_key += _sha256( _sha256( private_key ))[ :4 ]
public_key_uncomp = bytes( SigningKey. from_string( seed, curve = SECP256k1 ). get_verifying_key(). to_string() )
public_key = b'\x03' if public_key_uncomp[ -1 ] & 1 else b'\x02'
public_key += public_key_uncomp[ :32 ]
address = b'\x00' + _ripemd160( _sha256( public_key ))
address += _sha256( _sha256( address ))[ :4 ]
result = { 'key': _b58( private_key ), 'address': _b58( address )}
result[ None ] = result[ 'address' ]
return result
# xmr
评论列表
文章目录