Module 2: Identity and Membership in Hyperledger Fabric
2.3 Identity and Membership
Identity and membership are foundational concepts in Hyperledger Fabric. As a permissioned blockchain platform, Fabric requires all participants to have identifiable and verifiable identities, which are then used to determine their permissions and access rights within the network.
PKI Infrastructure
Hyperledger Fabric uses a Public Key Infrastructure (PKI) to provide authentication and encryption services. PKI is a set of roles, policies, hardware, software, and procedures needed to create, manage, distribute, use, store, and revoke digital certificates.
Public Key Cryptography Basics
Public key cryptography (also known as asymmetric cryptography) uses a pair of keys:
- Private Key: Kept secret by the owner
- Public Key: Freely shared with others
These keys have a mathematical relationship such that: - Data encrypted with the public key can only be decrypted with the private key - Data signed with the private key can be verified using the public key
PKI Components in Fabric
- Certificate Authorities (CAs)
- Issue and manage digital certificates
- Verify the identity of certificate requestors
- Maintain certificate revocation lists
-
Can be hierarchical (root CAs and intermediate CAs)
-
Digital Certificates
- Bind an identity to a public key
- Contain information about the identity and the issuing CA
- Signed by the issuing CA to prove authenticity
-
Follow the X.509 standard in Fabric
-
Certificate Revocation Lists (CRLs)
- Lists of certificates that have been revoked
- Used to check if a certificate is still valid
- Maintained by CAs
-
Regularly updated and distributed
-
Registration Authorities (RAs)
- Optional component that handles the registration process
- Verifies the identity of certificate requestors
- Forwards approved requests to the CA
- Reduces the workload on the CA
X.509 Certificates
X.509 certificates are the standard format for digital certificates used in Hyperledger Fabric. They provide a way to verify the identity of network participants and components.
Certificate Structure
An X.509 certificate typically includes:
- Version: Certificate format version
- Serial Number: Unique identifier assigned by the CA
- Signature Algorithm: Algorithm used by the CA to sign the certificate
- Issuer: Name of the CA that issued the certificate
- Validity Period: Start and end dates for certificate validity
- Subject: Identity of the certificate owner
- Subject Public Key Info: Owner's public key and algorithm
- Extensions: Additional information like key usage, alternative names
- Certificate Signature: Digital signature created by the CA
Certificate Types in Fabric
Fabric uses different types of certificates for different purposes:
- Enrollment Certificates (ECerts)
- Long-term identity certificates
- Identify components and users in the network
- Used for transaction signing and authentication
-
Issued by the organization's CA
-
Transaction Certificates (TCerts)
- Optional short-term certificates
- Derived from ECerts
- Provide an additional layer of privacy
-
Can include specific attributes for fine-grained access control
-
TLS Certificates
- Used for secure communication between components
- Authenticate network endpoints
- Encrypt communication channels
- Issued by a TLS CA (which can be separate from the enrollment CA)
Certificate Lifecycle
The lifecycle of a certificate in Fabric includes:
- Registration: Identity is registered with the CA
- Enrollment: Certificate is issued to the identity
- Usage: Certificate is used for authentication and authorization
- Renewal: Certificate is renewed before expiration
- Revocation: Certificate is revoked if compromised or no longer needed
Identity Management
Identity management in Hyperledger Fabric involves the processes and tools used to create, maintain, and terminate identities within the network.
Identity Components
An identity in Fabric consists of:
- Digital Certificate: X.509 certificate binding the identity to a public key
- Private Key: Corresponding private key (stored securely)
- Attributes: Optional information about the identity (role, organization, etc.)
- Privileges: Permissions associated with the identity
Fabric CA
Hyperledger Fabric provides a built-in CA server (Fabric CA) that can be used to manage identities. Key features include:
- RESTful API: For certificate management operations
- Web UI: Optional interface for administration
- Identity Registration: Register new identities with attributes
- Certificate Issuance: Issue certificates to registered identities
- Certificate Renewal: Renew certificates before expiration
- Certificate Revocation: Revoke compromised certificates
- Attribute-Based Access Control: Include attributes in certificates for fine-grained access control
External CAs
Organizations can also use external CAs instead of Fabric CA. Requirements for external CAs:
- Must issue X.509 certificates
- Must support certificate revocation
- Must be able to include required attributes in certificates
- Must be trusted by all network participants
Identity Bootstrapping
The process of bootstrapping identities in a Fabric network involves:
- Setting up CAs: Deploy and configure CAs for each organization
- Creating Admin Identities: Generate certificates for administrative users
- Registering Components: Register peers, orderers, and other components
- Enrolling Components: Issue certificates to registered components
- Configuring MSPs: Set up MSPs to recognize the CAs and identities
Access Control and Policies
Access control in Hyperledger Fabric is implemented through policies that define who can perform specific actions within the network.
Policy Types
Fabric uses several types of policies:
- Signature Policies
- Based on digital signatures from specific identities
- Can use logical expressions (AND, OR, NOutOf)
-
Example: "Org1.admin AND Org2.admin" requires signatures from both organizations' admins
-
ImplicitMeta Policies
- Reference other policies within the configuration
- Use rules like "MAJORITY of Admins" or "ANY of Readers"
-
Simplify policy management in multi-organization networks
-
Channel Policies
- Control channel configuration and management
- Define who can create or modify channels
-
Specify who can add organizations to channels
-
Chaincode Policies
- Endorsement Policies: Specify which peers must endorse transactions
- Lifecycle Policies: Control chaincode deployment and updates
- Instantiation Policies: Define who can instantiate chaincode
Policy Evaluation
When an action is attempted, the relevant policy is evaluated:
- The action is accompanied by a set of signatures
- The policy specifies which identities must sign
- The signatures are verified against the specified identities
- If the signatures satisfy the policy, the action is allowed
- If not, the action is rejected
Role-Based Access Control
Fabric supports role-based access control through:
- Organizational Roles: Admin, Member, Client, Peer
- Custom Roles: Defined using attributes in certificates
- Organizational Units (OUs): Subdivisions within organizations
Policy Examples
Channel Creation Policy:
OutOf(2, 'Org1.admin', 'Org2.admin', 'Org3.admin')
This requires signatures from at least 2 out of the 3 organization admins.
Chaincode Endorsement Policy:
AND('Org1.peer', 'Org2.peer')
This requires endorsements from peers in both Org1 and Org2.
Channel Modification Policy:
MAJORITY Admins
This requires signatures from a majority of the admin identities across all organizations in the channel.
Understanding identity and membership is crucial for implementing secure and properly governed Hyperledger Fabric networks. These concepts form the foundation for access control, transaction validation, and overall network security.