Example #1
0
// 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,
	}
}
Example #2
0
func (v *Validator) Hash() []byte {
	return binary.BinarySha256(v)
}