The mnemonic command: child mnemonics #6
Reference in New Issue
Block a user
Delete Branch "issue-4"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #4
keyfunc mnemonic [-n N] [--words 12|18|24]prints a child mnemonic derived from the main one with BIP-85's own mnemonic application, in English, defaulting to 12 words. Its entropy is the BIP-85 entropy cut to the length the word count needs, which is what that application asks for, so it does not pass through the generator the SSH keys read their bytes from. The BIP-85 specification's own test vectors for that application are the tests, checked against the master key the specification gives them for; the command is also checked end to end from a mnemonic.BIP-85 also allows 15 and 21 words. Only the three lengths README.md names are offered, and any other length is refused.
Two pieces the derivation package already had inside one function are now named and shared: the master key a mnemonic stands for, and the refusal of a key index that has no hardened child. The second one matters here, because the entropy deriver builds its own path and would otherwise wrap such an index around to another key.
One judgement call: the mnemonic is read before the word count is checked, so
--words 15prompts for the mnemonic and only then complains. That is the order the ssh commands already use for a bad index, so it was left alone rather than made a special case.make checkgreen.Model: opus-5
PASS
No findings.
What I verified, and how
issue-4is a fast-forward onto the currentnext, re-checked immediatelybefore writing this.
make checkwas run in this clone and exited zero. The lint layer came backcached, so I rebuilt
Dockerfile.lintwith the cache disabled to make thelinter genuinely run over this tree; it still passed.
For the derivation I wrote a separate implementation of BIP-85's mnemonic
application from the specification text alone, sharing no code with this
branch. It reproduces the specification's own 12, 18 and 24 word children for
the master key the specification publishes them under, exactly as the tests
assert — and that master key is not the one the all-
abandonmnemonic gives,so the tests are right to use the key directly.
Driving the built binary with the all-
abandonmnemonic, its output at 12, 18and 24 words and at key indexes 0 and 1 matches that separate implementation
word for word. The default is 12 words, indexes 0 and 1 differ, and the same
input always gives the same output.
I also computed what the 12-word child would be if the entropy went through
the generator the SSH keys use, and what it would be at a different word-list
number. Both differ from what the binary prints, so the entropy really is the
BIP-85 entropy cut to length at the English path, as README.md and the issue
require.
I re-derived the BIP-39 checksum by hand from the English word list for the
12, 18 and 24 word children; each holds, and the same hand check rejects a
child with one word altered, so it is not a vacuous check.
In a scratch copy I changed the word-list number, the default length, the
index guard and the set of accepted lengths; each change was caught by a named
test.
The subject carries
(closes #4), commit body and PR body are inside theirlimits and each ends with a model line, no company or product names appear,
and the scope is the issue plus the two small pieces of
internal/derive/derive.gothe new package needs.One judgement call, disclosed in the PR body and left alone:
--words 15asksfor the mnemonic before complaining about the word count. That is how the
sshcommands already treat a bad index, so I read it as consistency ratherthan a defect.
Model: opus-5