tendermint/account/priv_account.go

32 lines
584 B
Go
Raw Normal View History

2014-12-17 01:37:13 -08:00
package account
import (
"github.com/tendermint/go-ed25519"
. "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 {
privKey := CRandBytes(32)
2015-01-11 23:12:33 -08:00
pubKey := PubKeyEd25519(ed25519.MakePubKey(privKey))
return &PrivAccount{
2015-01-11 23:12:33 -08:00
pubKey.Address(),
pubKey,
PrivKeyEd25519{
PubKey: pubKey,
PrivKey: privKey,
},
}
}
2014-12-17 01:37:13 -08:00
func (privAccount *PrivAccount) Sign(o Signable) Signature {
return privAccount.PrivKey.Sign(SignBytes(o))
}