add a simple utility for converting seed phrase to private key

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-07-01 17:14:42 -04:00
parent 07f1c4297d
commit 1eaeb67fdf
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
2 changed files with 41 additions and 0 deletions

12
seed2key/README.md Normal file
View File

@ -0,0 +1,12 @@
# Description
This is a tiny utility for converting a Status seed phrase into a private key.
I created it so I could use my normal Status account with the [status-console-client](https://github.com/status-im/status-console-client).
# Usage
```bash
$ echo "this is my secret seed phrase" | go run main.go
0x334d5305f760c5767e25fd23480a46790ba9c6cc3519196a96675259515128fa
```

29
seed2key/main.go Normal file
View File

@ -0,0 +1,29 @@
package main
import (
"bufio"
"fmt"
"os"
"github.com/ethereum/go-ethereum/crypto"
"github.com/status-im/status-go/extkeys"
)
func main() {
// read the seed phrase from stdin
reader := bufio.NewReader(os.Stdin)
seedPhrase, err := reader.ReadString('\n')
if err != nil {
fmt.Printf("failed to read seed phrase from stdin\n")
os.Exit(1)
}
// convert the seed phrase to a private key
mnemonic := extkeys.NewMnemonic()
masterKey, err := extkeys.NewMaster(mnemonic.MnemonicSeed(seedPhrase, ""))
if err != nil {
fmt.Printf("can not create master extended key: %v\n", err)
os.Exit(1)
}
// print the private key
fmt.Printf("%#x\n", crypto.FromECDSA(masterKey.ToECDSA()))
}