def reconstitute_interface(args): p,k,first,second,manual_input = [],999,True,True,False # Gather up a list of n-pieces, with some moderately complex UI logic # to help the user along # Grammar: python main.py --reconstitute [piece 1] ... [piece n] [format] if len(args) == 0: while len(p) < k: if len(args) == 0: # The first time that we have information on k AND it's the user input # ting manually, print the "$1 total pieces required, $2 to go" string if len(p) > 0 and second: k = (bitcoin.trial_and_error_decode(p[0]) / (256 ** 37)) % 256 - 147 print "%d total pieces required, %d to go" % (k, k-len(p)) second = False if first: print "Enter the key parts:" v = raw_input("> ") manual_input = True else: v = args.pop(0) p.append(v) if first and manual_input: first = False # We have to do this at the end of the first round since the k # parameter might actually be 1, in which case we should end the # while loop after this immediately k = (bitcoin.trial_and_error_decode(p[0]) / (256 ** 37)) % 256 - 147 # Too many pieces inputted, don't interpret an extra piece as the base # parameter while len(args) > 0 and get_format(args[0]) == -1: args.pop(0) if len(args) == 0: args.append(raw_input( "Please enter format: integer(10), hexadecimal(16) " + \ "or base58check wallet import format (58): ")) print bitcoin.reconstitute(p,get_format(args[0]))
def reconstitute_interface(args): p, k, first, second, manual_input = [], 999, True, True, False # Gather up a list of n-pieces, with some moderately complex UI logic # to help the user along # Grammar: python main.py --reconstitute [piece 1] ... [piece n] [format] if len(args) == 0: while len(p) < k: if len(args) == 0: # The first time that we have information on k AND it's the user input # ting manually, print the "$1 total pieces required, $2 to go" string if len(p) > 0 and second: k = (bitcoin.trial_and_error_decode(p[0]) / (256**37)) % 256 - 147 print "%d total pieces required, %d to go" % (k, k - len(p)) second = False if first: print "Enter the key parts:" v = raw_input("> ") manual_input = True else: v = args.pop(0) p.append(v) if first and manual_input: first = False # We have to do this at the end of the first round since the k # parameter might actually be 1, in which case we should end the # while loop after this immediately k = (bitcoin.trial_and_error_decode(p[0]) / (256**37)) % 256 - 147 # Too many pieces inputted, don't interpret an extra piece as the base # parameter while len(args) > 0 and get_format(args[0]) == -1: args.pop(0) if len(args) == 0: args.append(raw_input( "Please enter format: integer(10), hexadecimal(16) " + \ "or base58check wallet import format (58): ")) print bitcoin.reconstitute(p, get_format(args[0]))
def split_reconstitute_tests_with_galois(self): gal = mathfuncs.Galois seed = 'horse rabbit dog' pk16 = b.makepk(seed,16) pk58 = b.makepk(seed,58) e16 = b.split(pk16,3,7,gal) e58 = b.split(pk58,3,7,gal) self.assertEqual(b.reconstitute([e16[2],e16[5],e16[4]],16),pk16) self.assertEqual(b.reconstitute([e16[1],e16[3],e16[6]],58),pk58) self.assertEqual(b.reconstitute([e58[3],e58[4],e58[0]],16),pk16) self.assertEqual(b.reconstitute([e58[0],e58[2],e58[4],e58[6]],58),pk58)
def split_reconstitute_tests_with_modularint(self): mi = mathfuncs.ModularInt seed = 'horse rabbit dog' pk16 = b.makepk(seed,16) pk58 = b.makepk(seed,58) e16 = b.split(pk16,3,7,mi) e58 = b.split(pk58,3,7,mi) self.assertEqual(b.reconstitute([e16[2],e16[5],e16[4]],16),pk16) self.assertEqual(b.reconstitute([e16[1],e16[3],e16[6]],58),pk58) self.assertEqual(b.reconstitute([e58[3],e58[4],e58[0]],16),pk16) self.assertEqual(b.reconstitute([e58[0],e58[2],e58[4],e58[6]],58),pk58)
def split_reconstitute_tests_with_galois(self): gal = mathfuncs.Galois seed = 'horse rabbit dog' pk16 = b.makepk(seed, 16) pk58 = b.makepk(seed, 58) e16 = b.split(pk16, 3, 7, gal) e58 = b.split(pk58, 3, 7, gal) self.assertEqual(b.reconstitute([e16[2], e16[5], e16[4]], 16), pk16) self.assertEqual(b.reconstitute([e16[1], e16[3], e16[6]], 58), pk58) self.assertEqual(b.reconstitute([e58[3], e58[4], e58[0]], 16), pk16) self.assertEqual(b.reconstitute([e58[0], e58[2], e58[4], e58[6]], 58), pk58)
def split_reconstitute_tests_with_modularint(self): mi = mathfuncs.ModularInt seed = 'horse rabbit dog' pk16 = b.makepk(seed, 16) pk58 = b.makepk(seed, 58) e16 = b.split(pk16, 3, 7, mi) e58 = b.split(pk58, 3, 7, mi) self.assertEqual(b.reconstitute([e16[2], e16[5], e16[4]], 16), pk16) self.assertEqual(b.reconstitute([e16[1], e16[3], e16[6]], 58), pk58) self.assertEqual(b.reconstitute([e58[3], e58[4], e58[0]], 16), pk16) self.assertEqual(b.reconstitute([e58[0], e58[2], e58[4], e58[6]], 58), pk58)