Acala and Phala jointly release the first privacy cross-chain use case
Phala可信网络
2020-12-23 03:19
本文约3463字,阅读全文需要约14分钟
The first privacy cross-chain demo based on Rococo was released, and Phala & Acala realized the cross-chain transfer of DeFi assets.

Why do we need cross-chain?

In the foreseeable future, parachains will subvert all existing blockchain technologies.

Parachain not only has the advantages of autonomy, endogenous security and professionalism of Layer1 blockchain and smart contracts, but also has the interoperability that Ethereum Layer2 currently does not have.

If you submit a compensation application for flight delay insurance, before the official compensation, the insurance company will obtain data from the airline whether the flight is delayed or not, and obtain data from the airport to verify whether you went to the airport on time. If the above two conditions are met, the insurance company will transfer the compensation funds into your bank account.

If you submit a compensation application for flight delay insurance, before the official compensation, the insurance company will obtain data from the airline whether the flight is delayed or not, and obtain data from the airport to verify whether you went to the airport on time. If the above two conditions are met, the insurance company will transfer the compensation funds into your bank account.

In this scenario, the invocation of data by the insurance company fully demonstrates the characteristics of interoperability.

At present, parachains have developed a variety of categories, such as: parachains with coins, parachains without coins, parachains perpendicular to a certain field, and hub chains serving a certain community...

Taking parachains as an example, what kind of use cases can we achieve using Polkadot/Kusama’s cross-chain technology?

mdnice editor

  • First of all, we may wish to assume that there are currently two most commonly used blockchain protocols and services:
  • Phala Network is a blockchain privacy protocol. Phala implements Turing's complete privacy contract through trusted computing technology + blockchain, which not only ensures the reliable execution of smart contracts, but also does not need to disclose sensitive data.
  • mdnice editor

  • Under this condition, we want to:
  • Get private assets on Phala from Acala

Obviously, under any non-Polkadot/Kusama protocol, whether it is Acala or Phala, it will consume huge developer resources and energy. However, if we adopt the Polkadot/Kusama cross-chain protocol, we can achieve this without changing a single line of code use case!

mdnice editor

Demo Video:https://www.odaily.com/video/3151

Github:https://github.com/Phala-Network/phala-blockchain/tree/rococo

Cross-chain use case displayhttps://rococo-demo.phala.network/#/settings
Acala:https://rococo-demo-acala.phala.network/#/explorer
Phala:https://rococo-demo-phala.phala.network/legacy.html#/explorer
Rococo relay chain:https://acala-dapp-4higttopf.vercel.app/#/wallet
Phala dark wallet:https://rococo-demo-phala.phala.network

first level title

The cross-chain principle consists of the protocol XCMP between the relay chain, the parallel chain, and the connection chain. Cross-chain transactions are resolved through a simple Merkle tree-based queuing mechanism to ensure accuracy. The task of the relay chain validators is to move transactions on the output queue of one parachain to the input queue of the target parachain. However, only the associated metadata is stored as a hash in the Relay Chain memory.

An XCMP queue must first be initiated by opening a channel between two parachains. A channel is identified by the sender and receiver parachains, which means it is a one-way channel. There can be up to two channels between a pair of parachains, one for sending messages to the other chain and one for receiving messages.

mdnice editor

  • The XCMP protocol can be subdivided into:
  • VMP: Parallel Chain-Relay Chain Communication
  • XCMP: Parallel Chain-Parallel Chain Direct Communication

At present, VMP and HRMP are implemented on Rococo v0, but Rococo v1 is still under development, so we have implemented the cross-chain use case between Phala-Acala on v0.

Architecture

mdnice editor
  • As mentioned above, the Acala-Phala cross-chain implementation based on Polkadot XCM consists of three parts:
  • Chain: Rococo relay chain, two parallel chains: Acala, Phala
  • Privacy black box: All private transactions on Phala occur in confidential contracts running in TEE, and the status of all encrypted data is invisible to the outside world, thus achieving privacy effects

Initiate a transfer from Acala to Phala

In the world of Polkadot, in addition to accounts controlled by individuals, there is also the concept of "sovereign accounts". For example, a Pallet module (or a smart contract) on Substrate can hold certain assets. And when a parachain enters Polkadot, it can also obtain its own account on other parachains. The sovereign account is controlled by the corresponding parachain. Each parachain has a unique ID, which will be mapped to its corresponding sovereign account.

mdnice editor

  • When Alice initiates a transfer transaction from Acala to Phala, such as transferring 1000 ACA to Phala's Bob's account, these events happened behind the scenes:
  • First, on the Acala chain, (Withdraw) 1000 ACA will be withdrawn from Alice’s account and deposited into (Deposit) Phala’s sovereign account
  • After the relay chain receives the message, it will analyze the receiver of the message according to the parachain ID is Phala, and it will forward the message to Phala. This is a VMP DownwardMessage

HRMP is a simple cross-chain messaging method already supported by Rococo v0. Its principle is that chain A initiates an UpwardMessage to the relay chain, and then the relay chain initiates a DownwardMessage to transfer the message to the B chain. Therefore, HRMP is realized by combining two VMPs.

Phala dark wallet accepts transfers and converts to privacy coins

Phala has one big difference from other chains. Usually a parachain will adopt the standard implementation provided by Polkadot to accept external transfers and settle for users. However, Phala is a general privacy protection layer, and it is very important for the main chain to remain neutral to the application. Therefore, the Phala main chain does not do any processing and settlement for cross-chain transfers, but directly transfers them to confidential contracts.

On the Phala side, after the cross-chain transfer message is accepted by the main chain, it is directly routed to the private wallet (Private Wallet) contract in TEE. When the confidentiality contract receives the message, it will add 1000 ACA to the account Bob.

Transfers in Confidential Contracts are end-to-end encrypted. Although it can be seen from the outside that Bob has received 1000 ACA, he can initiate a private transfer and transfer it to Charlie again. As a dark asset, all subsequent transactions of Bob are invisible and untraceable on the chain, thus ensuring privacy.

Therefore, in the demo, we demonstrate the private transaction (Shielded Transaction) between two dark wallets. The privacy transaction is end-to-end encrypted, and only the ciphertext can be seen on the chain, so the details of the transaction (such as sending address, receiving address, amount) are not visible on the chain.

Initiate a transfer from Phala to Acala

Finally, through Phala's dark wallet, a cross-chain transfer can be initiated to Acala to realize withdrawal.

mdnice editor

  • For example, after receiving 1000 ACA from Bob through private transfer, Charlie can initiate a request on the Phala side to send 500 ACA to Acala's Alice account, and these things happen behind the scenes:
  • TEE receives the transfer command, reduces Charlie's account by 500 ACA, and initiates a cross-chain transfer transaction to the Phala chain
  • After the Phala main chain receives the cross-chain transfer request, it will directly send the transfer message to the relay chain, which is a VMP UpwardMessage
  • epilogue

epilogue

In existing blockchains such as Ethereum, the combination of Defi and privacy Layer 2 needs to be mutually confirmed through Ethereum, and a Layer 2 protocol cannot interoperate with another Layer 2 protocol. As a result, users cannot use the Loopring protocol to directly call Tonado Cash, or use Aragon to call Aztec directly.

But on Polkadot, the XCMP protocol allows parachains with strong customization capabilities to achieve convenient cross-chain interoperability with very little workload. The composability achieved through XCMP allows developers to build rich application cases like building Lego blocks.

mdnice editor

Phala可信网络
作者文库