Skip to content

Commit 774e530

Browse files
authored
Update btcrseed.py
1 parent b73ea7c commit 774e530

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

btcrecover/btcrseed.py

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,19 +1140,23 @@ def __init__(self, arg_derivationpath: Optional[List[str]] = None, loading: bool
11401140

11411141
self._path_indexes.append(current_path_indexes)
11421142

1143+
def _get_pps_divisor(self) -> float:
1144+
return 1.0
1145+
11431146
def passwords_per_seconds(self, seconds: float) -> int:
11441147
if not self._passwords_per_second:
11451148
scalar_multiplies = 0
1146-
for i in self._path_indexes[0]: # Just use the first derivation path for this...
1147-
if i < 2147483648: # if it's a normal child key
1149+
for i in self._path_indexes[0]: # Just use the first derivation path for this...
1150+
if i < 2147483648: # if it's a normal child key
11481151
scalar_multiplies += 1 # then it requires a scalar multiply
11491152
if not self._chaincode:
11501153
scalar_multiplies += self._addrs_to_generate + 1 # each addr. to generate req. a scalar multiply
11511154
self._passwords_per_second = \
11521155
calc_passwords_per_second(self._checksum_ratio, self._kdf_overhead, scalar_multiplies)
11531156
passwords_per_second = max(int(round(self._passwords_per_second * seconds)), 1)
11541157
# Divide the speed by however many passphrases we are testing for each seed (Otherwise the benchmarking step takes ages)
1155-
return int(passwords_per_second / len(self._derivation_salts))
1158+
divisor = len(self._derivation_salts) * self._get_pps_divisor()
1159+
return int(passwords_per_second / divisor) if divisor else passwords_per_second
11561160

11571161

11581162

@@ -2375,19 +2379,8 @@ def create_from_params(cls, *args, **kwargs):
23752379
self = super(WalletCardano, cls).create_from_params(*args, **kwargs)
23762380
return self
23772381

2378-
def passwords_per_seconds(self, seconds):
2379-
if not self._passwords_per_second:
2380-
scalar_multiplies = 0
2381-
for i in self._path_indexes[0]: # Just use the first derivation path for this...
2382-
if i < 2147483648: # if it's a normal child key
2383-
scalar_multiplies += 1 # then it requires a scalar multiply
2384-
if not self._chaincode:
2385-
scalar_multiplies += self._addrs_to_generate + 1 # each addr. to generate req. a scalar multiply
2386-
self._passwords_per_second = \
2387-
calc_passwords_per_second(self._checksum_ratio, self._kdf_overhead, scalar_multiplies)
2388-
passwords_per_second = max(int(round(self._passwords_per_second * seconds)), 1)
2389-
# Divide the speed by however many passphrases we are testing for each seed (Otherwise the benchmarking step takes ages)
2390-
return passwords_per_second / len(self._derivation_salts) / 5
2382+
def _get_pps_divisor(self) -> float:
2383+
return 5.0
23912384

23922385
@staticmethod
23932386
def _addresses_to_hash160s(addresses):
@@ -2620,22 +2613,13 @@ def create_from_params(cls, *args, **kwargs):
26202613
self = super(WalletPyCryptoHDWallet, cls).create_from_params(*args, **kwargs)
26212614
return self
26222615

2623-
def passwords_per_seconds(self, seconds):
2616+
def _get_pps_divisor(self) -> float:
2617+
return 10.0
2618+
2619+
def passwords_per_seconds(self, seconds: float) -> int:
26242620
if self.opencl:
26252621
exit("Error: Wallet Type does not support OpenCL acceleration")
2626-
2627-
if not self._passwords_per_second:
2628-
scalar_multiplies = 0
2629-
for i in self._path_indexes[0]: # Just use the first derivation path for this...
2630-
if i < 2147483648: # if it's a normal child key
2631-
scalar_multiplies += 1 # then it requires a scalar multiply
2632-
if not self._chaincode:
2633-
scalar_multiplies += self._addrs_to_generate + 1 # each addr. to generate req. a scalar multiply
2634-
self._passwords_per_second = \
2635-
calc_passwords_per_second(self._checksum_ratio, self._kdf_overhead, scalar_multiplies)
2636-
passwords_per_second = max(int(round(self._passwords_per_second * seconds)), 1)
2637-
# Divide the speed by however many passphrases we are testing for each seed (Otherwise the benchmarking step takes ages)
2638-
return passwords_per_second / len(self._derivation_salts) / 10
2622+
return super().passwords_per_seconds(seconds)
26392623

26402624
# Default method for adding addresses, doesn't worry about validating the addresses
26412625
@staticmethod

0 commit comments

Comments
 (0)