Documentation
¶
Overview ¶
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- func CheckRole(bitmask int, role Role) bool
- func GetIdemixMspConfig(dir string, ID string) (*m.MSPConfig, error)
- func GetIdemixMspConfigWithType(dir string, ID string, mspType ProviderType) (*m.MSPConfig, error)deprecated
- func GetRoleMaskFromIdemixRole(role Role) int
- func ProviderTypeToString(id ProviderType) string
- type CryptoScheme
- type IdemixSigningIdentity
- type Idemixidentity
- type Idemixmsp
- type Identity
- type IdentityDeserializer
- type IdentityIdentifier
- type Logger
- type MSP
- func (msp *MSP) DeserializeIdentity(serializedID []byte) (Identity, error)
- func (msp *MSP) DeserializeIdentityInternal(serializedID []byte) (Identity, error)
- func (msp *MSP) DeserializeSigningIdentity(raw []byte) (SigningIdentity, error)
- func (msp *MSP) EnrollmentID() string
- func (msp *MSP) GetDefaultSigningIdentity() (SigningIdentity, error)
- func (msp *MSP) GetIdentifier() (string, error)
- func (msp *MSP) GetTLSIntermediateCerts() [][]byte
- func (msp *MSP) GetTLSRootCerts() [][]byte
- func (msp *MSP) GetType() ProviderType
- func (msp *MSP) GetVersion() MSPVersion
- func (msp *MSP) IsWellFormed(identity *m.SerializedIdentity) error
- func (msp *MSP) IssuerPublicKey() []byte
- func (msp *MSP) Pseudonym() (SigningIdentity, []byte, error)
- func (msp *MSP) SatisfiesPrincipal(id Identity, principal *m.MSPPrincipal) error
- func (msp *MSP) Scheme() CryptoScheme
- func (msp *MSP) Setup(conf1 *m.MSPConfig) error
- func (msp *MSP) Validate(id Identity) error
- type MSPVersion
- type OUIdentifier
- type Provider
- func NewIdemixMsp(version MSPVersion) (Provider, error)
- func NewIdemixMspAries(version MSPVersion) (Provider, error)deprecated
- func NewIdemixMspAriesWithLogger(version MSPVersion, logger Logger) (Provider, error)deprecated
- func NewIdemixMspWithLogger(version MSPVersion, logger Logger) (Provider, error)
- type ProviderType
- type Role
- type SigningIdentity
Constants ¶
const ( IdemixConfigDirMsp = "msp" IdemixConfigDirUser = "user" IdemixConfigFileIssuerPublicKey = "IssuerPublicKey" IdemixConfigFileRevocationPublicKey = "RevocationPublicKey" IdemixConfigFileSigner = "SignerConfig" )
const ( // AttributeIndexOU contains the index of the OU attribute in the idemix credential attributes AttributeIndexOU = iota // AttributeIndexRole contains the index of the Role attribute in the idemix credential attributes AttributeIndexRole // AttributeIndexEnrollmentId contains the index of the Enrollment ID attribute in the idemix credential attributes AttributeIndexEnrollmentId // AttributeIndexRevocationHandle contains the index of the Revocation Handle attribute in the idemix credential attributes AttributeIndexRevocationHandle )
const ( // AttributeNameOU is the attribute name of the Organization Unit attribute AttributeNameOU = "OU" // AttributeNameRole is the attribute name of the Role attribute AttributeNameRole = "Role" // AttributeNameEnrollmentId is the attribute name of the Enrollment ID attribute AttributeNameEnrollmentId = "EnrollmentID" // AttributeNameRevocationHandle is the attribute name of the revocation handle attribute AttributeNameRevocationHandle = "RevocationHandle" )
const ( MSPv1_0 = iota MSPv1_1 MSPv1_3 MSPv1_4_3 )
Variables ¶
This section is empty.
Functions ¶
func CheckRole ¶ added in v0.4.0
CheckRole Prove that the desired role is contained or not in the bitmask
func GetIdemixMspConfig ¶
GetIdemixMspConfig returns the configuration for the Idemix MSP
func GetIdemixMspConfigWithType
deprecated
GetIdemixMspConfigWithType returns the configuration for the Idemix MSP of the specified type. The curve is taken from the curve_id field of the signer config (written by idemixgen); when there is no signer config, or it names no curve, IdemixMSPConfig.CurveId is left empty and Setup uses the per-scheme default. Callers of a verification-only MSP on a non-default curve must set IdemixMSPConfig.CurveId themselves.
Deprecated: IDEMIX_ARIES is accepted as an alias of IDEMIX; use GetIdemixMspConfig.
func GetRoleMaskFromIdemixRole ¶
GetRoleMaskFromIdemixRole return a bitmask for one role
func ProviderTypeToString ¶
func ProviderTypeToString(id ProviderType) string
ProviderTypeToString returns a string that represents the ProviderType integer
Types ¶
type CryptoScheme ¶ added in v0.4.0
type CryptoScheme string
CryptoScheme identifies the cryptographic scheme an MSP was set up with.
const ( // SchemeDlog is the legacy Idemix discrete-log scheme. SchemeDlog CryptoScheme = "dlog" // SchemeAries is the Aries/BBS+ scheme. SchemeAries CryptoScheme = "aries" )
type IdemixSigningIdentity ¶
type IdemixSigningIdentity = signingIdentity
Aliases for the v0.3.1 type names.
type Identity ¶
type Identity interface {
// ExpiresAt returns the time at which the Identity expires.
// If the returned time is the zero value, it implies
// the Identity does not expire, or that its expiration
// time is unknown
ExpiresAt() time.Time
// GetIdentifier returns the identifier of that identity
GetIdentifier() *IdentityIdentifier
// GetMSPIdentifier returns the MSP Id for this instance
GetMSPIdentifier() string
// Validate uses the rules that govern this identity to validate it.
// E.g., if it is a fabric TCert implemented as identity, validate
// will check the TCert signature against the assumed root certificate
// authority.
Validate() error
// GetOrganizationalUnits returns zero or more organization units or
// divisions this identity is related to as long as this is public
// information. Certain MSP implementations may use attributes
// that are publicly associated to this identity, or the identifier of
// the root certificate authority that has provided signatures on this
// certificate.
// Examples:
// - if the identity is an x.509 certificate, this function returns one
// or more string which is encoded in the Subject's Distinguished Name
// of the type OU
// TODO: For X.509 based identities, check if we need a dedicated type
// for OU where the Certificate OU is properly namespaced by the
// signer's identity
GetOrganizationalUnits() []*OUIdentifier
// Anonymous returns true if this is an anonymous identity, false otherwise
Anonymous() bool
// Verify a signature over some message using this identity as reference
Verify(msg []byte, sig []byte) error
// Serialize converts an identity to bytes
Serialize() ([]byte, error)
// SatisfiesPrincipal checks whether this instance matches
// the description supplied in MSPPrincipal. The check may
// involve a byte-by-byte comparison (if the principal is
// a serialized identity) or may require MSP validation
SatisfiesPrincipal(principal *m.MSPPrincipal) error
}
Identity 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.///
type IdentityDeserializer ¶
type IdentityDeserializer interface {
// DeserializeIdentity deserializes an identity.
// Deserialization will fail if the identity is associated to
// an msp that is different from this one that is performing
// the deserialization.
DeserializeIdentity(serializedIdentity []byte) (Identity, error)
// IsWellFormed checks if the given identity can be deserialized into its provider-specific form
IsWellFormed(identity *m.SerializedIdentity) error
}
IdentityDeserializer is implemented by both MSPManger and MSP
type IdentityIdentifier ¶
type IdentityIdentifier struct {
// The identifier of the associated membership service provider
Mspid string
// The identifier for an identity within a provider
Id string
}
IdentityIdentifier is a holder for the identifier of a specific identity, naturally namespaced, by its provider identifier.
type Logger ¶
type Logger interface {
Debug(args ...any)
Debugf(format string, args ...any)
Errorf(format string, args ...any)
IsEnabledFor(level zapcore.Level) bool
}
Logger defines the logging interface required by msp. This interface is compatible with the Go SDK log package and common logging facades.
type MSP ¶
type MSP struct {
// contains filtered or unexported fields
}
func NewMSP ¶ added in v0.4.0
func NewMSP(version MSPVersion) (*MSP, error)
NewMSP creates a new instance of msp. Setup auto-detects the underlying cryptographic scheme (dlog or Aries/BBS+) from the key material in the config: it first attempts to load the config using the dlog scheme and, if that fails, retries using the Aries/BBS+ scheme. Any curve supported by curveAndTranslator is accepted by either scheme; the curve is determined at Setup time from IdemixMSPConfig.CurveId (default: FP256BN_AMCL for dlog, BLS12_381_BBS for Aries).
func NewMSPWithKeyStore ¶ added in v0.4.0
NewMSPWithKeyStore creates a new instance of idemixmsp with a custom logger and a custom keystore.KVS used to persist imported/derived keys. See NewMSP for the scheme auto-detection and curve-selection behavior of Setup. If logger is nil, the default logger is used. If kvs is nil, a non-persistent keystore.Dummy is used.
func NewMSPWithLogger ¶ added in v0.4.0
func NewMSPWithLogger(version MSPVersion, logger Logger) (*MSP, error)
NewMSPWithLogger creates a new instance of idemixmsp with a custom logger. See NewMSP for the scheme auto-detection and curve-selection behavior of Setup. If logger is nil, the default logger is used.
func (*MSP) DeserializeIdentity ¶ added in v0.4.0
func (*MSP) DeserializeIdentityInternal ¶ added in v0.4.0
DeserializeIdentityInternal deserializes the inner SerializedIdemixIdentity bytes.
func (*MSP) DeserializeSigningIdentity ¶ added in v0.4.0
func (msp *MSP) DeserializeSigningIdentity(raw []byte) (SigningIdentity, error)
DeserializeSigningIdentity rebuilds a SigningIdentity from a serialized identity (the inner SerializedIdemixIdentity bytes) previously produced by this MSP's default signer (or Pseudonym). It requires the MSP to have been created with a persistent keystore.KVS (NewMSPWithKeyStore), because the nym secret key is looked up by the SKI of the identity's nym public key. raw is either the output of Serialize or the inner SerializedIdemixIdentity bytes. The identity must carry the default signer's OU and role, its association proof must verify, and the nym secret key found in the KVS must belong to the default signer's user secret key. The KVS is expected to hold the keys of a single user.
func (*MSP) EnrollmentID ¶ added in v0.4.0
func (*MSP) GetDefaultSigningIdentity ¶
func (msp *MSP) GetDefaultSigningIdentity() (SigningIdentity, error)
func (*MSP) GetIdentifier ¶
func (*MSP) GetTLSIntermediateCerts ¶
func (*MSP) GetTLSRootCerts ¶
func (*MSP) GetType ¶
func (msp *MSP) GetType() ProviderType
func (*MSP) GetVersion ¶
func (msp *MSP) GetVersion() MSPVersion
GetVersion returns the version of this MSP
func (*MSP) IsWellFormed ¶ added in v0.4.0
func (msp *MSP) IsWellFormed(identity *m.SerializedIdentity) error
IsWellFormed checks if the given identity can be deserialized into its provider-specific form. In this MSP implementation, an identity is considered well formed if it contains a marshaled SerializedIdemixIdentity protobuf message that passes the same structural checks as DeserializeIdentity (pseudonym coordinates of the right size, parsable OU and role, defined role). No cryptographic check is performed.
func (*MSP) IssuerPublicKey ¶ added in v0.4.0
func (*MSP) Pseudonym ¶ added in v0.4.0
func (msp *MSP) Pseudonym() (SigningIdentity, []byte, error)
Pseudonym derives a fresh pseudonym from the default signer. The returned byte slice is reserved and currently always nil. When the MSP is backed by a keystore.KVS, each successful call persists a new nym secret key (there is no deletion path, so the store grows with every call) so that DeserializeSigningIdentity can recover it. Nym secret keys are created exportable and stored in clear in the caller-supplied KVS: it must be protected accordingly.
func (*MSP) SatisfiesPrincipal ¶
func (msp *MSP) SatisfiesPrincipal(id Identity, principal *m.MSPPrincipal) error
func (*MSP) Scheme ¶ added in v0.4.0
func (msp *MSP) Scheme() CryptoScheme
Scheme returns the cryptographic scheme detected by Setup: SchemeDlog or SchemeAries. It is empty before a successful Setup.
type MSPVersion ¶
type MSPVersion int
type OUIdentifier ¶
type OUIdentifier struct {
// CertifiersIdentifier is the hash of certificates chain of trust
// related to this organizational unit
CertifiersIdentifier []byte
// OrganizationUnitIdentifier defines the organizational unit under the
// MSP identified with MSPIdentifier
OrganizationalUnitIdentifier string
}
OUIdentifier represents an organizational unit and its related chain of trust identifier.
type Provider ¶ added in v0.4.0
type Provider interface {
IdentityDeserializer
Setup(config *m.MSPConfig) error
GetVersion() MSPVersion
GetType() ProviderType
GetIdentifier() (string, error)
GetDefaultSigningIdentity() (SigningIdentity, error)
GetTLSRootCerts() [][]byte
GetTLSIntermediateCerts() [][]byte
Validate(id Identity) error
SatisfiesPrincipal(id Identity, principal *m.MSPPrincipal) error
}
Provider is the Membership Service Provider interface (named MSP in idemix v0.3.1 and earlier). It is satisfied by *MSP.
func NewIdemixMsp ¶
func NewIdemixMsp(version MSPVersion) (Provider, error)
NewIdemixMsp is like NewMSP but returns the Provider interface. Setup auto-detects the scheme (dlog or Aries/BBS+).
func NewIdemixMspAries
deprecated
func NewIdemixMspAries(version MSPVersion) (Provider, error)
NewIdemixMspAries is equivalent to NewIdemixMsp: the scheme is auto-detected at Setup.
Deprecated: use NewIdemixMsp.
func NewIdemixMspAriesWithLogger
deprecated
added in
v0.2.0
func NewIdemixMspAriesWithLogger(version MSPVersion, logger Logger) (Provider, error)
NewIdemixMspAriesWithLogger is equivalent to NewIdemixMspWithLogger.
Deprecated: use NewIdemixMspWithLogger.
func NewIdemixMspWithLogger ¶ added in v0.2.0
func NewIdemixMspWithLogger(version MSPVersion, logger Logger) (Provider, error)
NewIdemixMspWithLogger is like NewMSPWithLogger but returns the Provider interface.
type ProviderType ¶
type ProviderType int
ProviderType indicates the type of an identity provider
const ( FABRIC ProviderType = iota // MSP is of FABRIC type IDEMIX // MSP is of IDEMIX type // Deprecated: IDEMIX_ARIES is accepted as an alias of IDEMIX; Setup detects the scheme. IDEMIX_ARIES OTHER // MSP is of OTHER TYPE )
The ProviderType of a member relative to the member API
type SigningIdentity ¶
type SigningIdentity interface {
// Extends Identity
Identity
// Sign the message
Sign(msg []byte) ([]byte, error)
// GetPublicVersion returns the public parts of this identity
GetPublicVersion() Identity
}
SigningIdentity 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.