Files
pallectrum/electrum
SomberNight 65d896be5a ecc: also use libsecp256k1 for point addition
time taken to add points changes to around 35% of what it was with python-ecdsa

-----

# benchmark runs before:
> python3.7-64 ..\wspace\201909_libsecp256k1_point_addition\bench.py
time taken: 3.7693 seconds
> python3.7-64 ..\wspace\201909_libsecp256k1_point_addition\bench.py
time taken: 3.8123 seconds
> python3.7-64 ..\wspace\201909_libsecp256k1_point_addition\bench.py
time taken: 3.7937 seconds

# benchmark runs after:
> python3.7-64 ..\wspace\201909_libsecp256k1_point_addition\bench.py
time taken: 1.3127 seconds
> python3.7-64 ..\wspace\201909_libsecp256k1_point_addition\bench.py
time taken: 1.3000 seconds
> python3.7-64 ..\wspace\201909_libsecp256k1_point_addition\bench.py
time taken: 1.3128 seconds

-----

# benchmark script:

import os
import time
from electrum.ecc import generator
from electrum.crypto import sha256

rand_bytes = os.urandom(32)
#rand_bytes = bytes.fromhex('d3d88983b91ee6dfd546ccf89b9a1ffb23b01bf2eef322c2808cb3d951a3c116')
point_pairs = []
for i in range(30000):
    rand_bytes = sha256(rand_bytes)
    rand_int = int.from_bytes(rand_bytes, "big")
    a = generator() * rand_int
    rand_bytes = sha256(rand_bytes)
    rand_int = int.from_bytes(rand_bytes, "big")
    b = generator() * rand_int
    point_pairs.append((a,b))

t0 = time.time()
for a, b in point_pairs:
    c = a + b
t = time.time() - t0
print(f"time taken: {t:.4f} seconds")
2019-09-16 20:43:13 +02:00
..
2019-09-10 16:24:21 +02:00
2019-09-05 11:45:28 +02:00
2019-09-12 12:26:49 +02:00
2019-09-04 13:53:38 +02:00
2019-09-12 20:11:20 +02:00
2019-09-13 12:26:27 +02:00
2019-09-12 12:26:49 +02:00
2019-09-05 18:30:04 +02:00
2019-08-20 09:03:12 +02:00
2019-09-11 11:58:28 +02:00
2019-08-20 09:03:12 +02:00
2019-09-10 21:17:15 +02:00
2019-09-12 04:07:17 +02:00