Basically, I followed the instructions here. How to generate mycelial addresses from the 12 words in python
So my code is similar:
from bip32utils import BIP32Key
from bip32utils import BIP32_HARDEN
from bip32utils import Base58
import os, bip39
strength_bits = 128
entropy = os.urandom (strength_bits // 8)
wallet_generator = bip39.Mnemonic (& # 39; english & # 39;)
mnemonic = wallet_generator.to_mnemonic (entropy)
affirm wallet_generator.to_entropy (mnemotécnico) == entropy # see, bijective!
# Or specify the mnemonic directly if you prefer:
mnemonic = & # 39; report report film exile buyer drum poverty supreme gym oppose float elegant & # 39;
password phrase = & # 39; test & # 39;
seed = bip39.Mnemonic.to_seed (mnemonic, passphrase = passphrase)
key = BIP32Key.fromEntropy (seed)
account_number = 0
i = 0
print "Address:" + key.ChildKey (44 + BIP32_HARDEN)
.ChildKey (0 + BIP32_HARDEN)
.ChildKey (account number + BIP32_HARDEN)
.ChildKey (0)
.ChildKey (i)
.Address()
And I verified it using https://iancoleman.io/bip39/#english that the generated address is in fact the first address that this web page also generated. However, I also want to obtain public and private key pairs using this same library. Originally I tried
Print "Public key:" + Base58.check_encode (key.ChildKey (44 + BIP32_HARDEN)
.ChildKey (0 + BIP32_HARDEN)
.ChildKey (account number + BIP32_HARDEN)
.ChildKey (0)
.ChildKey (i)
Public key ()
Print "Private key:" + Base58.check_encode (key.ChildKey (44 + BIP32_HARDEN)
.ChildKey (0 + BIP32_HARDEN)
.ChildKey (account number + BIP32_HARDEN)
.ChildKey (0)
.ChildKey (i)
.Private key ()
However, the output of these two calls are do not the same as those provided by the previous website for the same address.
So, my question is: what is the correct way for me to generate public and private key pairs?
Edition: to clarify, for the exact mnemonic and the passphrase above, the website that I am using as a reference tells me that the first address and the pair of keys must be:
While the output of the previous python code is:
Address: 1K6WQtD7bLQ5nQ14GyBV33mBWSbkiRKhQs
Public key: 62Yi9HBYYagf8CY1Ve2fquHKjBqAA7GFjGUUtkUHbkP5PHzv3W
Private key: EGHMsAp7nY7Jo9F589zCU227KBLTDhiwRq5vYVvRVZxJNPJn4
So the address matches, but not the pair of keys.