使用CORDA Flows创建原子事务的最佳方法 [英] Best way to create Atomic Transactions using CORDA Flows

查看:39
本文介绍了使用CORDA Flows创建原子事务的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用例,其中我需要将数据发送给多个交易对手,但交易双方之间必须保持匿名。从交易对手处获得背书后,我需要承担整个交易。需要保持整个事务的原子性。

I have an use case where i need to send data to multiple counter parties but the parties need to be kept anonymous of each other . After the endorsements are collected back from the counter parties i need to commit the whole transaction. The atomicity of the whole transaction needs to be maintained.

使用Flows实现此目的的最佳方法是什么。

What is the best way to achieve this with Flows.

推荐答案

为此,您需要使用机密身份。机密身份在状态中由 AnonymousParty 类表示:

For this, you need to use confidential identities. Confidential identities are represented in states by the AnonymousParty class:

class MyState(val party: AnonymousParty): ContractState {
    override val participants = listOf<AnonymousParty>(party)
}

Party AnonymousParty 之间的区别是 AnonymousParty 仅通过公共密钥标识参与者。只要每个交易参与者为该交易生成一个新的公钥,他们的身份及其在国家中的参与就将是秘密的。

The difference between a Party and an AnonymousParty is that AnonymousParty identifies participants by public key only. As long as each transaction participant generates a new public key for the transaction, their identity, and therefore their involvement in the state, will be secret.

要创建一个涉及交易的交易,机密身份,您必须执行以下操作:

To create a transaction involving confidential identities, you must do the following:


  • 发起流程的一方-我们叫她的爱丽丝-必须知道所有交易对手(知道从谁那里收集签名)

  • 爱丽丝与每个交易对手运行 SwapIdentitiesFlow 来自动为所有人创建机密身份参与者

  • 爱丽丝在建立交易时使用这些机密身份

  • 爱丽丝从所有交易对手处收集签名

  • 爱丽丝完成交易

  • One party who initiates the flow - let's call her Alice - must know the identity of all the counterparties (to know whom to gather signatures from)
  • Alice runs the SwapIdentitiesFlow with each counterparty to automate the creation of confidential identities for all the participants
  • Alice uses these confidential identities in building the transaction
  • Alice gathers signatures from all the counterparties
  • Alice finalises the transaction

每一方最终都会在其保险库中进行交易,但每一方仅由匿名公众标识关键,因此保持各方的参与

Each party will end up with the transaction in their vault, but each party is only identified by an anonymous public key, so the involvement of each party is kept secret from their peers.

您可以在此处找到有关此API的文档: https://docs.corda.net/api-identity.html 。您可以在此处找到使用机密身份的示例: https://github.com/joeldudleyr3/whistleblower

You can find docs about this API here: https://docs.corda.net/api-identity.html. You can find an example usage of confidential identities here: https://github.com/joeldudleyr3/whistleblower.

这篇关于使用CORDA Flows创建原子事务的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆