docs: def num2bytes(value, size):
      """Convert an unsigned integer to MSB-first bytes with specified size."""
      res = []
      for _ in range(size):
          res.append(value & 0xFF)
          value = value >> 8
      assert value == 0
      return bytes(bytearray(list(reversed(res))))