Skip to content

Fix dead passphrase validation in Bip38KeyPair encryption constructor#9

Merged
odolvlobo merged 1 commit into
developfrom
fix/bip38-empty-passphrase-validation
Jun 13, 2026
Merged

Fix dead passphrase validation in Bip38KeyPair encryption constructor#9
odolvlobo merged 1 commit into
developfrom
fix/bip38-empty-passphrase-validation

Conversation

@odolvlobo

Copy link
Copy Markdown
Owner

The non-EC-multiply Bip38KeyPair(KeyPair, string) constructor guarded the passphrase with passphrase == null && passphrase == "", which is never true (a string cannot be both null and empty), so the check was dead code. A null passphrase would NRE during key derivation and an empty passphrase would silently encrypt the key with no passphrase. Use || so both are rejected. Also corrects the key-null ArgumentException message, which read "Passphrase is required".

Ports casascius#15.

The non-EC-multiply Bip38KeyPair(KeyPair, string) constructor guarded the
passphrase with `passphrase == null && passphrase == ""`, which is never
true (a string cannot be both null and empty), so the check was dead code.
A null passphrase would NRE during key derivation and an empty passphrase
would silently encrypt the key with no passphrase. Use `||` so both are
rejected. Also corrects the key-null ArgumentException message, which read
"Passphrase is required".

Ports casascius#15.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@odolvlobo odolvlobo merged commit 084e36b into develop Jun 13, 2026
4 checks passed
@odolvlobo odolvlobo deleted the fix/bip38-empty-passphrase-validation branch June 13, 2026 07:11
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