[electrum] also use libsecp256k1 for point addition
Summary:
Time taken to add points changes to around 50% of what it was with python-ecdsa
Backport of:
- https://github.com/spesmilo/electrum/commit/65d896be5a646e9c0650feaba0ddd36de4833918
- https://github.com/spesmilo/electrum/commit/1669dd97827951d330b87bb6d7f786d843504766
See also electroncash#1621
Depends on D16682
Benchmark:
import os import time from electrumabc.ecc import GENERATOR from electrumabc.crypto import sha256 rand_bytes = os.urandom(32) 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")
Before: time taken: 1.0946 seconds
After: time taken: 0.5168 seconds
Test Plan: python test_runner.py
Reviewers: #bitcoin_abc, bytesofman
Reviewed By: #bitcoin_abc, bytesofman
Differential Revision: https://reviews.bitcoinabc.org/D16684