You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
548 B

10 years ago
10 years ago
  1. package account
  2. import (
  3. "github.com/tendermint/go-ed25519"
  4. . "github.com/tendermint/tendermint/common"
  5. )
  6. type PrivAccount struct {
  7. PubKey PubKey
  8. PrivKey PrivKey
  9. }
  10. // Generates a new account with private key.
  11. func GenPrivAccount() *PrivAccount {
  12. privKey := CRandBytes(32)
  13. pubKey := ed25519.MakePubKey(privKey)
  14. return &PrivAccount{
  15. PubKeyEd25519(pubKey),
  16. PrivKeyEd25519{
  17. PubKey: pubKey,
  18. PrivKey: privKey,
  19. },
  20. }
  21. }
  22. func (privAccount *PrivAccount) Sign(o Signable) Signature {
  23. return privAccount.PrivKey.Sign(SignBytes(o))
  24. }