<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>

CC BY-SA 4.0
2022-08-12T18:17:29.000Z
2022-08-14T02:11:46.920Z
2022-08-14T02:11:46.920Z
Pieter Wuille
<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>

<transactions><private-key><signature><address-generation>
Is any 256-bit combination a Bitcoin private key?
kuco 23
# Is any 256-bit combination a Bitcoin private key?

(Asked by: username_0 on 2022-08-12)

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.

**Tags:** transactions, private-key, signature, address-generation


---

## 1 answers

### Answer by username_1 on 2022-08-12. Score: 23 | Accepted answer

A secp256k1 private key is an integer between *1* and *11579208923731619542357098500868790785283756427907490438260516314151816149433*6, 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%.


---

