tendermint/account/priv_account.go

30 lines
608 B
Go
Raw Normal View History

2014-12-17 01:37:13 -08:00
package account
import (
. "github.com/tendermint/tendermint/common"
)
type PrivAccount struct {
2015-01-11 23:12:33 -08:00
Address []byte
PubKey PubKey
PrivKey PrivKey
}
// Generates a new account with private key.
func GenPrivAccount() *PrivAccount {
2015-01-13 21:03:01 -08:00
privKey := PrivKeyEd25519(CRandBytes(32))
return &PrivAccount{
2015-01-13 21:03:01 -08:00
Address: privKey.PubKey().Address(),
PubKey: privKey.PubKey(),
PrivKey: privKey,
}
}
2014-12-17 01:37:13 -08:00
func (privAccount *PrivAccount) Sign(o Signable) Signature {
return privAccount.PrivKey.Sign(SignBytes(o))
}
2015-01-16 00:31:34 -08:00
func (privAccount *PrivAccount) String() string {
return Fmt("PrivAccount{%X}", privAccount.Address)
}