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.

47 lines
959 B

  1. package account
  2. import (
  3. "errors"
  4. "fmt"
  5. "github.com/tendermint/go-ed25519"
  6. . "github.com/tendermint/tendermint/binary"
  7. . "github.com/tendermint/tendermint/common"
  8. )
  9. // Signature is a part of Txs and consensus Votes.
  10. type Signature interface {
  11. }
  12. // Types of Signature implementations
  13. const (
  14. SignatureTypeEd25519 = byte(0x01)
  15. )
  16. // for binary.readReflect
  17. var _ = RegisterInterface(
  18. struct{ Signature }{},
  19. ConcreteType{SignatureEd25519{}},
  20. )
  21. //-------------------------------------
  22. // Implements Signature
  23. type SignatureEd25519 []byte
  24. func (sig SignatureEd25519) TypeByte() byte { return SignatureTypeEd25519 }
  25. func (sig SignatureEd25519) ValidateBasic() error {
  26. if len(sig) != ed25519.SignatureSize {
  27. return errors.New("Invalid SignatureEd25519 signature size")
  28. }
  29. return nil
  30. }
  31. func (sig SignatureEd25519) IsZero() bool {
  32. return len(sig) == 0
  33. }
  34. func (sig SignatureEd25519) String() string {
  35. return fmt.Sprintf("%X", Fingerprint(sig))
  36. }