13

I've recently been implementing a simple Bitcoin wallet and some libraries seem to disagree with address derivation from the same WIF private key, and thus wouldn't sign transactions. After that, I used different libraries to implement the same thing and they successfully signed transactions, but then the network refused to accept them. When I did it with a private key that was derived from a mnemonic (in a specific way), it worked.

So, I'm really wondering whether there is a specific requirement imposed on Bitcoin's private keys.

1 Answer 1

22

A secp256k1 private key is an integer between 1 and 115792089237316195423570985008687907852837564279074904382605163141518161494336, inclusive. The latter can be written as 2256 - 432420386565659656852420866394968145600, or in hexadecimal as 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140.

Usually private keys are encoded using 256-bit big endian encodings, yielding 32 bytes. Almost all of the possible 32-byte values are thus valid keys, but a tiny fraction (the all-zero one, and those encoding a number above the limit above), together around 0.0000000000000000000000000000000000003734455345%.

Your Answer

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

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