Best way to create Atomic Transactions using CORDA Flows

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 07:42:26

问题


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.

What is the best way to achieve this with Flows.


回答1:


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)
}

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:

  • 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.

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.



来源:https://stackoverflow.com/questions/48529134/best-way-to-create-atomic-transactions-using-corda-flows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!