Skip to content

Demo: cap at 10 salt attempts with a clear message when max is too low - #10

Merged
KPreisner merged 1 commit into
mainfrom
demo-low-max
Oct 23, 2026
Merged

KPreisner merged 1 commit into
mainfrom
demo-low-max

Conversation

@KPreisner

@KPreisner KPreisner commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes the demo appearing to run forever when Max iterations is set too low: it now stops after 10 salt attempts and explains what to change.
Screenshot 2026-10-23 at 2 17 54 PM

Problem

With a max well below the typical chain length, every salt is rejected. The library then tries up to 1,000 salts before giving up, and with Animate on the page replays each attempt at about half a second, so a run could take 10+ minutes and add 1,000 bars to the page.

Changes

  • Cap at 10 salt attempts: the worker passes max_attempts=10 to Chip (the library default stays 1,000)
  • Clear failure message, shown under the bars and in the status line, using the benchmark mean for the chosen b and C:

    None of the 10 salts finished within 100 iterations, so no hash was stored. At b = 20 and C = 5, a chain needs about 3,147 iterations on average. Raise Max iterations, or press Reset to defaults.

  • Warning before running: the Max iterations hint turns red below the mean ("most salts will be rejected") and below mean − 1σ ("almost every salt will be rejected")

Testing

  • Headless Chrome, b = 20, C = 5, max = 100, Animate on: stops after 10 attempts in about 6 seconds with the message above, in light and dark themes
  • Warnings appear at max 2,600 and 1,500, not at the default 3,860
  • Reset to defaults followed by Hash still succeeds; no console errors

@KPreisner
KPreisner merged commit 234efdc into main Oct 23, 2026
6 checks passed
@KPreisner
KPreisner deleted the demo-low-max branch October 23, 2026 20:18
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