Bridging CryptoNote to Polygon

Bridging CryptoNote to Polygon


After working as a software developer in the CryptoNote space for 5 years, the biggest challenge I have faced involved connecting the CryptoNote based coin Fedoragold.com to Polygon.  Big challenges require impressive partners and we successfully completed that bridge with the help of Rebalancetoken.io, an organization that operates a new service named Rebalance Bridge (https://rebalancetoken.io/bridges.html).  We also required the assistance of the ChainLink team in order to construct an Oracle for the proper monitoring of this bridge service.  In this posting I will describe our experience with working in conjunction with Rebalance, and ChainLink and the many moving parts needed to successfully build a bridge of this sort, and thereby laying the foundations needed for other CryptoNote based projects to follow us.

The first thing one must realize when bridging a new chain to Polygon, is that the Polygon network has 2 different token types running simultaneously.  The two types are 1) for creating a new Polygon token from scratch (Plasma tokens), or 2) for map an Ethereum token address into Polygon using the Polygon token mapper (Pos tokens).  Effectively, there is a PoS (proof-of-stake) based token called Polygon PoS, and there is a second more technologically advanced token type named Polygon Plasma.  For our project we chose to first bridge from CryptoNote to Plasma.  This bridge does not involve the pre-issuing of tokens that are stored inside of a wallet address, but instead is based on the idea of dynamically issuing new tokens on the fly, and consequently burning coins that are so converted.  This has the advantage, that there is no massive blockchain address sitting around that contains large amounts of coins.  The addresses used as part of this bridge solution, are either issued to known addresses in the exact amounts needed, or they are sent to burn addresses for which no private keys are known.  For this reason the Plasma based solution is more secure than other bridge solutions that are based on the maintenance of large balance coin addresses, that could potentially be hacked.

Moving coins from CryptoNote (a Privacy Coin) over to Polygon (a public blockchain) in this manner is not an easy task.  To accomplish this feat the CN coins must first be monitored by an Oracle solution, that can monitor the state of the Fedoragold (CryptoNote) blockchain, and determine exactly when the correct amount of FED coins have been burned.  Then commands are issued which first create tokens within 2 intermediate coin standards until their final translation into the Polygon Plasma token standard.  This service translates Fedoragold/FED (native CryptoNote coins) into Polygon FED (Plasma tokens) in a 1-to-1 ratio, thereby maintaining the same coin value once translated into Polygon. 

The bridge service at Rebalancetoken.io runs as a smart contract within the Polygon blockchain.  Smart contracts do not have access to the general internet, in order to maintain proper security.  Therefore in order for Polygon smart contracts to be able to monitor transactions on an external CryptoNote based chain, commands must be sent to an Oracle service, to provide any needed CryptoNote based status information. The Oracle service used for this bridge contract is based on Chainlink.  The ChainLink Oracle runs an embedded Fedoragold daemon (a blockchain server), and uses the Block Explorer API exposed by that FED daemon to monitor activity on the FED chain, specifically tracking the balance within the FED Burn address, for which the Oracle was given a View key.  The CryptoNote View key does not allow the Chainlink Oracle to alter the contents of the FED Burn address however, as it is a read-only key.  So exposure of this low security key to the Chainlink Oracle does not pose a security risk to the overall system.  Indeed the private key for the FED burn address is not known by anyone, and any coins that had been accidentally burned during development, must remain so burned forever, and do not have corresponding tokens issued for them.  So, burning coins on the CryptoNote chain in this manner is a one-way affair, and is irreversible in nature.

What follows is a step by step description of the process of coin bridging from CN to Polygon.

Step 1: A button was constructed inside of the FED wallet labeled "Issue Tokens", and when that button is pressed, the first thing that happens is that the fee addresses required to run the Bridge smart contract are examined, to make sure that there is enough gas in the system, to run the bridge contract software.  We check the bridge fee balance prior to burning FED coins, because once burned they are lost forever, so it is important to make sure that the contract is operable before allowing the bridge process to continue.  The refunding of the contract fees should be an automated affair, however it is wise to double check that value first, prior to allowing the burn.

Step 2: Once we know there are sufficient bridge fees available, then the Fedoragold (FED) coins are delivered to the CN Burn Address.  Once sent a Proof-of-payment encryption key is generated and stored.  The proof-of-payment provides advance proof to the Bridge Contract that FED coins were in fact burned for this purpose.

Step 3: Next we redirect the user experience to the Rebalance Bridge submission form using the client web browser, and automatically fill out the form with the proof-of-payment, address, and amount of coins.  We fill out the Bridge submission form automatically, otherwise there would be too many opportunities for end-user typos. The Bridge then requests that a fee of 2 MATIC is paid for the bridge service, and later some of those fees are used to replenish the bridge contract which we had checked earlier.

Step 4: Then the Oracle Service begins monitoring the CryptoNote blockchain, to make sure that the FED burn is fully confirmed, using the proof-of-payment key provided, and by consulting its local FED daemon block explorer API.  Once the FED burn is confirmed it alerts the bridge contract that new token issuance should proceed.

Step 5: Next tokens are first issued from within ChainLink to be passed over to Rebalance Bridge.  These tokens are MATIC based tokens however, and not on the Polygon Plasma standard required as output.  These intermediate tokens are passed over to Rebalance which then translates those tokens into the Plasma standard format needed for the Polygon network.

Step 6: Finally, the resulting Plasma tokens are issued on the Polygon network and sent to the target Polygon address.  As an added security measure, each Polygon address can only be used once.  After that the same address can never be used to accept FED tokens ever again.  Since addresses can be created on the fly, this makes it impossible for a hacker to intercept the tokens as they are being created and send to the target Polygon Address.

That's the basic process used to issue bridged Plasma tokens on Polygon.  Once issued those tokens are then available for use on the Polygon Quickswap DEX, where trading has been healthy.  It was a long road to create this bridge, but now that this basic method has been forged, new CryptoNote coins can also be issued as tokens on Polygon as well.  I would like to thank the teams at both Rebalance and ChainLink for their diligence and professional engineering work, and we look forward to years of successful trading on Quickswap DEX.  In a future post I will also describe how FED has integrated CryptoNote with the Ethereum network as well, and how those same Ethereum tokens (called BFED) were subsequently published back over to Polygon as Polygon Pos tokens, which are then pegged to the Polygon Plasma tokens described above.

 

 

How do you rate this article?

7


Joja Poppa
Joja Poppa

Joja Poppa is a very experienced CryptoNote blockchain developer, and contributor to the Fedoragold.com project. Joja writes about CryptoNote related topics, Privacy, Fungibility, and Security.


The Future Is Fungible (FedoraGold.com)
The Future Is Fungible (FedoraGold.com)

The future of the entire crypto industry hinges on the concepts of privacy, security and fungibility. What does it mean for a crypto to be both private, secure and fungible, and what sort of assets will lead us into that fungible future? Read about it all here on the Official Fedoragold.com Blog.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.