将tendermint私钥转换成以太坊私钥及以太坊keystore

package main

import (
	"crypto/ed25519"
	"encoding/hex"
	"encoding/json"
	"fmt"
	"github.com/insight-chain/inb-go/accounts/keystore"
	"log"
)



func main() {

	GetKeyStore("/home/wek/Desktop/inb2","HrBah0ZIlbOwpJ7q9GrK8zrU1pzEiZJnEde9LRihA2OPyP8FJBlE2c2zWU51of0IbLndmSBhtG7pqfftOMnNbA==","123")

}



func GetKeyStore(datadir,tmPriv ,pass string){


	store := keystore.NewKeyStore(datadir, keystore.LightScryptN, keystore.LightScryptP)

	var priv ed25519.PrivateKey


	err := json.Unmarshal([]byte(`"`+tmPriv+`"`), &priv)
	if err!=nil{
		log.Fatal(err)
	}

	toString:= hex.EncodeToString(priv)


	account, err := store.NewAccountByPrivAndPass(toString[:64],pass)
	fmt.Println(account,err)

}






 

你可能感兴趣的:(工具)