Skip to content

Harden entropy fail-closed behavior - #4

Merged
shadowbipnode merged 3 commits into
mainfrom
harden-entropy-fail-closed
Aug 2, 2026
Merged

Harden entropy fail-closed behavior#4
shadowbipnode merged 3 commits into
mainfrom
harden-entropy-fail-closed

Conversation

@shadowbipnode

Copy link
Copy Markdown
Owner

Summary

  • require the mandatory OS CSPRNG source when deriving mnemonics
  • fail if OS entropy returns an unexpected byte count
  • lazy-load qrcode so self-test/help work on minimal offline environments
  • document fail-closed entropy handling and add regression tests

Verification

  • python3 -m compileall -q entropyseed tests seedgen.py seed.py
  • python3 seedgen.py --self-test
  • python3 seedgen.py --help
  • direct check that derive_mnemonic rejects source lists without os-csprng

Note: full pytest could not be run locally because this VM lacks pip/pytest/python3-venv; GitHub Actions should run the complete matrix.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 73ee995fb4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread entropyseed/cli.py


def print_mnemonic_qr(mnemonic: str) -> None:
import qrcode

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check QR support before generating the mnemonic

When qrcode is absent and the user requests --qr—the minimal offline environment this change is intended to support—the import now occurs only after main() has generated and printed the mnemonic. It then raises an uncaught ModuleNotFoundError, leaving the user with an unnecessarily exposed mnemonic but no requested QR output. Resolve/import the optional dependency immediately after parsing --qr, before entropy collection and mnemonic generation, and report a controlled error if unavailable.

Useful? React with 👍 / 👎.

@shadowbipnode

Copy link
Copy Markdown
Owner Author

Addressed the Codex QR review feedback in commit 0b3bdc1. When --qr is requested, the CLI now checks for the optional qrcode dependency immediately after argument parsing and exits with a controlled error before entropy collection or mnemonic generation if QR support is unavailable. Added regression coverage for that path.

@shadowbipnode
shadowbipnode merged commit 92110ce into main Aug 2, 2026
13 checks passed
@shadowbipnode
shadowbipnode deleted the harden-entropy-fail-closed branch August 2, 2026 16:12
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