January 2019
Beginner to intermediate
372 pages
11h 17m
English
We will implement the generation of a key pair and store the keys in plaintext, that is, without applying any encryption. Although wallets can store multiple keys, which can also be generated by a seed phrase, we will use a single key per wallet in this application to keep the wallet implementation as simple as possible. The following method will read the private key and convert the hexadecimal to byte representation:
PRIV_KEY_LOC = 'private_key'
from ecdsa import SigningKey
def generate_private_key():
sk = SigningKey.generate(curve=SECP256k1)
with open(PRIV_KEY_LOC, 'wt') as file_obj:
file_obj.write(binascii.b2a_hex(sk.to_string()).decode())
Wallet is initialized by creating a private key using the ecdsa package. The SigningKey ...
Read now
Unlock full access