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.

40 lines
728 B

  1. package blocks
  2. import (
  3. . "github.com/tendermint/tendermint/binary"
  4. "io"
  5. )
  6. /*
  7. Signature message wire format:
  8. |a...|sss...|
  9. a Account number, varint encoded (1+ bytes)
  10. s Signature of all prior bytes (32 bytes)
  11. It usually follows the message to be signed.
  12. */
  13. type Signature struct {
  14. SignerId uint64
  15. Bytes []byte
  16. }
  17. func ReadSignature(r io.Reader, n *int64, err *error) Signature {
  18. return Signature{
  19. SignerId: ReadUInt64(r, n, err),
  20. Bytes: ReadByteSlice(r, n, err),
  21. }
  22. }
  23. func (sig Signature) IsZero() bool {
  24. return len(sig.Bytes) == 0
  25. }
  26. func (sig Signature) WriteTo(w io.Writer) (n int64, err error) {
  27. WriteUInt64(w, sig.SignerId, &n, &err)
  28. WriteByteSlice(w, sig.Bytes, &n, &err)
  29. return
  30. }