Skip to content

perf(storage): cut V19 PIN KDF to 70k iterations (30% faster unlock) - #371

Open
BitHighlander wants to merge 1 commit into
developfrom
fix/pin-kdf-30pct-faster
Open

perf(storage): cut V19 PIN KDF to 70k iterations (30% faster unlock)#371
BitHighlander wants to merge 1 commit into
developfrom
fix/pin-kdf-30pct-faster

Conversation

@BitHighlander

Copy link
Copy Markdown
Owner

What

PIN_ITER_COUNT_v19 100000 → 70000, PIN_ITER_CHUNK_v19 1000 → 700.

Why

V19 (e109404) restored a 100,000-iteration PBKDF2 work factor after V16 had cut it to ten. Two passes at that count is the multi-second unlock wait now visible on 7.15.0-rc27 hardware.

The offline work factor this buys is bounded by the PIN search space, not by the iteration count. The alphabet is 1–9 and most users pick four digits — 6,561 candidates. Those last 30,000 iterations are paid on every unlock, forever, to move a GPU attack by minutes.

Correctness

  • 70000 / 700 = 100 exactly, so the progress loop still ticks 100 times and layoutProgress lands on 1000.
  • V15 and V16 constants untouched — old wallets must unwrap with the parameters they were written under, then rewrap.
  • unittests/firmware/storage.cpp exercises the KDF as a round-trip (derive → unwrap → rewrap), not against fixed key vectors, so no goldens are pinned to the iteration count.
  • EMULATOR/DEBUG values left alone (already 1000; that path never had the wait).

Timing

V19 has not shipped in any tag. These constants are part of the persistent storage format, so the number has to be settled before release — changing it afterward costs a V20 and a migration for every wallet.

Not verified here

The 30% is proportional, not measured: PBKDF2 is linear in iterations, but no stopwatch reading was taken off rc27 hardware. Worth timing the progress bar on a build of this branch before merge. Reviewers who know the rationale behind the V19 hardening — if it came from an audit finding that named a specific work factor, that constrains this number and I'd want to hear it.

V19 restored a 100,000-iteration PBKDF2 work factor after V16 had reduced
it to ten. Two passes at that count is the multi-second unlock wait users
are hitting on 7.15.0-rc27.

Drop to 70,000 (chunk 700, so the progress loop still ticks 100 times) for
a 30% cut in unlock wall-clock. The offline work factor this buys is
bounded by the PIN search space -- alphabet 1-9, and most users pick four
digits -- so the last 30k iterations are paid on every single unlock to
move a GPU attack by minutes.

V19 has not shipped in any tag. These constants are part of the persistent
storage format, so this has to be settled before release: changing it after
costs a V20 and a migration for every wallet. V15 and V16 constants are
untouched, as old wallets must unwrap with their original parameters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant