You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Hyperledger Fabric私钥存储机制及隐私求和场景的安全问询

Hey there, let's tackle your Hyperledger Fabric questions one by one—these are really important considerations for building secure, privacy-focused networks.

1. How are private keys stored in Hyperledger Fabric?

Private key storage in Fabric varies depending on which component is using the key, but here's a breakdown of the most common setups:

  • Peer & Orderer Nodes: Out of the box, node private keys (used for signing blocks, transactions, and identity assertions) are stored in the local filesystem—usually under the crypto-config directory generated by the cryptogen tool, saved as PEM files. For development, basic file system permissions are enough, but in production, you should absolutely use a Hardware Security Module (HSM) or a managed key vault (like HashiCorp Vault) via Fabric's PKCS#11 integration. This keeps keys off disk entirely, accessible only through secure hardware interfaces that resist tampering.

  • User/Client Wallets: For end users or client apps interacting with the network, private keys live in wallets. Fabric offers several options here:

    • File System Wallet: The default for dev work, stores encrypted key files on disk (protected by a user-set password).
    • HSM Wallet: Integrates directly with HSMs, so keys never touch untrusted storage—perfect for production where key theft is a top concern.
    • Cloud-Managed Wallets: Many cloud providers offer Fabric-compatible wallets that handle key storage and rotation in secure, auditable services.

A critical note: Fabric never stores private keys on the ledger itself. All key management happens off-chain, which is foundational to the network's identity and security model.

2. Security Risks & Fixes for the Private Number Summation Scenario

Let's start by breaking down the risks of your initial approach (storing decryption keys in chaincode that's replicated across every peer):

Potential Security Risks

  • Key Exposure: Every peer holds a full copy of the chaincode. If an attacker compromises a peer (or a rogue employee has access to the server), they can dig into the chaincode's files or binary to extract the decryption key. Once they have it, they can decrypt every peer's private number—completely destroying the privacy you're trying to maintain.
  • Unauthorized Decryption: Even if you obfuscate the key in the chaincode, determined attackers can reverse-engineer the binary to uncover it. Chaincode runs in Docker containers, but container escapes or local host access can still expose the key.
  • Malicious Peer Tampering: A compromised peer could modify the chaincode logic to leak the key or alter the summation result, while still appearing to be a valid network participant.
  • Key Rotation Headaches: If you need to update or rotate the decryption key, you'd have to redeploy the chaincode to all peers—cumbersome, and creates a window where old keys might still be accessible on some nodes.

These are the most robust ways to handle this scenario in Fabric, without putting decryption keys at risk:

a. Use Private Data Collections (PDCs)

Fabric's built-in Private Data feature is made for exactly this use case. Here's how it works:

  • Configure a private data collection where each peer only stores its own private number. The collection policy restricts access so peers can't view each other's private data.
  • The chaincode can access all authorized peers' private data (via the Fabric runtime) to compute the sum, but the raw private numbers are never written to the public ledger. Only the final sum is committed as public data.
  • No shared decryption key is needed here—Fabric handles access control to private data automatically, so peers never see each other's sensitive values.

b. Zero-Knowledge Proofs (ZKPs)

For next-level privacy, integrate ZKPs (like zk-SNARKs) into your chaincode. Here's the gist:

  • Each peer generates a cryptographic proof that their number is valid (e.g., within a specified range) without revealing the actual value.
  • The chaincode verifies all proofs and calculates the sum using the proof data—never touching the raw private numbers.
  • This eliminates the need for decryption keys entirely, since the sum is derived from proofs instead of plaintext data.

c. Secure Key Management with HSMs

If you absolutely must use encryption (though PDCs are a better fit here), never store the decryption key in the chaincode. Instead:

  • Keep the key in an HSM or secure key vault.
  • Modify the chaincode to call the HSM's API to decrypt data on-demand, rather than holding the key locally.
  • Configure the HSM to restrict access to the decryption key only to authorized chaincode instances—so even if a peer is compromised, the key stays locked in hardware.

d. Lock Down Chaincode Access

  • Use Fabric's endorsement policies to ensure only trusted, pre-approved peers can execute the summation logic.
  • Restrict local access to peer nodes and chaincode containers with strict OS permissions and network security groups.
  • Deploy encrypted chaincode packages, so only authorized peers can unpack and run the chaincode.

内容的提问来源于stack exchange,提问作者Omar Kayali

火山引擎 最新活动