<p>I know this is an old post.
But according to documentation (<a href="https://en.bitcoin.it/wiki/Wallet_import_format" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Wallet_import_format</a>)</p>

<blockquote>
  <p>Add a 0x01 byte at the end if the private key will correspond to a
  compressed public key a compressed private key should have a 01 flag
  at the end... If it corresponded to a compressed public key, the WIF
  string will have started with K or L instead of 5 (or c instead of 9
  on testnet).</p>
</blockquote>

<p>Taking the key from the example on the site </p>

<blockquote>
  <p>5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ</p>
</blockquote>

<p>The key should be derived by decoding the key using Base58, removing the last 4 bytes (8 characters) corresponding to the checksum.</p>

<blockquote>
  <p>800c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d<strong>507a5b8d</strong></p>
</blockquote>

<p>For the compressed version add a 01 byte at the end</p>

<blockquote>
  <p>800c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d<strong>01</strong></p>
</blockquote>

<p>And re derive the double SHA256 hash for the checksum. Using Python (<a href="http://www.herongyang.com/Bitcoin/Block-Data-Calculate-Double-SHA256-with-Python.html" rel="nofollow noreferrer">http://www.herongyang.com/Bitcoin/Block-Data-Calculate-Double-SHA256-with-Python.html</a>) or (<a href="https://learnmeabitcoin.com/guide/checksum" rel="nofollow noreferrer">https://learnmeabitcoin.com/guide/checksum</a>) result is:</p>

<blockquote>
  <p><strong>a62019d2</strong>0340a1de1b5f254f07f2f6c96ad5165218459ab4f3c8f5a7c0e12183</p>
</blockquote>

<p>Take the first 4 bytes from the hash (<strong>a62019d2</strong>) and add it to the key after the 01 byte.</p>

<blockquote>
  <p>800c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d507a5b8d01<strong>a62019d2</strong></p>
</blockquote>

<p>Encode the result in Base58 and you should have the compressed key.</p>

<blockquote>
  <p>KwdMAjGmerYanjeui5SHS7JkmpZvVipYvB2LJGU1ZxJwYvP98617</p>
</blockquote>

<p>Notice the key begins with K. I was unable to confirm with any other info published on the internet.</p>

CC BY-SA 4.0
2020-04-14T16:32:45.413Z
2020-04-14T20:30:45.577Z
2020-04-14T20:30:45.577Z
MRGiacalone2005
<p>Ok I answered my own question. From: <a href="https://github.com/pointbiz/bitaddress.org/blob/master/src/bitcoinjs-lib.eckey.js#L186-L222" rel="nofollow">https://github.com/pointbiz/bitaddress.org/blob/master/src/bitcoinjs-lib.eckey.js#L186-L222</a></p>

<pre><code>bytes = Bitcoin.Base58.decode(compressed_or_uncompressed_private_key);
</code></pre>

<p>After some processing, this bytes-array can then be re-encoded into a compressed or uncompressed private key.</p>

CC BY-SA 3.0
2013-11-27T09:21:41.337Z
2013-11-27T09:21:41.337Z
vinhboy
<p>So I have a compressed private key. Is it possible to get the uncompressed version of it? If yes, how? Examples in Javascript would be much appreciated.</p>

<private-key>
How to uncompress a compressed private key?
vinhboy
# How to uncompress a compressed private key?

(Asked by: username_0 on 2013-11-25)

So I have a compressed private key. Is it possible to get the uncompressed version of it? If yes, how? Examples in Javascript would be much appreciated.

**Tags:** private-key


---

## 2 answers

### Answer by username_0 on 2013-11-27. Score: 3 | Accepted answer

Ok I answered my own question. From: <https://github.com/pointbiz/bitaddress.org/blob/master/src/bitcoinjs-lib.eckey.js#L186-L222>

```
bytes = Bitcoin.Base58.decode(compressed_or_uncompressed_private_key);

```

After some processing, this bytes-array can then be re-encoded into a compressed or uncompressed private key.


---

### Answer by username_1 on 2020-04-14. Score: 1

I know this is an old post.
But according to documentation (<https://en.bitcoin.it/wiki/Wallet_import_format>)

> Add a 0x01 byte at the end if the private key will correspond to a
> compressed public key a compressed private key should have a 01 flag
> at the end... If it corresponded to a compressed public key, the WIF
> string will have started with K or L instead of 5 (or c instead of 9
> on testnet).

Taking the key from the example on the site

> 5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ

The key should be derived by decoding the key using Base58, removing the last 4 bytes (8 characters) corresponding to the checksum.

> 800c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d**507a5b8d**

For the compressed version add a 01 byte at the end

> 800c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d**01**

And re derive the double SHA256 hash for the checksum. Using Python (<http://www.herongyang.com/Bitcoin/Block-Data-Calculate-Double-SHA256-with-Python.html>) or (<https://learnmeabitcoin.com/guide/checksum>) result is:

> **a62019d2**0340a1de1b5f254f07f2f6c96ad5165218459ab4f3c8f5a7c0e12183

Take the first 4 bytes from the hash (**a62019d2**) and add it to the key after the 01 byte.

> 800c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d507a5b8d01**a62019d2**

Encode the result in Base58 and you should have the compressed key.

> KwdMAjGmerYanjeui5SHS7JkmpZvVipYvB2LJGU1ZxJwYvP98617

Notice the key begins with K. I was unable to confirm with any other info published on the internet.


---

