Commit 043b358
committed
fix(crypto): fix BLAKE2b finalization for block-aligned inputs in ZIP-243
The blake2b_256_personal function had a manual loop that processed all
complete 128-byte blocks with the finalization flag f=0. For inputs whose
length is an exact multiple of the block size (e.g. the outputs preimage
for 8+ outputs), the finalize call would find an empty buffer and compress
a spurious all-zero block as the final block, producing the wrong hash.
Fix: remove the manual loop and feed all data through the Lazy buffer
(buffer.digest_blocks), which retains the last block until finalize so
the correct finalization flag is always applied.1 parent 8d7f0c5 commit 043b358
1 file changed
Lines changed: 4 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | 15 | | |
18 | 16 | | |
19 | 17 | | |
| |||
339 | 337 | | |
340 | 338 | | |
341 | 339 | | |
342 | | - | |
343 | 340 | | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
356 | 344 | | |
357 | | - | |
| 345 | + | |
358 | 346 | | |
359 | 347 | | |
360 | 348 | | |
| |||
0 commit comments