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.

50 lines
1.2 KiB

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