Let's assume I am a developer of Bitcoin wallet.

If I create a private key without implementing a seed phrase methodology (not using the principles of BIP32 and BIP39), is there at least the slightest chance that by generating a public key and address based on that public key, I will not be able to spend my bitcoins – because the signature doesn't prove that the owner of a private key produced a given message?

2 Answers 2


If you properly create the public key and address, there is no chance that the signature created from the private key will fail.

This was true before BIP32 and BIP39. It remains true.

  • Ok, cool, @RedGrittyBrick. So, in other words, any 128-bit binary number from 000000000000......0000000 to 111111111111111.......11111111 fits for creating a private key?
    – user125245
    Sep 15, 2021 at 9:40
  • 2
    No, only values which meet the specification for secp256k1. Approximately 2^256-2^32 total keys are valid.
    – Claris
    Sep 15, 2021 at 9:49
  • In BIP32 yes. BIP39 is a specification of seed mnemonic encoding, not deterministic key generation.
    – Claris
    Sep 15, 2021 at 12:38
  • @Claris That number is the size of the coordinate field. The number of private keys is slightly smaller: it has to be between 1 and 2^256-432420386565659656852420866394968145600, inclusive. Sep 15, 2021 at 13:25
  • 1
    “Slightly” I suppose is right in the scale of the numbers :P
    – Claris
    Sep 15, 2021 at 14:41

Thanks to aforementioned info I made a conclusion – I can generate my own private key using some constraints (to be sure my hand-made private key will not fail).

Here's what I have to do in order to generate a "right" private key:

  1. I must generate a random number from 1 to 2^256

  2. Convert a binary number to hexadecimal form using SHA256 (let's call it number)

  3. Compare a converted number with an upper allowed boundary:

    0 < number < (2^256 - 432,420,386,565,659,656,852,420,866,394,968,145,600)

How we get a decimal operand for aforementioned subtraction?

Finite field Fp is associated with a secp256k1, specified by the sextuple T = (p,a,b,G,n,h)

Fp is defined by first Hex p value (or 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1).

The order n of G is second Hex value.

432,420,386,565,659,656,852,420,866,394,968,145,600                // Decimal
  1. In Bitcoin mainnet all private keys begin with 5

    I must add 80 in Hex in the beginning of private key
  2. Then I generate a checksum of a key, applying SHA256 one more time

  3. I copy 8 leading Hex characters of a checksum and paste them to the end of my private key

  4. And at last, I convert my hexadecimal private key to base58

    Base 58 excludes:
         0 – (zero)
         I – (capital i)
         l – (lower case L)
         O – (capital o)
    Base 58 includes:
         25 lower case characters
         24 capital characters
         numbers 1 to 9

My hand-made private key is ready.

  • 4
    If you generate a truly random (with a secure RNG!) number between 1 and 2^432420386565659656852420866394968145600, you're done. No need to use SHA256 or convert to hex or anything. Private keys are just numbers. Sep 15, 2021 at 13:27
  • 1
    Eh, that's between 1 and 2^256-432420386565659656852420866394968145600; the number i gave above is slightly too large. Sep 15, 2021 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy