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:
parent
07f1c4297d
commit
1eaeb67fdf
|
@ -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
|
||||||
|
```
|
|
@ -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()))
|
||||||
|
}
|
Loading…
Reference in New Issue