# Signature doesn't prove that the owner of a Private Key produced a given message

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?

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? Sep 15 at 9:40
• No, only values which meet the specification for secp256k1. Approximately `2^256-2^32` total keys are valid. Sep 15 at 9:49
• In BIP32 yes. BIP39 is a specification of seed mnemonic encoding, not deterministic key generation. Sep 15 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 at 13:25
• “Slightly” I suppose is right in the scale of the numbers :P Sep 15 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.

``````0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F // Hex p
-
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 // Hex n
=
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
``````