First of all I want to say that I have exactly 0 knowledge how I can write something in Python. But I have some knowledge in math especially finite fields. That's why I want to learn more in writing tools for a Project.

This is the list what the tool should do:

  • generating random private keys.
  • in a range ( which I can change )
  • give out the hex X Point
  • compare with given X Point

Now the question: is that too difficult for a newbie? And is C++ better for that instead of Python?


You should definitely stick with Python or my fav, SageMath (which is Python based) when playing with elliptic curve crypto.

The private key is generally just a large scalar value, which when multiplied with the curves base point (in other words when we repeatedly double the base point) the resultant point is the public key.

There are subtleties that aren’t captured here, that vary across curves and production implementations.

I’d start in SageMath it’s an easy place to begin. Check out this link for a starter.


Python 3 is very fine for exploring asymmetric cryptography: it is clean, concise, powerful; has built-in support for arbitrarily large integers; is easy to install, learn and use; it minimizes the idea-to-result delay; and it has enough industrial traction that knowing it has marketplace value.

Since Python 3.6, there's the built-in secrets module intended to generate cryptographically strong random numbers (and it was feasible to build or add similar functionality in previous versions). It will make "generating random private keys.. in a range" a breeze.

While the built-in integers are fast enough for most uses, should you need more speed, there's gmpy2, with precompiled Windows binaries there.

Just be conscious that:

  • It is hard to prevent side channel leakage (e.g. by timing variation) in Python, which can be an issue for cryptographic code that both can be observed (perhaps, remotely) by adversaries, and manipulates secrets like private keys.
  • The size and frequent updates of the Python runtime and packages adds to the configuration audit and hardening nightmare of safely deploying crypto in the real world.
  • Python is not good for code that must be callable from other languages or run in small microcontrollers.
  • $\begingroup$ Thanks for your Comments. Actually I read an book for that and try my best. :) I upload all my progress here. $\endgroup$
    – Buzz
    Dec 5 '19 at 22:49
  • $\begingroup$ I used "secret" for my tool, it works and give back the X Coordinate of a random private key. Next step is to add Automatic random search in a given range and compare that value with a database. :) Some more hints for that? 😁 $\endgroup$
    – Buzz
    Dec 6 '19 at 12:32
  • $\begingroup$ @Buzz: I do not know exactly what you mean by "the X Coordinate" (of a random private key): it suggests X Cartesian coordinate of a point on an Elliptic Curve, but usually private keys are not point on an EC; they are scalar. Independently: a database of private keys is dangerous for the rightful keys user(s) if the keys are used, and useful only to test the generator if not. $\endgroup$
    – fgrieu
    Dec 6 '19 at 13:17
  • $\begingroup$ Hey Fgrieu, I mean the coordinates for the public key. 😁 I have a database with some public key points which I want to search ( I know the exactly range ) and after that I want to calculate my own Algorithmus. $\endgroup$
    – Buzz
    Dec 6 '19 at 23:27

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