Suppose I have a Wif private key from Electrum 4.0.9:

L2pt3eVopnxfBBvMwrJV2saZeAyQfF77UQSH5WGj5q9LBS6WWBmN ( this one or the other generated from the seed is non used of course )

with a corresponding public key:


I am using the code from the book "programming bitcoin" and the way we create private key is by converting the bits of a secret phrase like this:

secret = little_endian_to_int(hash256(b'dat_test_private_key'))

So I was thinking I just had to put the private key derived from L2pt3eVopnxfBBvMwrJV2saZeAyQfF77UQSH5WGj5q9LBS6WWBmN instead of "dat_test_private_key"

then we do more step to get our private key here:


Then to get our public key:

public_key = print(private_key.point.address(testnet=False))

But no mater what I tried I dont have the same public key as electrum, so I guess I must be off something or they use a different WIF format or the way they derive public key

  • What do you mean by "original bits"? Mar 31 at 23:56
  • I have updated my post, but I guess I am gonna go for the bitcoin libraries and dont go too deep for my project, I have even had a reply from Jimmy song for my problem, but it hadnt fixed it
    – Saxtheowl
    Apr 1 at 0:40
  • There are tons of ways for converting passwords/phrases/seeds into keys. Presumably Electrum is using a very different one. That doesn't mean any is right or wrong. Apr 1 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.