Repository navigation
create: Mix optional typed keystrokes into Core randomness - #159
BenWestgate wants to merge 3 commits into
Conversation
BenWestgate
left a comment
There was a problem hiding this comment.
AI-assisted current-head security review.
Concept ACK, not code ACK, at 3ced124. Hashing manually entered entropy last is a useful additional source when OS RNG and the temporary Core wallet both fail. One issue: --keystrokes currently accepts non-TTY stdin via _cli_input.read_text, while docs promise those keys are not saved or kept in command history; piped/file-supplied text does not meet that guarantee. Require an interactive TTY for this opt-in path (with a regression test), or document the narrower guarantee. Keep stacked on #145.
|
Re the non-TTY point: On a real terminal Generated by Claude Code |
BenWestgate
left a comment
There was a problem hiding this comment.
AI-assisted review at maintainer request.
Code ACK ede3d2d (static). The non-TTY concern was incorrect: create already rejects noninteractive input before prompting, now covered by a regression test. Typed entropy is mixed into each draw after Core and OS randomness. No new blocker found. Python package CI was still running at review time; tests not run locally.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Now this should probably use Argon2id or Scrypt according to the OWASP passphrase storage cheat sheet. Users will probably not generate enough entropy to produce 128-bits even when they think they do, so strong key stretching improves this feature. See https://github.com/oleganza/bitcoin-papers/blob/master/AuditableBitcoinWallets.md |
|
AI-assisted security follow-up: Concept ACK. The typed keys may have far less than 128 bits; |
bea2914 to
7cb2ae6
Compare
ede3d2d to
66d2efd
Compare
bea2914 to
7cb2ae6
Compare
ede3d2d to
66d2efd
Compare
|
17a16bd adds the scrypt stretching from the two comments above.
All 924 tests pass locally. Generated by Claude Code |
|
A re-run won't pick up the fix because it reuses the old merge commit. This PR gets the fix when it is rebased onto Generated by Claude Code |
BenWestgate
left a comment
There was a problem hiding this comment.
AI-assisted incremental security review at 17a16bd: Concept ACK. The opt-in typed input is now stretched with scrypt (128 MiB, once per draw) and a per-draw salt; the Core+OS path is unchanged. This raises offline guessing cost, not the input's entropy. Static review found no new blocker in the delta. Still draft: rebase onto #145's CI fix and obtain independent review of the underlying CoreEntropy boundary; current fixture run failed on an older stacked base.
|
AI-assisted integration follow-up for |
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
753eded to
0d5df21
Compare
`ms32 create --keystrokes` asks for random keys without showing them or keeping them in line history, and hashes them in last on every draw: sha256(xprv + OS bytes + typed keys). They never reach the wallet, so a broken OS generator plus a leaked wallet file now rests on how unpredictable the typing was instead of being a total loss. Claude-Session: https://claude.ai/code/session_01T233rKgZqE5wzDm3EVTHL1
`create` already refuses non-terminal stdin before any prompt, so keys can only be typed, never piped or read from a file. Pin that for `--keystrokes`. Claude-Session: https://claude.ai/code/session_01T233rKgZqE5wzDm3EVTHL1
People type far fewer unpredictable bits than they think, so when both generators fail and Core's wallet file leaks, raw typed keys can be guessed quickly. Each draw now runs the typed text through scrypt at OWASP's minimum (N=2^17, r=8, p=1, 128 MiB, maxmem capped at 256 MiB) before hashing it in, salted with a domain tag and the draw's first xprv and OS bytes. It adds no entropy, but every guess now costs one scrypt. Draws without typed keys skip scrypt and are unchanged. A 3-of-5 creation makes 9 draws, so about 10 seconds in all. Claude-Session: https://claude.ai/code/session_01T233rKgZqE5wzDm3EVTHL1
17a16bd to
befead5
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
BenWestgate
left a comment
There was a problem hiding this comment.
AI-assisted review at the maintainer's request.
Code ACK befead5549d0. Security diff scan of the four changed source files found no vulnerability; 59 focused Core tests pass and current-head CI is green. Interactive input is hidden; the CLI rejects piped creation before prompting. scrypt raises guessing cost without claiming extra entropy. Tails hardware integration remains a separate pre-merge check.
Before: if this computer's random generator is broken and Core's temporary wallet file leaks, the new cards are lost, because the weak passphrase decrypts the xprvs.
After:
ms32 create --keystrokesasks for some random keys, without showing them or keeping them in line history. On every draw they are stretched with scrypt and hashed in last:sha256(xprv + 32 OS bytes + scrypt(typed keys)). They never reach the wallet, so that case now rests on how unpredictable the typing was, and each guess at it costs one scrypt.How:
CoreEntropytakes an optionaltypedstring. scrypt runs once per draw at OWASP's minimum (N=2^17, r=8, p=1, 128 MiB, maxmem capped at 256 MiB), salted withcodex32 keystrokes\0plus the draw's first xprv and OS bytes. Draws without typed keys skip scrypt and are unchanged. The CLI reads the keys withgetpass; non-terminal stdin is refused before any prompt, and--keystrokesis refused when no new cards are drawn.Stacked on #201.