Commit graph

16 commits

Author SHA1 Message Date
SomberNight
4cec098d2d
build: create a standalone build script for libsecp256k1
heavily based on Electron-Cash/Electron-Cash@eda015908e
2020-02-11 16:48:24 +01:00
SomberNight
1d72585b7d
ecc: hard fail if libsecp256k1 is not found/usable 2020-02-11 16:46:35 +01:00
SomberNight
0a5ad9fda4
ecc: small API clean-up 2020-02-11 16:42:02 +01:00
SomberNight
288d793893
ecc: use libsecp256k1 for pubkey recovery (from sig and msg) 2020-02-11 16:41:59 +01:00
SomberNight
ab0c70e291
ecc: use libsecp256k1 for signature conversions
(instead of python-ecdsa)
2020-02-11 16:41:56 +01:00
SomberNight
ad408ea832
ecc: use libsecp256k1 for sign/verify/mul/add 2020-02-11 16:41:52 +01:00
SomberNight
a5a7c205e3
trivial: add a few log lines for startup 2019-12-10 23:31:58 +01:00
SomberNight
5b88b8667e
also grind ecdsa low R when using libsecp256k1, and fix tests
note: low R grinding would not have to be duplicated if we trusted the caller
to have done it already (as is the case with the classes in ecc.py), and if
we propagated the choice of "random_k" as part of the nonce_function passed
to libsecp256k1 (which is not currently done)
2019-12-05 20:27:55 +01:00
SomberNight
1669dd9782
simplify prev
following @markblundeberg's suggestion
https://github.com/Electron-Cash/Electron-Cash/pull/1621#issuecomment-532070318
2019-09-17 19:27:28 +02:00
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
SomberNight
251db638af
only require libsecp256k1 if lightning is enabled
related: #5606
2019-09-06 15:08:15 +02:00
Janus
9862fe5c0c ecc_fast: require libsecp256k1 on lightning, channel graph breaks electrum without 2019-08-20 09:03:10 +02:00
SomberNight
3385a94753
logging: basics 2019-05-02 15:19:03 +02:00
SomberNight
7044f1145f
ecc_fast: clarify fallback message 2018-08-17 16:01:03 +02:00
zebra-lucky
059a4fff5c fix ecc_fast.py for win64 (#4606) 2018-08-05 22:30:58 +02:00
Janus
097ac144d9 file reorganization with top-level module 2018-07-13 14:01:37 +02:00
Renamed from lib/ecc_fast.py (Browse further)