1

I might be wrong in some of the facts that I state here, so please correct me if necessary.

My understanding:

  • Private key - 256 bits
  • Public key - 256 bits
  • Public address - the last 160 bits of a public key
  • Every private key is mapped to a public key, and hence to a public address

The facts above imply that some private keys are mapped to the same public address, but they do not imply that some private keys are mapped to the same public key.

I would like to ask the following questions:

  1. Do we have any other knowledge as to whether or not some private keys are mapped to the same public key, and hence, some public keys have no private key which is mapped to them?

  2. If the answer to the above question is yes, then there's a possibility that some public addresses have no private key which is mapped to them. Do we know of any such addresses, or if they even exist?

My motivation for asking this, is that I have an ERC20 contract which sometimes (depending on the current state) mints an additional amount of tokens which will later be distributed among (i.e., transferred to) some users.

Now, I need some address to hold these tokens, but I wish to avoid the case where someone has the private key of this address (as slim a chance as it may be).

At present, I am generating this address as follows:

address public constant MINTING_ACCOUNT = address(keccak256("MINTING_ACCOUNT"));

Ideally, I would like to replace this with a constant address which has no private key.

Thank you!

5 Answers 5

5

TLDR: Use address 0.

  1. Depending on your definition of a private key, then yes or no. The public key is generated from the private key by scalar elliptic curve multiplication.

    P = k * G
    

    We know that the order of the generator G is

    n = FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141 
    

    and so every k in the range [0, n) gives a unique public key. Sometimes people say that a private key is just a random 256-bit number, but private keys are equivalent mod n, which is slightly less than 2^256. For instance the private key k and n+k will give the same public key.

If you define a "public key" as any 512-bit integer then clearly almost all of them do not have associated private keys. (There are only n < 2^256 distinct private keys).

  1. The question of whether or not an address exists with no private key is a completely separate issue. Essentially you want to know if there is a 20-byte string such that no keccak256 hash ever ends in that postfix. The answer is that nobody knows, but probably not. Cryptographic hashes are designed exactly to avoid these sorts of nontrivial patterns in their output, and it would be a major flaw if such a string were to be discovered.

In summary, no. There is no "safe address". On the other hand, as many others have pointed out, the probability of guessing a private key corresponding to the 0 address is almost exactly 2^-160. This will never happen. Note that I don't say "this will probably never happen", because humans tend to be bad at reasoning about big numbers. I say "there's a 1 in 2^160" chance, and you say "so there's a chance?"

The chance is lower than any the probability of every computer on the network spontaneously combusting. There's no chance.

So we see the only option is to just pick an address "at random". You seem to want to pick a address generated by the hash of some string. I argue that you should use the 0 address instead. In cryptography this is sometimes called a "nothing up my sleve number". The more freedom you have in picking the address, the less confident users will be that you didn't intentionally search for a collision between the fake address and a real address. If you pick 0, users can be sure you have nothing up your sleeve.

7
  • Excellent answer. I upvoted. Dec 17, 2018 at 20:00
  • Thanks. However, implementation-wise, I'm inheriting OpenZeppelin's ERC20 contract, which asserts that the address is not zero when minting, buring and transferring tokens. So I cannot quite make use of this address unless I override their functions (or just avoid inheriting it to begin with). I understand that on average, every private key is mapped to 2 ** 96 public addresses (I think I wrote it in a comment to one of the answers above here). I just thought I'd check to see if there was a "bullet proof" choice of a public address. Dec 17, 2018 at 20:07
  • If 0 doesn't work for some reason, you can always use 1. But general best practice in this space is to use 0 for the"impossible" address, because everyone will understand immediately what you are using it for. Dec 17, 2018 at 20:09
  • BTW, with regards to your The chance is lower than... argument - I'm sure someone once said that about SHA-128. Then within a few years time, computing power has increased by several magnitudes, some people (or more precisely, agencies) pre-generated huge tables with hash info, and made this algorithm compromised to the point where it had to be replaced. But of course, if that ever happens to keccak256, then I guess my choice for a public address would be the least of my worries here. Dec 17, 2018 at 20:10
  • 1
    Quantum computers at most halve the bit-security of symmetric functions. See en.wikipedia.org/wiki/Grover%27s_algorithm. Even with quantum computing brute force attacks would be impossible. Dec 17, 2018 at 20:19
2

This issue is not a reason to be worry.

The probability of getting by chance a privatekey that you have already or that anyone has already in use is neglegible.

Also, the amount of time required by the fastest super-computer today to generate all the possible addresses is about 13 billion years see this answer for the case of Bitcoin

Finally, is not true that there is a 20bytes number that will not be related to a privatekey, in fact every possible address will be linked to several privatekeys. See this for a discusion

By the time this computational capability is available we should have move already to quantum resistant cryptography, whcih already exist.

Hope this helps

9
  • Thank you. But with the exception of one statement, you've basically repeated the previous answer, which did not relate to my question directly, but rather told me that I shouldn't be worried about it. The one statement: "Finally, is not true that there is a 20bytes number that will not be related to a privatekey, in fact every possible address will be linked to several privatekeys." Do you have anything to back this up? Even a link to an article or some official documentation of the Ethereum blockchain? Dec 16, 2018 at 15:46
  • I think your comment is very unfair, the link you I shared shows how to calculate the probability of getting a particular address, the reason I say to not to worry is that of that calculation, which is different than the argument in the previous answer. On the other hand, If the address is the 160 last bits of the publickey, and the public key is 256 bits, several publickey will lead to the same address. Assume the posssinle public keys are 3 bits long and the address is 1 bit (2 addresses: 0 or 1), 000, 010 and 100 are the publickeys with the same address.
    – Jaime
    Dec 16, 2018 at 15:59
  • Please take a look to my editted answer for a discussion about several private keys with the same address
    – Jaime
    Dec 16, 2018 at 16:10
  • did this cleared things for you?
    – Jaime
    Dec 16, 2018 at 16:20
  • Thank you. First of all, there is one statement in that link which reveals an error in the facts that I have stated: "A public key is 512-bit long" (and not 256-bit long as I mentioned). Dec 16, 2018 at 18:57
2

No, there is no way to use "non-private-key addresses". Ethereum uses ECDSA that generates the public keys exclusively from the private key. So there are no "privileged" addresses that can be used as non-public address. The full set of public addresses can be generated from the full set of private addresses.

2

A contract has no private key.

You could consider a very idiomatic contract with an Ownable or Multi-signature pattern and a possibility of withdrawing the tokens or distributing. Mint tokens to that contract's address.

Obviously, there will still be an account or combination of accounts that can perform some limited range of options, defined in the contract, with the tokens held in the contract. If that is not the case, then the tokens would be burned.

The contract itself, like all contracts, would have no known private key.

Hope it helps.

10
  • That's exactly the approach that we started off with - Mint tokens to one of our contract addresses (good guess!). However, there's one problem with that - we cannot allow ourselves to upgrade this contract (i.e., redeploy it, and in our "registry" contract which maps unique strings to contract addresses, update this contract address). More precisely, we would need to rewrite some of our system-upgrade mechanism to handle this, and transfer all the tokens to the address of the new contract. Dec 16, 2018 at 19:06
  • So we figured we'd use some hard-coded address like 0x12345678.... But instead of a magic number, we figured we'd use keccak256 in order to generate this hard-coded address. You have stated that a contract has no private key - do you have anything to back this up? Are contract addresses somehow generated in a different manner, such that no private key possibly maps to them? Dec 16, 2018 at 19:07
  • I found an interesting thread on this. Now matters are less clear. Yes, contracts are different and no private key is generated in the process. No, possibly it is merely extremely unlikely anyone can generate a private key to spend from a contract address. Not quite the same as impossible. See here for two credible descriptions: ethereum.stackexchange.com/questions/185/… Dec 16, 2018 at 19:21
  • So what's the difference between using a contract's address and using address(keccak256("SomeString")) as I have demonstrated in my question? Sounds to me like both will yield an address with an unknown (and hard to find) private key. Dec 16, 2018 at 19:34
  • From the perspective of an ERC20 contract, your made up address is fine. From the perspective of the owner (you), I fail to see how you will get the funds back since it would be neither a wallet with a private or a contract that responds to inputs. Dec 16, 2018 at 19:39
1

There really is no need to consider the possibility that someone might, by pure chance, find that private key. You really have to appreciate how small these probabilities really are.

  • The chance that you and I will both die within this hour is much larger.

  • The chance that you will win a national lottery 5 times in a row is much larger.

The entire cryptocurrency ecosystem and the entire field of cryptography is built on the assumption that these extremely-low-probability events will not happen. You have a billion other things to worry about before you have to worry about someone accidentally finding a private key for your random public key.

1
  • I'm sure someone once said that about SHA-128. Then within a few years time, computing power has increased by several magnitudes, some people (or more precisely, agencies) pre-generated huge tables with hash info, and made this hash algorithm compromised to the point where it had to be replaced. But in any case, my point is, if we know of such address then why not use it? Hence my question. Thank you. Dec 16, 2018 at 10:58

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.