2

In a library I'm reading, I can export a private key to a WIF, which takes a compressed boolean parameter. It reads:

"...False if you want a standard WIF export (the most standard option). True if you want the compressed form (Note that not all clients will accept this form)...."

I am aware that both of these private keys have the same bytes and will make the same signatures.

However, I am wondering if there is a convention for what kind of private keys are generated for legacy and (native) segwit addresses. Though information for nested segwit would also be nice to know.

1 Answer 1

3

The term "compressed private key" is a misnomer; it's not the private key that is compressed. Instead, it is an indication about whether the corresponding public key is to be in compressed (33 byte) or uncompressed (65 byte) format.

Note that since addresses contain a hash of the public key, compressed and uncompressed keys will result in separate addresses, so this is not a question to answer at private key export time - it is a property of the addresses your software uses. P2PKH outputs can use both compressed and uncompressed public keys, but since 2012 or so, compressed keys are the norm. They're cheaper to reveal and thus spend from, after all.

Inside segwit, only compressed public keys are allowed.

Taproot uses its own public key format (x-only) which is neither compressed or uncompressed, but by convention, the corresponding private keys are still compressed.

In short: always use compressed public keys, unless you need compatibility with absolutely ancient software.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.