|
@ -2,6 +2,7 @@ package account |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"github.com/tendermint/ed25519" |
|
|
"github.com/tendermint/ed25519" |
|
|
|
|
|
"github.com/tendermint/tendermint/binary" |
|
|
. "github.com/tendermint/tendermint/common" |
|
|
. "github.com/tendermint/tendermint/common" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
@ -25,6 +26,21 @@ func GenPrivAccount() *PrivAccount { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Generates a new account with private key from SHA256 hash of a secret
|
|
|
|
|
|
func GenPrivAccountFromSecret(secret []byte) *PrivAccount { |
|
|
|
|
|
privKey32 := binary.BinarySha256(secret) |
|
|
|
|
|
privKeyBytes := new([64]byte) |
|
|
|
|
|
copy(privKeyBytes[:32], privKey32) |
|
|
|
|
|
pubKeyBytes := ed25519.MakePublicKey(privKeyBytes) |
|
|
|
|
|
pubKey := PubKeyEd25519(pubKeyBytes[:]) |
|
|
|
|
|
privKey := PrivKeyEd25519(privKeyBytes[:]) |
|
|
|
|
|
return &PrivAccount{ |
|
|
|
|
|
Address: pubKey.Address(), |
|
|
|
|
|
PubKey: pubKey, |
|
|
|
|
|
PrivKey: privKey, |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func GenPrivAccountFromKey(privKeyBytes [64]byte) *PrivAccount { |
|
|
func GenPrivAccountFromKey(privKeyBytes [64]byte) *PrivAccount { |
|
|
pubKeyBytes := ed25519.MakePublicKey(&privKeyBytes) |
|
|
pubKeyBytes := ed25519.MakePublicKey(&privKeyBytes) |
|
|
pubKey := PubKeyEd25519(pubKeyBytes[:]) |
|
|
pubKey := PubKeyEd25519(pubKeyBytes[:]) |
|
|