paint-brush
How to Convert R-BTCs in BTCs Using RSK’s Powpeg Protocolby@rootstock_io
741 reads
741 reads

How to Convert R-BTCs in BTCs Using RSK’s Powpeg Protocol

by RootstockMarch 22nd, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

The Powpeg is RSK’s 2-way peg protocol used to do conversions between BTC and R-BTC. It protects private keys stored in special purpose PowHSMs based on tamper-proof secure elements, using a layered design which is referred to as defense-in-depth. The minimum amount to send must be greater than 0.005 tR-BTC for Testnet, so you must be careful not to do something wrong and lose your “real” funds.

Coin Mentioned

Mention Thumbnail
featured image - How to Convert R-BTCs in BTCs Using RSK’s Powpeg Protocol
Rootstock HackerNoon profile picture

What is Powpeg?

The Powpeg is RSK’s 2-way peg protocol used to do conversions between BTC and R-BTC. 

The Powpeg protects private keys stored in special purpose PowHSMs based on tamper-proof secure elements, using a layered design which is  referred to as defense-in-depth. 

To learn more about it, I suggest you read the article Building the Most Secure, Permissionless and Uncensorable Bitcoin Peg, from Sergio Demian Lerner and Sebastian Lindner.

Overview

Steps

  • Get some tR-BTCs on the faucet
  • Send tR-BTC to RSK Bridge Contract
  • Export private key
  • Get the BTC address equivalent to R-BTC address
  • Wait 4000 RSK block confirmations and at least 10 more minutes.
  • Check balance in your BTC address
  • Import your private key on a BTC wallet

I strongly recommend trying the 2-way peg on Testnet, before doing it on Mainnet. 

At this moment, the minimum amount of the process is 0.008 R-BTCs on Mainnet and 0.005 tR-BTCs on Testnet, so you must be careful not to do something wrong and lose your “real” funds.

Get some tR-BTCs on the faucet

I am using the Metamask wallet to store my tR-BTCs. Nifty is also an excellent option!

Here are the instructions to use them on RSK networks:

Maybe you already have tR-BTCs because you first tried the PegIn process, but if you didn’t , you can get some tR-BTCs in the faucet.

Go to the RSK faucet

Paste your address and resolve the captcha

Wait some seconds...

Take a look on my transaction:

https://explorer.testnet.rsk.co/tx/0x55bd44539942ae36ebad0489694402dac39392bb8a34f056ca32ef476710db42 

Send tR-BTC to RSK Bridge Contract

You will send the tR-BTC to the RSK Bridge Contract address, updating the gas limit.

In your R-BTC wallet, click on the Send / Transfer button.

The RSK Bridge Contract address is: 

0x0000000000000000000000000000000001000006

The minimum amount to send must be greater than 0.005 tR-BTC for Testnet

  1. Fill the RSK Bridge Contract address: 0x0000000000000000000000000000000001000006
  2. Fill the value, greater than 0.005 tR-BTC for Testnet
  3. Check the gas price, at least: 0.06 GWei
  4. Update the Gas Limit to 100000

Important

The Gas Limit of the transaction must be manually set at 100,000 gas; otherwise the transaction will fail. 

Confirm the transaction

The transaction will be pending for a while

Wait the transaction be confirmed

Export private key

I am using the Metamask wallet.

On the 3 dots on the left side, click on Account details

Then click on Export Private key

For example, this is the private key for my account in this tutorial

b4a670a4240b900cadf14c680a82a917159712fa303038f5e8d4fd3b88675bd3

Do not show your private key to anyone!

I am showing it to you because this is a tutorial and we're using the Testnet, however I will never store real cryptos using this seed :)

Get the BTC address equivalent to R-BTC address

The private key for your R-BTC address will be used to discover your Bitcoin private key, and use it in a wallet to get the BTC address also to transfer your BTC later.

RSK has a tool to get your BTC private key in a secure way, on your desktop, without exposing your private key on the internet. So, let’s use it!

If you already did the PegIn process, you had used this before. 

Go to github.com/rsksmart/utils

If you do not want to compile the utility, you can download the latest release. I will use it.

Go to last release page and click on build.zip to download it

I saved, unzipped it in C:\RSK and renamed to rsk-utils-build

In the build folder, open index.html in your browser

For example, my path is file:///C:/RSK/rsk-utils-build/build/index.html

  • Enter your RSK private key
  • Select TestNet
  • Click on the Transform button.

Then you’ll get your BTC private key.

In my example, the BTC  private key is 

cTdrwp5UenJqFUrMV58sT9VwbpSmX8EMN2bZKU8QUpnDAbTi9aZp

Remember: never share your private key!

Here I am doing a tutorial, so I can share it only for educational purposes.

Import your BTC private key on a BTC wallet

I will use the Electrum wallet, which we explained how to download and installed it on the previous post, the PegIn part of How to do Conversions Between BTC and R-BTC Using the Powpeg Protocol.

For example, I had it installed in the C:\RSK\Electrum folder.

Then I run:

electrum-4.0.9-portable.exe --testnet

Choose Create new wallet

Choose a new name, if you like it.

For example, my wallet will be from_rsk

Click the Next button.

Choose Import Bitcoin addresses or private keys, then click the Next button again.

Paste your private key and click on Next button

For example, this is that I’m using in this tutorial:

Define a password, if you would like to do it, and click on Next button again.

And this is your new imported wallet from private key on Electrum!

Get your BTC Address on Electrum

  1. Go to the third tab, Receive
  2. Change the Expires after to Never.
  3. Click the new address button

You will see a Bitcoin Testnet address like below.

My BTC testnet address is:

n1izvJX1RTXHaLyp6LWZKhuqbLK8919vpA

You can check it out in the zoomed image:

Wait block confirmations

Wait 4000 RSK block confirmations and at least 10 more minutes.

A block is confirmed on RSK Network in average, 30s, so you need to wait at least 33h20min more 10 minutes.

This is equivalent to waiting 33h30min!

Check balance of your BTC address

Besides the Electrum, you can check your balance in Blockcypher - a block explorer for Bitcoin testnet

For example, this is my tBTC in this tutorial:

https://live.blockcypher.com/btc-testnet/address/n1izvJX1RTXHaLyp6LWZKhuqbLK8919vpA/

Final message

In the previous post, How to do Conversions Between BTC and R-BTC Using the Powpeg Protocol you learn the PegIn part of Powpeg.

Here I showed you how to do the PegOut: transforming your R-BTCs in BTCs. So now you know all the processes!

I hope this tutorial has been helpful and I’d appreciate your feedback. 

Happy with this tutorial? Share it if you like it :)

The end