fabric: github.com/hyperledger/fabric/core/common/privdata Index | Files

package privdata

import "github.com/hyperledger/fabric/core/common/privdata"

Index

Package Files

collection.go membershipinfo.go simplecollection.go store.go util.go

func BuildCollectionKVSKey Uses

func BuildCollectionKVSKey(ccname string) string

BuildCollectionKVSKey constructs the collection config key for a given chaincode name

func GetCCNameFromCollectionConfigKey Uses

func GetCCNameFromCollectionConfigKey(key string) string

GetCCNameFromCollectionConfigKey returns the chaincode name given a collection config key

func IsCollectionConfigKey Uses

func IsCollectionConfigKey(key string) bool

IsCollectionConfigKey detects if a key is a collection key

func ParseCollectionConfig Uses

func ParseCollectionConfig(colBytes []byte) (*common.CollectionConfigPackage, error)

ParseCollectionConfig parses the collection configuration from the given serialized representation

func RetrieveCollectionConfigPackageFromState Uses

func RetrieveCollectionConfigPackageFromState(cc common.CollectionCriteria, state State) (*common.CollectionConfigPackage, error)

RetrieveCollectionConfigPackageFromState retrieves the collection config package from the given key from the given state

type Collection Uses

type Collection interface {

    // CollectionID returns this collection's ID
    CollectionID() string

    // MemberOrgs returns the collection's members as MSP IDs. This serves as
    // a human-readable way of quickly identifying who is part of a collection.
    MemberOrgs() []string
}

Collection defines a common interface for collections

type CollectionAccessPolicy Uses

type CollectionAccessPolicy interface {
    // AccessFilter returns a member filter function for a collection
    AccessFilter() Filter

    // The minimum number of peers private data will be sent to upon
    // endorsement. The endorsement would fail if dissemination to at least
    // this number of peers is not achieved.
    RequiredPeerCount() int

    // The maximum number of peers that private data will be sent to
    // upon endorsement. This number has to be bigger than RequiredPeerCount().
    MaximumPeerCount() int

    // MemberOrgs returns the collection's members as MSP IDs. This serves as
    // a human-readable way of quickly identifying who is part of a collection.
    MemberOrgs() []string

    // IsMemberOnlyRead returns a true if only collection members can read
    // the private data
    IsMemberOnlyRead() bool
}

CollectionAccessPolicy encapsulates functions for the access policy of a collection

type CollectionFilter Uses

type CollectionFilter interface {
    // AccessFilter retrieves the collection's filter that matches a given channel and a collectionPolicyConfig
    AccessFilter(channelName string, collectionPolicyConfig *common.CollectionPolicyConfig) (Filter, error)
}

type CollectionPersistenceConfigs Uses

type CollectionPersistenceConfigs interface {
    // BlockToLive returns the number of blocks after which the collection data expires.
    // For instance if the value is set to 10, a key last modified by block number 100
    // will be purged at block number 111. A zero value is treated same as MaxUint64
    BlockToLive() uint64
}

CollectionPersistenceConfigs encapsulates configurations related to persistece of a collection

type CollectionStore Uses

type CollectionStore interface {
    // GetCollection retrieves the collection in the following way:
    // If the TxID exists in the ledger, the collection that is returned has the
    // latest configuration that was committed into the ledger before this txID
    // was committed.
    // Else - it's the latest configuration for the collection.
    RetrieveCollection(common.CollectionCriteria) (Collection, error)

    // GetCollectionAccessPolicy retrieves a collection's access policy
    RetrieveCollectionAccessPolicy(common.CollectionCriteria) (CollectionAccessPolicy, error)

    // RetrieveCollectionConfigPackage retrieves the whole configuration package
    // for the chaincode with the supplied criteria
    RetrieveCollectionConfigPackage(common.CollectionCriteria) (*common.CollectionConfigPackage, error)

    // RetrieveCollectionPersistenceConfigs retrieves the collection's persistence related configurations
    RetrieveCollectionPersistenceConfigs(common.CollectionCriteria) (CollectionPersistenceConfigs, error)

    // HasReadAccess checks whether the creator of the signedProposal has read permission on a
    // given collection
    HasReadAccess(common.CollectionCriteria, *pb.SignedProposal, ledger.QueryExecutor) (bool, error)

    CollectionFilter
}

CollectionStore provides various APIs to retrieves stored collections and perform membership check & read permission check based on the collection's properties. TODO: Refactor CollectionStore - FAB-13082 (1) function such as RetrieveCollection() and RetrieveCollectionConfigPackage() are

never used except in mocks and test files.

(2) in gossip, at least in 7 different places, the following 3 operations

are repeated which can be avoided by introducing a API called IsAMemberOf().
    (i)   retrieves collection access policy by calling RetrieveCollectionAccessPolicy()
    (ii)  get the access filter func from the collection access policy
    (iii) create the evaluation policy and check for membership

(3) we would need a cache in collection store to avoid repeated crypto operation.

This would be simple to implement when we introduce IsAMemberOf() APIs.

func NewSimpleCollectionStore Uses

func NewSimpleCollectionStore(s Support) CollectionStore

NewSimpleCollectionStore returns a collection stored backed by a ledger supplied by the specified ledgerGetter with an internal name formed as specified by the supplied collectionNamer function

type Filter Uses

type Filter func(common.SignedData) bool

Filter defines a rule that filters peers according to data signed by them. The Identity in the SignedData is a SerializedIdentity of a peer. The Data is a message the peer signed, and the Signature is the corresponding Signature on that Data. Returns: True, if the policy holds for the given signed data.

False otherwise

type MembershipProvider Uses

type MembershipProvider struct {
    IdentityDeserializerFactory func(chainID string) msp.IdentityDeserializer
    // contains filtered or unexported fields
}

MembershipProvider can be used to check whether a peer is eligible to a collection or not

func NewMembershipInfoProvider Uses

func NewMembershipInfoProvider(selfSignedData common.SignedData, identityDeserializerFunc func(chainID string) msp.IdentityDeserializer) *MembershipProvider

NewMembershipInfoProvider returns MembershipProvider

func (*MembershipProvider) AmMemberOf Uses

func (m *MembershipProvider) AmMemberOf(channelName string, collectionPolicyConfig *common.CollectionPolicyConfig) (bool, error)

AmMemberOf checks whether the current peer is a member of the given collection config. If getPolicy returns an error, it will drop the error and return false - same as a RejectAll policy.

type NoSuchCollectionError Uses

type NoSuchCollectionError common.CollectionCriteria

func (NoSuchCollectionError) Error Uses

func (f NoSuchCollectionError) Error() string

type SimpleCollection Uses

type SimpleCollection struct {
    // contains filtered or unexported fields
}

SimpleCollection implements a collection with static properties and a public member set

func (*SimpleCollection) AccessFilter Uses

func (sc *SimpleCollection) AccessFilter() Filter

AccessFilter returns the member filter function that evaluates signed data against the member access policy of this collection

func (*SimpleCollection) CollectionID Uses

func (sc *SimpleCollection) CollectionID() string

CollectionID returns the collection's ID

func (*SimpleCollection) IsMemberOnlyRead Uses

func (sc *SimpleCollection) IsMemberOnlyRead() bool

func (*SimpleCollection) MaximumPeerCount Uses

func (sc *SimpleCollection) MaximumPeerCount() int

func (*SimpleCollection) MemberOrgs Uses

func (sc *SimpleCollection) MemberOrgs() []string

MemberOrgs returns the MSP IDs that are part of this collection

func (*SimpleCollection) RequiredPeerCount Uses

func (sc *SimpleCollection) RequiredPeerCount() int

RequiredPeerCount returns the minimum number of peers required to send private data to

func (*SimpleCollection) Setup Uses

func (sc *SimpleCollection) Setup(collectionConfig *common.StaticCollectionConfig, deserializer msp.IdentityDeserializer) error

Setup configures a simple collection object based on a given StaticCollectionConfig proto that has all the necessary information

type SimpleCollectionPersistenceConfigs Uses

type SimpleCollectionPersistenceConfigs struct {
    // contains filtered or unexported fields
}

func (*SimpleCollectionPersistenceConfigs) BlockToLive Uses

func (s *SimpleCollectionPersistenceConfigs) BlockToLive() uint64

BlockToLive return collection's block to live configuration

type State Uses

type State interface {
    // GetState retrieves the value for the given key in the given namespace
    GetState(namespace string, key string) ([]byte, error)
}

StateGetter retrieves data from the state

type Support Uses

type Support interface {
    // GetQueryExecutorForLedger returns a query executor for the specified channel
    GetQueryExecutorForLedger(cid string) (ledger.QueryExecutor, error)

    // GetIdentityDeserializer returns an IdentityDeserializer
    // instance for the specified chain
    GetIdentityDeserializer(chainID string) msp.IdentityDeserializer
}

Support is an interface used to inject dependencies

Package privdata imports 13 packages (graph) and is imported by 23 packages. Updated 2019-07-01. Refresh now. Tools for package owners.