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.

63 lines
1.2 KiB

  1. package blocks
  2. import (
  3. . "github.com/tendermint/tendermint/binary"
  4. "io"
  5. )
  6. // NOTE: consensus/Validator embeds this, so..
  7. type Account struct {
  8. Id uint64 // Numeric id of account, incrementing.
  9. PubKey []byte
  10. }
  11. func (self *Account) Verify(msg []byte, sig []byte) bool {
  12. return false
  13. }
  14. //-----------------------------------------------------------------------------
  15. type PrivAccount struct {
  16. Account
  17. PrivKey []byte
  18. }
  19. func (self *PrivAccount) Sign(msg []byte) Signature {
  20. return Signature{}
  21. }
  22. //-----------------------------------------------------------------------------
  23. /*
  24. Signature message wire format:
  25. |A...|SSS...|
  26. A account number, varint encoded (1+ bytes)
  27. S signature of all prior bytes (32 bytes)
  28. It usually follows the message to be signed.
  29. */
  30. type Signature struct {
  31. SignerId uint64
  32. Bytes []byte
  33. }
  34. func ReadSignature(r io.Reader, n *int64, err *error) Signature {
  35. return Signature{
  36. SignerId: ReadUInt64(r, n, err),
  37. Bytes: ReadByteSlice(r, n, err),
  38. }
  39. }
  40. func (sig Signature) IsZero() bool {
  41. return len(sig.Bytes) == 0
  42. }
  43. func (sig Signature) WriteTo(w io.Writer) (n int64, err error) {
  44. WriteUInt64(w, sig.SignerId, &n, &err)
  45. WriteByteSlice(w, sig.Bytes, &n, &err)
  46. return
  47. }