Yes. A private key is just a number. Different "formats" are just different ways of representing the same number.
~~MZ~~
Compressed key is a form of Base58 Wallet Import Format. You shouldn't need to do any conversions.
Sorry for not posting correctly. I thought Bas58 Wallet Import Format is Uncompressed key as I saw just uncompressed private key in Bitcoin wiki. So is there any way to convert compressed to uncompressed format? And thanks for clarifying it!
~~MZ~~
Compressed and Uncompressed are words that describe how the public key is represented after it is calculated from the private key.
If you convert from a "Compressed Key" private key to an "Uncompressed Key" private key, you are telling the wallet that it should use the private key to calculate an uncompressed public key instead of a compressed public key. Since a bitcoin address is a hash of the public key, this means that changing from a "Compressed Key" private key to an "Uncompressed Key" private key will result in a completely different bitcoin address.
Importing an "Uncompressed Key" private key will not allow you access to any of the bitcoins that were sent to the address that was associated with the "Compressed Key" address.
If you aren't trying to access a particular bitcoin address, then I'm not sure why you'd be importing a private key at all?
If you are certain that you want to import the private key for the "Uncompressed Key" address, then here's what you need to do:
- Convert from base 58 to bytes (base 16) using the Base58Check symbol chart
- Truncate the trailing 5 bytes from the result of the previous step (this is the Extended Key)
- Perform SHA-256 hash on the Extended Key
- Perform SHA-256 hash on the result of the previous step (this is the Extended Checksum)
- Concatenate the Extended Key and the first 4 bytes of the Extended Checksum
- Convert the result of the previous step from a byte string into a base58 string using the Base58Check symbol chart