use ChildForPurpose with KeyPurposeWallet to get chat identity

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-07-08 15:49:54 -04:00
parent 072c50ce30
commit a686b44782
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 9 additions and 2 deletions

View File

@ -24,9 +24,16 @@ func main() {
mnemonic := extkeys.NewMnemonic()
masterKey, err := extkeys.NewMaster(mnemonic.MnemonicSeed(seedPhrase, ""))
if err != nil {
fmt.Printf("can not create master extended key: %v\n", err)
fmt.Printf("cannot create master extended key: %v\n", err)
os.Exit(1)
}
fmt.Printf("Depth: %d\n", masterKey.Depth)
// extract chat key from the master key
chatKey, err := masterKey.ChildForPurpose(extkeys.KeyPurposeWallet, 0)
if err != nil {
fmt.Printf("cannot extract chat key from master key: %v\n", err)
os.Exit(1)
}
// print the private key
fmt.Printf("%#x\n", crypto.FromECDSA(masterKey.ToECDSA()))
fmt.Printf("%#x\n", crypto.FromECDSA(chatKey.ToECDSA()))
}