I want to generate a pair of ECDH keys (64 bytes each), where the first 12 bytes of the public key will suit my format.

For example, if I have a unique sequence "13456789ABC" I'd like to use it as the first 12 bytes of the 64 bytes long public key (the rest of the length is padded by the generated values). For each generation of the keys, the sequence will change a little bit so it is unique.

So I'm basically asking two things:

  1. Is this possible?
  2. Is there a generator which would allow me to specify a prefix of a suitable length for the public key?

closed as off-topic by Xander, Xiong Chiamiov, Rory Alsop Jun 1 '17 at 8:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about Information security within the scope defined in the help center." – Xander, Rory Alsop
If this question can be reworded to fit the rules in the help center, please edit the question.

  • What you are trying to accomplish is literally the same as to crack the key, find a set of unknown inputs that produce known output. – Crypt32 May 31 '17 at 18:53

Quick answers:

  1. Not impossible, but pretty much in the realm of defeating PKI - so not easy by a long shot (yet). [edit: If it ever becomes easy, you might want to stop using that implementation of PKI for security in the first place!]
  2. I have not come across such a generator.

PKI makes that difficult by design (not necessarily in implementation though that's a digression) - so you might want to look for design solutions that better suit your needs. Or state your underlying need, to explore possibilities.


This is very similar to the problem of generating a Bitcoin key whose address has some predetermined content, called a 'vanity' address by analogy to the 'vanity' automobile license plates available in many (most?) jurisdictions at extra cost, except Bitcoin needs to guess approximately 6 bits for each desired character in the result address. See other stack for Qs on that. You could presumably modify the Bitcoin vanitygen program to handle your case, since the hard part is the point multiplication; hashing is relatively cheap and base58 negligible.

It's not clear if you really want fixed bytes (and possibly your byte size, although since you didn't think to specify you probably only know about PC-class machines that use 8-bit bytes) or since the example you gave is all valid hexadecimal digits if you actually mean fixed digits in the hex representation often used to display and sometimes to store or transport EC keys (and other things in modern crypto).

  • If you want to fix 11 hex digits that's 44 bits; based on the rough estimates at https://en.bitcoin.it/wiki/Vanitygen it probably takes less than a day or at most a few days on reasonable hardware.

  • If you want to fix 11 bytes of 8 bits that's much costlier, for example a hundred thousand years if you use a million PC-class machines, somewhat less if you have custom hardware designed and manufactured for you.

Not the answer you're looking for? Browse other questions tagged or ask your own question.