func (u *User) Identity() ([]byte, error) {
	serializedIdentity := &pb_msp.SerializedIdentity{Mspid: u.MspID(),
		IdBytes: u.EnrollmentCertificate()}
	identity, err := proto.Marshal(serializedIdentity)
	if err != nil {
		return nil, errors.Wrap(err, "marshal serializedIdentity failed")
	}
	return identity, nil
}
Identity returns client's serialized identity
package identity
import (
	"github.com/golang/protobuf/proto"
	"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
	pb_msp "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/msp"
	"github.com/pkg/errors"
)
type User struct {
	name                  string
	mspID                 string
	roles                 []string
	privateKey            apicryptosuite.Key
	enrollmentCertificate []byte
}
type JSON struct {
	MspID                 string
	Roles                 []string
	PrivateKeySKI         []byte
	EnrollmentCertificate []byte
}
func NewUser(name string, mspID string) *User {
	return &User{name: name, mspID: mspID}
}
func (u *User) Name() string {
	return u.name
}
func (u *User) Roles() []string {
	return u.roles
}
func (u *User) SetRoles(roles []string) {
	u.roles = roles
}
func (u *User) EnrollmentCertificate() []byte {
	return u.enrollmentCertificate
}
func (u *User) SetEnrollmentCertificate(cert []byte) {
	u.enrollmentCertificate = cert
}
func (u *User) SetPrivateKey(privateKey apicryptosuite.Key) {
	u.privateKey = privateKey
}
func (u *User) PrivateKey() apicryptosuite.Key {
	return u.privateKey
}
func (u *User) SetMspID(mspID string) {
	u.mspID = mspID
}
func (u *User) MspID() string {
	return u.mspID
}