code: func (msg *ReceivedMessage) ValidateAndParse() bool {
  	end := len(msg.Raw)
  	if end < 1 {
  		return false
  	}
  
  	if isMessageSigned(msg.Raw[0]) {
  		end -= signatureLength
  		if end <= 1 {
  			return false
  		}
  		msg.Signature = msg.Raw[end : end+signatureLength]
  		msg.Src = msg.SigToPubKey()
  		if msg.Src == nil {
  			return false
  		}
  	}
  
  	beg := 1
  	payloadSize := 0
  	sizeOfPayloadSizeField := int(msg.Raw[0] & SizeMask) // number of bytes indicating the size of payload
  	if sizeOfPayloadSizeField != 0 {
  		payloadSize = int(bytesToUintLittleEndian(msg.Raw[beg : beg+sizeOfPayloadSizeField]))
  		if payloadSize+1 > end {
  			return false
  		}
  		beg += sizeOfPayloadSizeField
  		msg.Payload = msg.Raw[beg : beg+payloadSize]
  	}
  
  	beg += payloadSize
  	msg.Padding = msg.Raw[beg:end]
  	return true
  }
docs: // ValidateAndParse checks the message validity and extracts the fields in case of success.