Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace pure ECC implementation to speed block sync #42

Closed
ixje opened this issue Nov 18, 2020 · 1 comment
Closed

Replace pure ECC implementation to speed block sync #42

ixje opened this issue Nov 18, 2020 · 1 comment

Comments

@ixje
Copy link
Member

ixje commented Nov 18, 2020

On NEO2 the VM used to be the major performance bottleneck. Now that this is resolved for NEO3 through a C-extension a place with room for performance is in signature verification.

The current pure Python ECC implementation comes from neo-python and works fine but is slow. An issue about replacing that implementation existed for neo-python but was dropped to focus on more important issues. At the time also most considered ECC packages did not seem suitable. This was 2+ years ago and available libraries have evolved.

The requirements have not changed much

  • support custom curves (as we never know what NEO will change to)
  • support point on curve validation
  • support ECPoint loading from binary data (not PEM/DER format)
  • support compressed points

The options

  1. python-ecdsa
  • is a pure Python implementation, but if it detects gmpy2 it will use that for arithmetic speeding it up massively. With gmpy2 it is supposedly 3 x faster than fast-ecdsa. gmpy2 is supported on all platforms and has wheels for Windows. The downside is that you'll need to have build tools for OSX/Linux
  • signing key can be made deterministic which is nice for unittests
  • need to try creating a custom curve to see how/if that works
  • sacrifices side-channel resistance for speed. This is good for our purpose
  • note that we already use this package for signature verification, but ideally we also use it in signing and all other parts. Meaning among others we wrap Point into ECPoint and inherit from ISerializable.
  1. Do our own in C++ (or port the NEO version to C++) and wrap it with pybind11.
  • the pro is that we can create wheels for all platforms thus not needing any compilers.
  • the downside is that it takes significantly more time to create and adds maintenance

fast-ecdsa is not considered because that has side channel resistance which results in being slower than python-ecdsa. Speed for us is more important.

@ixje
Copy link
Member Author

ixje commented Jan 25, 2021

done

@ixje ixje closed this as completed Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant