Skip to content

Validate passphrase and identifier in mnemonics with ValueError - #28

Open
fametrano wants to merge 1 commit into
pjkundert:masterfrom
fametrano:validate-passphrase-and-identifier
Open

fametrano wants to merge 1 commit into
pjkundert:masterfrom
fametrano:validate-passphrase-and-identifier

Conversation

@fametrano

Copy link
Copy Markdown

mnemonics accepts a passphrase that is not printable ASCII, which SLIP-0039 forbids and shamir_mnemonic.generate_mnemonics refuses. It also checks the identifier with assert, so under python -O a 16-bit identifier with extendable=False gives shares that recover a different master secret.

I check the passphrase as generate_mnemonics does, and raise ValueError for an identifier out of range. The check that refuses a passphrase with an encrypted master secret was an assert too, so under -O that passphrase was silently ignored; it now raises ValueError as well. The three new tests in api_test.py fail on master and pass here, with and without -O. Closes #27.

SLIP-39 allows only printable ASCII in a passphrase, as
shamir_mnemonic.generate_mnemonics checks; mnemonics now checks it too.
The identifier and encrypted-secret passphrase checks were asserts,
which python -O removes; they now raise ValueError.

This branch has not been deployed

No deployments
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.

api.mnemonics accepts a non-ASCII passphrase, and checks the identifier with assert

1 participant