{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package msp\n\nCopyright IBM Corp. All Rights Reserved.\n\nSPDX-License-Identifier: Apache-2.0\n\n## Constants\n\n```go\nconst (\n\tIdemixConfigDirMsp                  = \"msp\"\n\tIdemixConfigDirUser                 = \"user\"\n\tIdemixConfigFileIssuerPublicKey     = \"IssuerPublicKey\"\n\tIdemixConfigFileRevocationPublicKey = \"RevocationPublicKey\"\n\tIdemixConfigFileSigner              = \"SignerConfig\"\n)\n```\n\n```go\nconst (\n\tMSPv1_0 = iota\n\tMSPv1_1\n\tMSPv1_3\n\tMSPv1_4_3\n)\n```\n\n```go\nconst (\n\t// AttributeIndexOU contains the index of the OU attribute in the idemix credential attributes\n\tAttributeIndexOU = iota\n\n\t// AttributeIndexRole contains the index of the Role attribute in the idemix credential attributes\n\tAttributeIndexRole\n\n\t// AttributeIndexEnrollmentId contains the index of the Enrollment ID attribute in the idemix credential attributes\n\tAttributeIndexEnrollmentId\n\n\t// AttributeIndexRevocationHandle contains the index of the Revocation Handle attribute in the idemix credential attributes\n\tAttributeIndexRevocationHandle\n)\n```\n\n```go\nconst (\n\t// AttributeNameOU is the attribute name of the Organization Unit attribute\n\tAttributeNameOU = \"OU\"\n\n\t// AttributeNameRole is the attribute name of the Role attribute\n\tAttributeNameRole = \"Role\"\n\n\t// AttributeNameEnrollmentId is the attribute name of the Enrollment ID attribute\n\tAttributeNameEnrollmentId = \"EnrollmentID\"\n\n\t// AttributeNameRevocationHandle is the attribute name of the revocation handle attribute\n\tAttributeNameRevocationHandle = \"RevocationHandle\"\n)\n```\n\n## Functions\n\n```go\nfunc GetIdemixMspConfig(dir string, ID string) (*msp.MSPConfig, error)\n```\nGetIdemixMspConfig returns the configuration for the Idemix MSP\n\n```go\nfunc GetLocalMspConfig(dir string, bccspConfig *factory.FactoryOpts, ID string) (*msp.MSPConfig, error)\n```\n\n```go\nfunc GetLocalMspConfigWithType(dir string, bccspConfig *factory.FactoryOpts, ID, mspType string) (*msp.MSPConfig, error)\n```\nGetLocalMspConfigWithType returns a local MSP configuration for the MSP in the specified directory, with the specified ID and type\n\n```go\nfunc GetRoleMaskFromIdemixRole(role Role) int\n```\nGetRoleMaskFromIdemixRole return a bitmask for one role\n\n```go\nfunc GetVerifyingMspConfig(dir, ID, mspType string) (*msp.MSPConfig, error)\n```\nGetVerifyingMspConfig returns an MSP config given directory, ID and type\n\n```go\nfunc NewSerializedIdentity(mspID string, certPEM []byte) ([]byte, error)\n```\nNewSerializedIdentity returns a serialized identity having as content the passed mspID and x509 certificate in PEM format. This method does not check the validity of certificate nor any consistency of the mspID with it.\n\n```go\nfunc ProviderTypeToString(id ProviderType) string\n```\nProviderTypeToString returns a string that represents the ProviderType integer\n\n```go\nfunc SetupBCCSPKeystoreConfig(bccspConfig *factory.FactoryOpts, keystoreDir string) *factory.FactoryOpts\n```\n\n## Types\n\n```go\ntype BCCSPNewOpts struct {\n\tNewBaseOpts\n}\n```\nBCCSPNewOpts contains the options to instantiate a new BCCSP-based (X509) MSP\n\n```go\ntype Configuration struct {\n\t// OrganizationalUnitIdentifiers is a list of OUs. If this is set, the MSP\n\t// will consider an identity valid only it contains at least one of these OUs\n\tOrganizationalUnitIdentifiers []*OrganizationalUnitIdentifiersConfiguration `yaml:\"OrganizationalUnitIdentifiers,omitempty\"`\n\t// NodeOUs enables the MSP to tell apart clients, peers and orderers based\n\t// on the identity's OU.\n\tNodeOUs *NodeOUs `yaml:\"NodeOUs,omitempty\"`\n}\n```\nConfiguration represents the accessory configuration an MSP can be equipped with. By default, this configuration is stored in a yaml file\n\n```go\ntype IdemixNewOpts struct {\n\tNewBaseOpts\n}\n```\nIdemixNewOpts contains the options to instantiate a new Idemix-based MSP\n\n```go\ntype Identity interface {\n\n\t// ExpiresAt returns the time at which the Identity expires.\n\t// If the returned time is the zero value, it implies\n\t// the Identity does not expire, or that its expiration\n\t// time is unknown\n\tExpiresAt() time.Time\n\n\t// GetIdentifier returns the identifier of that identity\n\tGetIdentifier() *IdentityIdentifier\n\n\t// GetMSPIdentifier returns the MSP Id for this instance\n\tGetMSPIdentifier() string\n\n\t// Validate uses the rules that govern this identity to validate it.\n\t// E.g., if it is a fabric TCert implemented as identity, validate\n\t// will check the TCert signature against the assumed root certificate\n\t// authority.\n\tValidate() error\n\n\t// GetOrganizationalUnits returns zero or more organization units or\n\t// divisions this identity is related to as long as this is public\n\t// information. Certain MSP implementations may use attributes\n\t// that are publicly associated to this identity, or the identifier of\n\t// the root certificate authority that has provided signatures on this\n\t// certificate.\n\t// Examples:\n\t//  - if the identity is an x.509 certificate, this function returns one\n\t//    or more string which is encoded in the Subject's Distinguished Name\n\t//    of the type OU\n\t// TODO: For X.509 based identities, check if we need a dedicated type\n\t//       for OU where the Certificate OU is properly namespaced by the\n\t//       signer's identity\n\tGetOrganizationalUnits() []*OUIdentifier\n\n\t// Anonymous returns true if this is an anonymous identity, false otherwise\n\tAnonymous() bool\n\n\t// Verify a signature over some message using this identity as reference\n\tVerify(msg []byte, sig []byte) error\n\n\t// Serialize converts an identity to bytes\n\tSerialize() ([]byte, error)\n\n\t// SatisfiesPrincipal checks whether this instance matches\n\t// the description supplied in MSPPrincipal. The check may\n\t// involve a byte-by-byte comparison (if the principal is\n\t// a serialized identity) or may require MSP validation\n\tSatisfiesPrincipal(principal *msp.MSPPrincipal) error\n}\n```\nIdentity interface defining operations associated to a \"certificate\". That is, the public part of the identity could be thought to be a certificate, and offers solely signature verification capabilities. This is to be used at the peer side when verifying certificates that transactions are signed with, and verifying signatures that correspond to these certificates.///\n\n```go\ntype IdentityDeserializer interface {\n\t// DeserializeIdentity deserializes an identity.\n\t// Deserialization will fail if the identity is associated to\n\t// an msp that is different from this one that is performing\n\t// the deserialization.\n\tDeserializeIdentity(serializedIdentity []byte) (Identity, error)\n\n\t// IsWellFormed checks if the given identity can be deserialized into its provider-specific form\n\tIsWellFormed(identity *msp.SerializedIdentity) error\n}\n```\nIdentityDeserializer is implemented by both MSPManger and MSP\n\n```go\ntype IdentityIdentifier struct {\n\n\t// The identifier of the associated membership service provider\n\tMspid string\n\n\t// The identifier for an identity within a provider\n\tId string\n}\n```\nIdentityIdentifier is a holder for the identifier of a specific identity, naturally namespaced, by its provider identifier.\n\n```go\ntype MSP interface {\n\n\t// IdentityDeserializer interface needs to be implemented by MSP\n\tIdentityDeserializer\n\n\t// Setup the MSP instance according to configuration information\n\tSetup(config *msp.MSPConfig) error\n\n\t// GetVersion returns the version of this MSP\n\tGetVersion() MSPVersion\n\n\t// GetType returns the provider type\n\tGetType() ProviderType\n\n\t// GetIdentifier returns the provider identifier\n\tGetIdentifier() (string, error)\n\n\t// GetSigningIdentity returns a signing identity corresponding to the provided identifier\n\tGetSigningIdentity(identifier *IdentityIdentifier) (SigningIdentity, error)\n\n\t// GetDefaultSigningIdentity returns the default signing identity\n\tGetDefaultSigningIdentity() (SigningIdentity, error)\n\n\t// GetTLSRootCerts returns the TLS root certificates for this MSP\n\tGetTLSRootCerts() [][]byte\n\n\t// GetTLSIntermediateCerts returns the TLS intermediate root certificates for this MSP\n\tGetTLSIntermediateCerts() [][]byte\n\n\t// Validate checks whether the supplied identity is valid\n\tValidate(id Identity) error\n\n\t// SatisfiesPrincipal checks whether the identity matches\n\t// the description supplied in MSPPrincipal. The check may\n\t// involve a byte-by-byte comparison (if the principal is\n\t// a serialized identity) or may require MSP validation\n\tSatisfiesPrincipal(id Identity, principal *msp.MSPPrincipal) error\n}\n```\nMSP is the minimal Membership Service Provider Interface to be implemented to accommodate peer functionality\n\n```go\nfunc New(opts NewOpts) (MSP, error)\n```\nNew create a new MSP instance depending on the passed Opts\n\n```go\ntype MSPManager interface {\n\n\t// IdentityDeserializer interface needs to be implemented by MSPManager\n\tIdentityDeserializer\n\n\t// Setup the MSP manager instance according to configuration information\n\tSetup(msps []MSP) error\n\n\t// GetMSPs Provides a list of Membership Service providers\n\tGetMSPs() (map[string]MSP, error)\n}\n```\nMSPManager is an interface defining a manager of one or more MSPs. This essentially acts as a mediator to MSP calls and routes MSP related calls to the appropriate MSP. This object is immutable, it is initialized once and never changed.\n\n```go\nfunc NewMSPManager() MSPManager\n```\nNewMSPManager returns a new MSP manager instance; note that this instance is not initialized until the Setup method is called\n\n```go\ntype MSPVersion int\n```\n\n```go\ntype NewBaseOpts struct {\n\tVersion MSPVersion\n}\n```\nNewBaseOpts is the default base type for all MSP instantiation Opts\n\n```go\nfunc (o *NewBaseOpts) GetVersion() MSPVersion\n```\n\n```go\ntype NewOpts interface {\n\t// GetVersion returns the MSP's version to be instantiated\n\tGetVersion() MSPVersion\n}\n```\nNewOpts represent\n\n```go\ntype NodeOUs struct {\n\t// Enable activates the OU enforcement\n\tEnable bool `yaml:\"Enable,omitempty\"`\n\t// ClientOUIdentifier specifies how to recognize clients by OU\n\tClientOUIdentifier *OrganizationalUnitIdentifiersConfiguration `yaml:\"ClientOUIdentifier,omitempty\"`\n\t// PeerOUIdentifier specifies how to recognize peers by OU\n\tPeerOUIdentifier *OrganizationalUnitIdentifiersConfiguration `yaml:\"PeerOUIdentifier,omitempty\"`\n\t// AdminOUIdentifier specifies how to recognize admins by OU\n\tAdminOUIdentifier *OrganizationalUnitIdentifiersConfiguration `yaml:\"AdminOUIdentifier,omitempty\"`\n\t// OrdererOUIdentifier specifies how to recognize admins by OU\n\tOrdererOUIdentifier *OrganizationalUnitIdentifiersConfiguration `yaml:\"OrdererOUIdentifier,omitempty\"`\n}\n```\nNodeOUs contains information on how to tell apart clients, peers and orderers based on OUs. If the check is enforced, by setting Enabled to true, the MSP will consider an identity valid if it is an identity of a client, a peer or an orderer. An identity should have only one of these special OUs.\n\n```go\ntype OUIdentifier struct {\n\t// CertifiersIdentifier is the hash of certificates chain of trust\n\t// related to this organizational unit\n\tCertifiersIdentifier []byte\n\t// OrganizationUnitIdentifier defines the organizational unit under the\n\t// MSP identified with MSPIdentifier\n\tOrganizationalUnitIdentifier string\n}\n```\nOUIdentifier represents an organizational unit and its related chain of trust identifier.\n\n```go\ntype OrganizationalUnitIdentifiersConfiguration struct {\n\t// Certificate is the path to a root or intermediate certificate\n\tCertificate string `yaml:\"Certificate,omitempty\"`\n\t// OrganizationalUnitIdentifier is the name of the OU\n\tOrganizationalUnitIdentifier string `yaml:\"OrganizationalUnitIdentifier,omitempty\"`\n}\n```\nOrganizationalUnitIdentifiersConfiguration is used to represent an OU and an associated trusted certificate\n\n```go\ntype ProviderType int\n```\nProviderType indicates the type of an identity provider\n\n```go\nconst (\n\tFABRIC ProviderType = iota // MSP is of FABRIC type\n\tIDEMIX                     // MSP is of IDEMIX type\n\tOTHER                      // MSP is of OTHER TYPE\n\n)\n```\nThe ProviderType of a member relative to the member API\n\n```go\ntype Role int32\n```\nRole : Represents a IdemixRole\n\n```go\nconst (\n\tMEMBER Role = 1\n\tADMIN  Role = 2\n\tCLIENT Role = 4\n\tPEER   Role = 8\n)\n```\nThe expected roles are 4; We can combine them using a bitmask\n\n```go\ntype SigningIdentity interface {\n\n\t// Extends Identity\n\tIdentity\n\n\t// Sign the message\n\tSign(msg []byte) ([]byte, error)\n\n\t// GetPublicVersion returns the public parts of this identity\n\tGetPublicVersion() Identity\n}\n```\nSigningIdentity is an extension of Identity to cover signing capabilities. E.g., signing identity should be requested in the case of a client who wishes to sign transactions, or fabric endorser who wishes to sign proposal processing outcomes.\n\n","path":"github.com/eric-erki/https-hyperledger.org/msp","name":"msp","synopsis":"","isRedistributable":true}
