<blockquote>
<p>So I was thinking I just had to put the private key derived from L2pt3eVopnxfBBvMwrJV2saZeAyQfF77UQSH5WGj5q9LBS6WWBmN instead of &quot;dat_test_private_key&quot;
Blockquote</p>
</blockquote>
<p>Are you trying to hash the private key and use it as the
secret?<br />
You could try something like this instead:</p>
<pre><code>secret = int(derived_private_key_hex, 16)
</code></pre>

CC BY-SA 4.0
2023-09-13T11:00:34.597Z
2023-09-13T11:00:34.597Z
leslie
<p>Suppose I have a Wif private key from Electrum 4.0.9:</p>
<p>L2pt3eVopnxfBBvMwrJV2saZeAyQfF77UQSH5WGj5q9LBS6WWBmN ( this one or the other generated from the seed is non used of course )</p>
<p>with a corresponding public key:</p>
<p>14k8mYFC1LBWiBN8WSxpJN48jQYX1FZ6kz</p>
<p>I am using the code from the book &quot;programming bitcoin&quot; and the way we create private key is by converting the bits of a secret phrase like this:</p>
<pre><code>secret = little_endian_to_int(hash256(b'dat_test_private_key'))
</code></pre>
<p>So I was thinking I just had to put the private key derived from L2pt3eVopnxfBBvMwrJV2saZeAyQfF77UQSH5WGj5q9LBS6WWBmN instead of &quot;dat_test_private_key&quot;</p>
<p>then we do more step to get our private key here:</p>
<blockquote>
<p><a href="https://github.com/jimmysong/programmingbitcoin/blob/master/code-ch13/ecc.py" rel="nofollow noreferrer">https://github.com/jimmysong/programmingbitcoin/blob/master/code-ch13/ecc.py</a></p>
</blockquote>
<p>Then to get our public key:</p>
<blockquote>
<p>public_key = print(private_key.point.address(testnet=False))</p>
</blockquote>
<p>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</p>

CC BY-SA 4.0
2021-03-31T23:56:19.350Z
What do you mean by "original bits"?
Pieter Wuille
CC BY-SA 4.0
2021-04-01T00:40:52.987Z
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
CC BY-SA 4.0
2021-04-01T01:00:31.580Z
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.
Pieter Wuille
<private-key><electrum><public-key><wallet-import-format><programming-bitcoin-book>
Retrieving a WIF bits private key
Saxtheowl
# Retrieving a WIF bits private key

(Asked by: username_0 on 2021-03-31)

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:
14k8mYFC1LBWiBN8WSxpJN48jQYX1FZ6kz
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:

https://github.com/jimmysong/programmingbitcoin/blob/master/code-ch13/ecc.py

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

**Tags:** private-key, electrum, public-key, wallet-import-format, programming-bitcoin-book

> **Comments:**
> **username_1**: What do you mean by "original bits"?  
> **username_0**: 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  
> **username_1**: 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.  

---

## 1 answers

### Answer by username_2 on 2023-09-13. Score: 0

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

Are you trying to hash the private key and use it as the
secret?
You could try something like this instead:
secret = int(derived_private_key_hex, 16)


---

