Login with mnemonic is incorrectly creating the private key from entropy instead of from seed. #729
Labels
No Label
1000k
100k
10k
200k
20k
500k
50k
5k
75k
backend
blocked:design
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
P1
P2
P3
question
scope:intl
scope:nip
scope:query_tracing
scope:ux
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Kieran/snort#729
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
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?
Description
The file
src/branch/main/packages/app/src/Hooks/useLoginHandler.tsx:useLoginHandler():doLogin()
contains the following logic:This references logic defined in the file
src/branch/main/packages/app/src/Utils/nip6.ts
(i.e.,generateBip39Entropy()
,entropyToPrivateKey()
).The primary concern is this logic in the function
generateBip39Entropy()
which uses the functionbip39.mnemonicToEntropy()
from the package@scure/bip39
:The login process should instead be using the the function
await bip39.mnemonicToSeed()
from the package@scure/bip39
:For clarification, the current logic respects the following process:
Whereas, the logic should instead respect the following process:
1 above: https://learnmeabitcoin.com/technical/mnemonic#generate-entropy
2 above: https://learnmeabitcoin.com/technical/mnemonic#entropy-to-mnemonic
4 & 5 [CORRECT] above: https://learnmeabitcoin.com/technical/mnemonic#mnemonic-to-seed
Additional context
This BIP-39 documentation does not mention recalculating entropy from the mnemonic:
https://bips.xyz/39#from-mnemonic-to-seed
I verified that the values from this suggested change match the values generated using the
@scure/bip32
and@scure/bip39
typescript libraries:https://github.com/paulmillr/scure-bip32
https://github.com/paulmillr/scure-bip39
I verified that the values from this suggested change match the values generated using the NBitcoin C# library:
https://github.com/MetacoSA/NBitcoin
I verified that the values from this suggested change match the
Seed
andBIP32 Root Key
provided here using an identical phrase:https://bitaps.com/mnemonic