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)
def split_interface(args): # Splits a key # Grammar: python main.py --split [privkey] [n] [k (1<=k<=n)] if len(args) == 0: args.append(bitcoin.trial_and_error_decode(raw_input( "Enter private key (any format): "))) if len(args) == 1: args.append(raw_input( "How many parts do you want to split your key into? (1-14): ")) if len(args) == 2: args.append(raw_input( "How many parts should be required to reconstitute your " + \ "key? (1-%d): " % int(args[1]))) v = bitcoin.split(args[0],int(args[2]),int(args[1])) print "Write down the key parts:" for i in v: print i
def split_interface(args): # Splits a key # Grammar: python main.py --split [privkey] [n] [k (1<=k<=n)] if len(args) == 0: args.append( bitcoin.trial_and_error_decode( raw_input("Enter private key (any format): "))) if len(args) == 1: args.append( raw_input( "How many parts do you want to split your key into? (1-14): ")) if len(args) == 2: args.append(raw_input( "How many parts should be required to reconstitute your " + \ "key? (1-%d): " % int(args[1]))) v = bitcoin.split(args[0], int(args[2]), int(args[1])) print "Write down the key parts:" for i in v: print i