Skip to content

Commit

Permalink
[BrainKeyScript] Define prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Jan 20, 2016
1 parent 50d9458 commit ff0de8d
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions scripts/genkeys/master-child-keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import argparse
import csv

def main() :
prefix = "BTS"


def main() :
parser = argparse.ArgumentParser(description='Generate CSV table with brain key, pub key and private key')
parser.add_argument('--number', type=int, help='Number of brain keys to generate')
parser.add_argument('--filename', type=str, help='filename to store CSV file in')
Expand All @@ -21,22 +24,22 @@ def main() :
while True :
pw = getpass.getpass('Passphrase: ')
pwck = getpass.getpass('Retype passphrase: ')
if(pw == pwck) :
if(pw == pwck) :
break
else :
print("Given Passphrases do not match!")

t = PrettyTable(["wif","pub","sequence"])
t = PrettyTable(["wif", "pub", "sequence"])
b = BrainKey()
for i in range(0,args.number) :
for i in range(0, args.number) :
wif = b.get_private()
pub = b.get_private().pubkey
if args.encrypt : # (optionally) encrypt paper wallet
try :
wif = format(bip38.encrypt(wif,pw),"encwif")
pub = format(b.get_private().pubkey, prefix)
if args.encrypt : # (optionally) encrypt paper wallet
try :
wif = format(bip38.encrypt(wif, pw), "encwif")
except :
raise Exception("Error encoding the privkey for pubkey %s. Already encrypted?" % pub)
assert format(b.get_private(),'wif') == format(bip38.decrypt(wif,pw),'wif')
assert format(b.get_private(), 'wif') == format(bip38.decrypt(wif, pw), 'wif')

t.add_row([wif, pub, b.sequence])
b.next_sequence()
Expand All @@ -45,7 +48,7 @@ def main() :
print("\n\n\t%s\n\n" % b.get_brainkey())
print(t.get_string())

if args.filename :
if args.filename :
with open(args.filename, 'w') as file:
file.write("# This is your (unencrypted) Brainkey. Make sure to store it savely:\n")
file.write("#\n#\t%s\n#\n" % b.get_brainkey())
Expand Down

0 comments on commit ff0de8d

Please sign in to comment.