user136095: 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.

user208: 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%.

136095: <p>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.</p>
<p>So, I'm really wondering whether there is a specific requirement imposed on Bitcoin's private keys.</p>
 208: <p>A secp256k1 private key is an integer between <em>1</em> and <em>11579208923731619542357098500868790785283756427907490438260516314151816149433</em>6, inclusive. The latter can be written as <em>2<sup>256</sup> - 432420386565659656852420866394968145600</em>, or in hexadecimal as <code>0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140</code>.</p>
<p>Usually private keys are encoded using 256-bit big endian encodings, yielding 32 bytes. <em>Almost all</em> 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%.</p>
