Example #1
0
 def get_xkeys(self, seed, t, passphrase, derivation):
     assert is_any_2fa_seed_type(t)
     xtype = 'standard' if t == '2fa' else 'p2wsh'
     bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
     xprv, xpub = bip32_root(bip32_seed, xtype)
     xprv, xpub = bip32_private_derivation(xprv, "m/", derivation)
     return xprv, xpub
Example #2
0
 def get_xkeys(self, seed, t, passphrase, derivation):
     assert is_any_2fa_seed_type(t)
     xtype = 'standard' if t == '2fa' else 'p2wsh'
     bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
     xprv, xpub = bip32_root(bip32_seed, xtype)
     xprv, xpub = bip32_private_derivation(xprv, "m/", derivation)
     return xprv, xpub
Example #3
0
    def _do_test_bip32(self, seed, sequence):
        xprv, xpub = bip32_root(bfh(seed), 'standard')
        self.assertEqual("m/", sequence[0:2])
        path = 'm'
        sequence = sequence[2:]
        for n in sequence.split('/'):
            child_path = path + '/' + n
            if n[-1] != "'":
                xpub2 = bip32_public_derivation(xpub, path, child_path)
            xprv, xpub = bip32_private_derivation(xprv, path, child_path)
            if n[-1] != "'":
                self.assertEqual(xpub, xpub2)
            path = child_path

        return xpub, xprv
Example #4
0
    def _do_test_bip32(self, seed, sequence):
        xprv, xpub = bip32_root(bfh(seed), 'standard')
        self.assertEqual("m/", sequence[0:2])
        path = 'm'
        sequence = sequence[2:]
        for n in sequence.split('/'):
            child_path = path + '/' + n
            if n[-1] != "'":
                xpub2 = bip32_public_derivation(xpub, path, child_path)
            xprv, xpub = bip32_private_derivation(xprv, path, child_path)
            if n[-1] != "'":
                self.assertEqual(xpub, xpub2)
            path = child_path

        return xpub, xprv
Example #5
0
 def get_xkeys(self, seed, passphrase, derivation):
     bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
     xprv, xpub = bip32_root(bip32_seed, 'standard')
     xprv, xpub = bip32_private_derivation(xprv, "m/", derivation)
     return xprv, xpub
Example #6
0
 def get_xkeys(self, seed, passphrase, derivation):
     bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
     xprv, xpub = bip32_root(bip32_seed, 'standard')
     xprv, xpub = bip32_private_derivation(xprv, "m/", derivation)
     return xprv, xpub
Example #7
0
if bip32.is_bip32_derivation( derivation_path ):
	if bip32.is_xpub(master_key):
		if args.output_xprv:
				sys.exit( "Cannot derive extended private key from extended public key\n" )
		if derivation_path == "m/":
			print( master_key )
		else:
			try:
				xpub = bip32.bip32_public_derivation( master_key, "m/", derivation_path )
				sys.stderr.write( "Derivation Path: {}\n".format( derivation_path ) )
			except BaseException:
				sys.exit( "Invalid derivation path. Private derivation is not possible with extended public keys.\n" )
			else:
				print( xpub )
	elif bip32.is_xprv( master_key ):
		try:
			xprv,xpub = bip32.bip32_private_derivation( master_key,"m/", derivation_path )    
			sys.stderr.write( "Derivation Path: {}\n".format( derivation_path ) )
		except BaseException:
			sys.stderr.write( "Invalid derivation path\n" )
		else:
			if args.output_xprv:
				print( xprv )
			else:
				print( xpub )
	else:
		sys.exit( "Invalid Master Key\n" )
else:
	print( "Incorrect derivation path" )