Skip to content

Commit f13922c

Browse files
committed
chore: improving estimates
1 parent f666de8 commit f13922c

File tree

2 files changed

+346
-56
lines changed

2 files changed

+346
-56
lines changed

README.md

Lines changed: 64 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ All commands share the Argon2id cost flags. For release mode we have:
123123

124124
## Brute‑force search time estimation
125125

126+
### Understanding the Time Estimates
127+
128+
**Search space**: For n-bit preimages, there are 2^(n-1) possible candidates (MSB always 1).
129+
130+
**Expected trials**:
131+
- Systematic search: 2^(n-2) trials (exactly half the space)
132+
- Random search: 2^(n-1) trials (due to replacement/duplicates)
133+
134+
**Wall-clock time** = (Expected trials × Time per trial) / Number of threads
135+
136+
The table below shows realistic scenarios:
137+
- Desktop (16 threads): Limited by available cores
138+
- Cluster (2048 threads): Limited by coordination overhead
139+
126140
**Assumptions**
127141

128142
* Preimages are uniformly from [2<sup>n-1</sup>, 2<sup>n</sup>), i.e. the most‑significant bit is **always 1**. Every candidate truly has *n* bits; the search‑space size is therefore 2<sup>n‑1</sup>
@@ -164,20 +178,27 @@ All commands share the Argon2id cost flags. For release mode we have:
164178
| 31 | 65 y 297 d | 182 d | 182 d | 2 y 105 d | 3 y 157 d |
165179
| 32 | 131 y 228 d | 364 d | 364 d | 4 y 212 d | 6 y 318 d |
166180

181+
167182
## Understanding Random Search Variance
168183

169184
Random search follows a geometric distribution with high variance. While the table shows expected times, actual recovery can vary significantly:
170185

171-
* **50% chance** of finding the key in ~0.7× the expected time
172-
* **90% chance** it will take longer than ~2.3× the expected time
173-
* **99% chance** it will take longer than ~4.6× the expected time
186+
**⚠️ Important**: The random search times shown are averages. Due to the geometric distribution:
187+
- 50% chance of finding by 0.69× the shown time
188+
- 10% chance of taking more than 2.3× the shown time
189+
- 1% chance of taking more than 4.6× the shown time
190+
191+
Systematic search has no variance—it will find the key in exactly the expected time.
174192

175193
For planning purposes, consider the 99th percentile times shown in the table above to understand worst-case scenarios.
176194

177195
**Interpretation**
178196

179-
* **Single machine** (16 threads): we partition the space, so duplicates never happen. Expected time is exactly half the random search.
180-
* **Cluster** (2048 threads): different machines choose ranges independently; occasional overlaps mean the average time is the same as pure random sampling.
197+
* **Single machine (16 threads)**: Systematic search partitions the space among threads, eliminating duplicates. Each thread searches a distinct range, guaranteeing the key will be found after searching exactly half the total space on average.
198+
199+
* **Cluster (2048 threads)**: Random search where each machine independently selects candidates. The 128× increase in threads (2048 vs 16) compensates for occasional duplicate work, resulting in much faster wall-clock time despite the same expected number of trials.
200+
201+
* **Key insight**: With equal thread counts, systematic search would complete in half the time of random search due to no duplicates. The table shows different thread counts to reflect realistic deployment scenarios.
181202

182203

183204
### Real world example using the `benchmark` command
@@ -188,55 +209,55 @@ Starting benchmark with 1 iterations across 16 threads...
188209

189210
Benchmark results:
190211
Threads: 16
191-
Total time: 30.51s
212+
Total time: 35.48s
192213
Total iterations: 16
193-
Global average time per derivation: 1907.07ms
194-
Global derivations per second: 0.52
195-
Thread average time per derivation: 30.51s
214+
Global average time per derivation: 2217.33ms
215+
Global derivations per second: 0.45
216+
Thread average time per derivation: 35.48s
196217
Thread derivations per second: 0.03
197218

198219
Estimated time to brute-force one preimage/key pair:
199220
Note: This benchmark uses 16 threads with systematic search
200221
For comparison with random search percentiles, see README table
201222

202-
bits │ systematic (worst) │ systematic (avg)
223+
bits │ systematic (worst) │ systematic (expected)
203224
-----┼--------------------┼-------------------
204-
1 │ 31s31s
205-
2 │ 31s31s
206-
3 │ 31s31s
207-
4 │ 31s31s
208-
5 │ 31s31s
209-
6 │ 1min 1s31s
210-
7 │ 2min 2s 1min 1s
211-
8 │ 4min 4s 2min 2s
212-
9 │ 8min 8s 4min 4s
213-
10 │ 16min 16s 8min 8s
214-
11 │ 32min 33s16min 16s
215-
12 │ 1h 5min32min 33s
216-
13 │ 2h 10min 1h 5min
217-
14 │ 4h 20min │ 2h 10min
218-
15 │ 8h 41min4h 20min
219-
16 │ 17h 22min8h 41min
220-
17 │ 1d 11h17h 22min
221-
18 │ 2d 21h │ 1d 11h
222-
19 │ 5d 19h2d 21h
223-
20 │ 11d 14h5d 19h
224-
21 │ 23d 3h 11d 14h
225-
22 │ 46d 7h 23d 3h
226-
23 │ 92d 14h 46d 7h
227-
24 │ 185d 4h 92d 14h
228-
25 │ 1y 5d185d 4h
229-
26 │ 2y 10d 1y 5d
230-
27 │ 4y 20d 2y 10d
231-
28 │ 8y 41d 4y 20d
232-
29 │ 16y 81d 8y 41d
233-
30 │ 32y 162d 16y 81d
234-
31 │ 64y 324d32y 162d
235-
32 │ 129y 283d64y 324d
225+
1 │ 35s35s
226+
2 │ 35s35s
227+
3 │ 35s35s
228+
4 │ 35s35s
229+
5 │ 35s35s
230+
6 │ 1min 11s35s
231+
7 │ 2min 22s │ 1min 11s
232+
8 │ 4min 44s │ 2min 22s
233+
9 │ 9min 28s │ 4min 44s
234+
10 │ 18min 55s9min 28s
235+
11 │ 37min 51s18min 55s
236+
12 │ 1h 16min37min 51s
237+
13 │ 2h 31min │ 1h 16min
238+
14 │ 5h 3min │ 2h 31min
239+
15 │ 10h 5min 5h 3min
240+
16 │ 20h 11min10h 5min
241+
17 │ 1d 16h20h 11min
242+
18 │ 3d 9h │ 1d 16h
243+
19 │ 6d 17h 3d 9h
244+
20 │ 13d 11h6d 17h
245+
21 │ 26d 22h 13d 11h
246+
22 │ 53d 20h 26d 22h
247+
23 │ 107d 15h 53d 20h
248+
24 │ 215d 7h107d 15h
249+
25 │ 1y 66d215d 7h
250+
26 │ 2y 131d │ 1y 66d
251+
27 │ 4y 262d │ 2y 131d
252+
28 │ 9y 159d │ 4y 262d
253+
29 │ 18y 319d 9y 159d
254+
30 │ 37y 273d18y 319d
255+
31 │ 75y 181d37y 273d
256+
32 │ 150y 362d75y 181d
236257

237258
Systematic search explanation:
238259
• Worst-case: One thread gets unlucky and searches entire partition
239-
Average case: Threads find target halfway through their partitions
260+
Expected case: Threads find target halfway through their partitions on average
240261
• No variance: Deterministic partitioning means predictable bounds
241262

242263
For random search with percentiles, see the README table comparing

0 commit comments

Comments
 (0)