code: func (id *identity) Serialize() ([]byte, error) {
  	// mspIdentityLogger.Infof("Serializing identity %s", id.id)
  
  	pb := &pem.Block{Bytes: id.cert.Raw, Type: "CERTIFICATE"}
  	pemBytes := pem.EncodeToMemory(pb)
  	if pemBytes == nil {
  		return nil, errors.New("encoding of identity failed")
  	}
  
  	// We serialize identities by prepending the MSPID and appending the ASN.1 DER content of the cert
  	sId := &msp.SerializedIdentity{Mspid: id.id.Mspid, IdBytes: pemBytes}
  	idBytes, err := proto.Marshal(sId)
  	if err != nil {
  		return nil, errors.Wrapf(err, "could not marshal a SerializedIdentity structure for identity %s", id.id)
  	}
  
  	return idBytes, nil
  }
docs: // Serialize returns a byte array representation of this identity