Commit graph

25 commits

Author SHA1 Message Date
SomberNight
004acb906d
ecc: abstract away some usage of python-ecdsa: randrange 2020-02-11 16:41:45 +01:00
SomberNight
5f6f7da2a1
bitcoin.py: base58 address: make sure all public methods test checksum
Note: the checksum was already being checked in practically all cases, by the caller.
Moved the check here, to the lower level (but still public) method for sanity.
2019-12-08 06:56:19 +01:00
SomberNight
8cf3587aeb
base_encode/base_decode: change to saner API 2019-12-08 06:19:51 +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
dd14a3fde5
psbt: follow-ups: fix digital bitbox 2019-11-05 22:06:46 +01:00
SomberNight
04edad9984
config: no longer singleton. it is passed to Wallet.__init__
The few other cases that used SimpleConfig.get_instance() now
either get passed a config instance, or they try to get a reference
to something else that has a reference to a config.
(see lnsweep, qt/qrcodewidget, qt/qrtextedit)
2019-09-22 20:46:01 +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
7584cebbe3
bitcoin: stricter check on WIF for compressed pubkeys
fixes #5290
2019-04-25 14:35:16 +02:00
SomberNight
d4a2e9634f
bitcoin: disallow importing/sweeping segwit scripts with uncompressed pubkey
fixes #4638
2019-04-19 00:37:28 +02:00
SomberNight
a2047e2c68
tests: base43/base58 encoding/decoding 2019-02-25 19:17:38 +01:00
SomberNight
11733d6bc2
wizard: normalize bip32 derivation path
so that what gets put in storage is "canonical"
(from now on... we could storage upgrade existing wallets
but it's not critical)
2019-02-22 18:50:29 +01:00
SomberNight
85a7aa291e
bip32: refactor whole module. clean-up. 2019-02-22 18:50:24 +01:00
SomberNight
b39c51adf7
mv "electrum seed" stuff from bitcoin.py to mnemonic.py 2019-02-22 18:01:54 +01:00
SomberNight
e7f38467d7
move opcodes to bitcoin.py 2019-02-22 17:39:58 +01:00
SomberNight
0c9a03ac54
keystore: revert KDF change from #4838
making the KDF expensive is blocked on #4909
2018-12-18 15:37:29 +01:00
SomberNight
8b775fd24a
contrib: import 'requests' in try-except 2018-12-13 23:25:52 +01:00
ThomasV
2484c52611
Merge pull request #4838 from SomberNight/keystore_pw_hash2b
keystore: stronger pbkdf for encryption
2018-11-30 11:48:03 +01:00
SomberNight
36f64d1ad9
bitcoin/ecc: some more type annotations 2018-11-18 22:07:27 +01:00
SomberNight
48b0de7871
keystore: stronger pbkdf for encryption 2018-11-10 16:36:41 +01:00
SomberNight
082a83dd85
rename crypto.Hash to sha256d 2018-10-25 22:28:24 +02:00
SomberNight
a88a2dea82
split bip32 from bitcoin.py 2018-10-25 22:20:33 +02:00
Dzhelil Rufat
c9ffffc526 Remove unneccessary imports from the unit testing directory. (#4699) 2018-09-08 17:24:23 +02:00
Filip Gospodinov
c42f0dac53 test_bitcoin: fix decorators for running tests twice (#4669)
This bug is triggered if ecc_fast._libsecp256k1 and/or
crypto.AES are not present.

Before, if the first test would have raised an exception
it would have been implicitly caught by returning from
the finally block and hence this effectively masks the
test's outcome. Now, the exception is properly propagated
causing the test to fail if an exception is raised.
2018-08-30 18:53:14 +02:00
SomberNight
b4b1de088a
move TrezorClient.expand_path to bitcoin.py
and allow its input to end with a '/' slash
2018-08-14 18:19:16 +02:00
Janus
097ac144d9 file reorganization with top-level module 2018-07-13 14:01:37 +02:00
Renamed from lib/tests/test_bitcoin.py (Browse further)