简体   繁体   English

在Hyperledger Fabric V1.0中,在同一个通道内的对等体之间实现通道间安全性

[英]Implement inter-channel security among the peers within the same channel in Hyperledger Fabric V1.0

I have successfully create a Hyperledger Fabric v1.0 network locally by following the steps Building Your First Network and communicating to this network from my java application using fabric-sdk-java . 我已经按照构建您的第一个网络步骤并使用fabric-sdk-java从我的Java应用程序与此网络进行通信,在本地成功创建了Hyperledger Fabric v1.0网络。
Here it created the certificates using cryptogen tools and is able to invoke/query chaincode through each of the peers which participating in the same channel. 这创造了使用cryptogen工具证书,并能够通过每个参与同一通道中端的调用/查询chaincode。


My implementations is like: 我的实现是这样的:
I have four organisations Org1, Org2, Org3 and Org4 each having one peer. 我有四个组织Org1,Org2,Org3和Org4,每个组织都有一个同伴。 When Org1 creating an asset A1 with quantity 100 using the chaincode C1, it has to share this asset among the peers like 当Org1使用链码C1创建数量为100的资产A1时,它必须在对等体之间共享此资产

Org2.peer0 A1: with quantity 40 Org2.peer0 A1:数量为40
Org3.peer0 A1: with quantity 30 Org3.peer0 A1:数量为30
Org4.peer0 A1: with quatity 20 Org4.peer0 A1:数量为20
And remaining 10 only will be available for Org1.peer0 Org1.peer0只剩下10个

All these peers joined in the same channel channel1 . 所有这些同伴都加入了同一个频道channel1 My requirement is 我的要求是

If Org1 try to query the data for Org2 : error 如果Org1尝试查询Org2的数据:错误
If Org1 try to query its own data: return the Asset with the corresponding quantity. 如果Org1尝试查询自己的数据:返回具有相应数量的资产。

Currently it is allowing to query all the data from all peers in the channel. 目前,它允许查询来自通道中所有对等体的所有数据。 In order to keep it hide the asset of one organisation from other, what is the best possible way? 为了保持一个组织的资产与其他组织的隐藏,最好的方法是什么?

I think that the source of your confusion due to the fact that you mixing the application logic with the business contracts logic which is usually implemented in chaincode. 我认为由于您将应用程序逻辑与通常在链代码中实现的业务契约逻辑混合在一起而导致混淆的原因。

Say you would like to establish Fabric network among 4 different parties and you need to define a rule which defines how you will split/distributed the asset among those participants. 假设您希望在4个不同方之间建立Fabric网络,您需要定义一个规则,该规则定义如何在这些参与者之间拆分/分配资产。 Now, let's put aside the peers. 现在,让我们抛开同行。 In your chaincode you encode notion of the asset and probably the notion of the users to avoid confusion let's call them persons. 在你的链码中你编码资产的概念,可能是用户的概念,以避免混淆让我们称之为人。 So you have 4 persons: Alice, Bob, Charlie and John and business rule which says that once Alice submit an asset it has to be distributed according to 40%, 30%, 20% and 10% respectively. 所以你有4个人:爱丽丝,鲍勃,查理和约翰以及商业规则,这表明一旦爱丽丝提交资产,它必须分别按40%,30%,20%和10%分配。

Next, to continue with say Alice works at Org1, Bob at Org2, Charlie at Org3 and John from Org4. 接下来,继续说,Alice在Org1工作,Bob在Org2工作,Charlie在Org3工作,John从Org4工作。 Now you can implement a chaincode which will apply business rule based on whoever submits the transaction. 现在,您可以实现一个链代码,该代码将根据提交事务的人员应用业务规则。 Moreover you can implement ACL based on the submitter identity, hence to prevent from Bob query for balance of the let's say John. 此外,您可以根据提交者身份实施ACL,从而防止Bob查询让我们说John的余额。

The legitimate question will be why do I need 4 peers to implement such simple logic. 合法的问题是为什么我需要4个对等体来实现这样简单的逻辑。 As you can have only one peer with chaincode deployed, channel which configured for all 4 orgs and all you need is to send transactions proposal to invoke the chaincode. 由于您只能部署一个带有链代码的对等体,因此为所有4个组织配置的通道以及您需要的只是发送事务提议以调用链代码。

The caveat in this approach is pretty obvious you need to decide which org will host and run this peer and the chaincode, therefore as all 4 orgs doesn't really trust each other they would like to host they own peer and invoke chaincode against theirs own peers. 这种方法的警告非常明显,你需要决定哪个组织将托管和运行这个对等体和链码,因为所有4个组织都不相互信任,他们想要托管他们自己的对等体并调用他们自己的链码同行。 And in order to prevent each org to trick each other and reduce the influence of adversarial/non-deterministic behavior they will agree on endorsement policies which actually will make sure that peers of other orgs also receives same results as you during the simulation. 并且为了防止每个组织相互欺骗并减少对抗/非确定性行为的影响,他们将同意认可政策,这些政策实际上将确保其他组织的同行在模拟期间也收到与您相同的结果。

Now back to your question, peers are used to simulate transaction against current state and sign on the results, send results back to the client which aggregates endorsements based on policies and submits results to the ordering service which cuts blocks and deliver them to the peers, which will validate correctness of transactions in the block and eventually commit them to the ledger updating state. 现在回到你的问题,对等体用于模拟当前状态的交易并在结果上签名,将结果发送回客户端,客户端根据策略聚合认可,并将结果提交给订单服务,订购服务削减块并将其交付给同行,这将验证块中事务的正确性,并最终将它们提交到分类帐更新状态。

Therefore your chaincode should encode notion of clients/users/persons among which you will distribute assets, those users could be mapped back to the client application (real world users), which might be enrolled into different organizations, hence having different certificates signed by appropriate org CA. 因此,您的链代码应编码客户/用户/人员的概念,您将在其中分配资产,这些用户可以映射回客户端应用程序(真实用户),这些用户可能会注册到不同的组织,因此具有适当的签名的不同证书组织CA. Finally you will be able to leverage GetCreator API of the chaincode to understand which client invoked the chaincode and apply business logic and access control based on business logic you defined. 最后,您将能够利用GetCreator API来了解哪个客户端调用了链代码,并根据您定义的业务逻辑应用业务逻辑和访问控制。

Sorry for making my answer too long, but to summarize. 很抱歉让我的答案太长,但总结一下。 Your application/service will be based on two tiers: first one is the application tier - mapped to the user of org, second tier is the peer which holds the ledger and deployed chaincode - to simulate and execute transactions. 您的应用程序/服务将基于两层:第一层是应用程序层 - 映射到组织用户,第二层是持有分类帐和部署链代码的对等层 - 用于模拟和执行事务。 Hence you will have 4 peers and 4 clients which will submit transaction to the peers and your logic will be based on the client identities rather on the peers. 因此,您将拥有4个对等体和4个客户端,它们将向对等体提交事务,您的逻辑将基于客户端身份而非对等体。

Hope my explanation will make sense to you ;) 希望我的解释对你有意义;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM