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.

31 lines
564 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{
  16. PubKey: pubKey,
  17. },
  18. PrivKeyEd25519{
  19. PubKey: pubKey,
  20. PrivKey: privKey,
  21. },
  22. }
  23. }
  24. func (privAccount *PrivAccount) Sign(o Signable) Signature {
  25. return privAccount.PrivKey.Sign(SignBytes(o))
  26. }