in the excellent reply to this question: How to generate Bitcoin keys/addresses from a seed in Python? there is a discussion of 3 ways to generate a BIP32Key
from mnemonics or extended private keys. but how can I generate one from a private key? I have the hex version of one
there doesn't seem to be a method to do this
BIP32Key
encapsulates an extended key that contains various components (private/public key, chain code, version, depth, fingerprint, index, see here) that have to be specified during import (either individually via constructor or serialized viafromExtendedKey()
). So a private key alone is not enough, even for the master key at least the chain code is needed in addition to the private key. – Handgun.fromEntropy
method produces a digest of a hash of the BIP39 and takes the left 32 bytes for the secret and the rest as a chain code. so if I read you right, the private key would be thesecret
fed toBIP32Key()
and the chain code could be anything? if I know that the pk is for an ethereum address, can I deduce the chain code? – PlanulaBIP32Key
object from it (withfromEntropy()
). But if you only have the private key (and both your original comment and this question talk about a private key and not a seed), this is not possible because the related chain code is missing (and you need the seed to derive the chain code). – HandgunBIP32Key
object if you are not BIP32 compliant, and the latter is the case for an arbitrary chain code (according to BIP32 a private key is related to a specific chain code via the seed). Another point is the lack of entropy. I.e. technicallyBIP32Key
may allow this, but it is not intended for this, and therefore it is not advisable. – Handgun