-
Notifications
You must be signed in to change notification settings - Fork 5
docs: explain MnemonicSwift pitfall AFE-172 #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HashMapsData2Value
wants to merge
3
commits into
main
Choose a base branch
from
docs/clarify-mnemonic-swift
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to clarify here, since the seedBytes are deterministic. I may be misunderstanding but it seems to be a 1-1 for the Seed/Entropy to Mnemonic conversions.
It looks like the interface only supports hex encoding though, luckily it's attached to the response of
deterministicSeedBytes
. You can see the hex property being used in deterministicSeedString, that could be the input tomnemonicString
Looks like this is missing some statements?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a one way function:
Mnemonic --> "seedBytes"
seedBytes --//--> Mnemonics
Because of this line right here: https://github.com/Electric-Coin-Company/MnemonicSwift/blob/716a2c32ac2bbd8a1499ac834077df42b75edc85/MnemonicSwift/Mnemonic.swift#L135
The PBKDF2 involves hashing.
To contextualize what I wrote (which could probably be reworded and made clearer), look at this BIP39 NPM package: https://github.com/bitcoinjs/bip39/blob/a7ecbfe2e60d0214ce17163d610cad9f7b23140c/src/index.js#L38
They have:
But there is no Seed to Mnemonic or Seed to Entropy.
Meanwhile the MnemonicSwift library doesn't even have Entropy <-> Mnemonic. It's all Mnemonic --> Determinstic SeedBytes.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MnemonicSwift does have Entropy <-> Mnemonic via the string utilities. Looks like they return Data that has a toBitArray method
The initial guide on the project may be the culprit for this particular issue, maybe we go with something like the following:
That way they can still handle the entropy bytes in a sane way then decide if they want to derive keys using MnemonicSwift. Deriving a seed as the first step leads to this footgun where they expect to recover the inputs of the seed.