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

Point Addition Performance #92

Open
iceland2k14 opened this issue Mar 17, 2021 · 2 comments
Open

Point Addition Performance #92

iceland2k14 opened this issue Mar 17, 2021 · 2 comments

Comments

@iceland2k14
Copy link

Your library performance is Very good for Scalar Multiplication. But i am trying for Point Addition and getting slower speed.

pub1 = bit.Key.from_int(1)._pk.public_key
timeit pub1.combine_keys([pub1, pub1])
8.81 µs ± 287 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

In comparison, by using gmpy2 with https://github.com/iceland2k14/bsgs/blob/main/gmp_ec.py
timeit ec.G + ec.G
6.56 µs ± 106 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

Maybe i am not trying in proper way to do Point Addition with bit or coincurve. Can you please show ?

@ofek
Copy link
Owner

ofek commented Mar 17, 2021

Can you give me a way to test like this:

$ python -m timeit -s "from coincurve import PrivateKey,PublicKey;pub_key=PrivateKey.from_int(1).public_key;keys=[pub_key, pub_key]" "PublicKey.combine_keys(keys)"
50000 loops, best of 5: 5.87 usec per loop

@iceland2k14
Copy link
Author

Just to avoid Point Doubling inside, Adding G + 2G, here they are :

python -m timeit -s "from coincurve import PrivateKey,PublicKey;pub_key2=PrivateKey.from_int(2).public_key;pub_key1=PrivateKey.from_int(1).public_key;keys=[pub_key1, pub_key2]" "PublicKey.combine_keys(keys)"
50000 loops, best of 5: 8.41 usec per loop
python -m timeit -s "import gmp_ec as ec;pub_key1=ec.G;pub_key2=ec.Scalar_Multiplication(2)" "ec.Point_Addition(pub_key1, pub_key2)"
50000 loops, best of 5: 3.9 usec per loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants