Interview with Joseph Chow of BTC Relay at DEVCON1 in London
9 Dec 2015 · 16:54
At Devcon1 in London, Epicenter interviews Joseph Chow, developer of BTC Relay, a set of Ethereum smart contracts that let the network verify Bitcoin transactions without running a full Bitcoin node. They cover how BTC Relay functions as an SPV client for Bitcoin on Ethereum, the gas costs of verifying a Bitcoin transaction onchain, and the applications this cross-chain verification could unlock.
Speakers
Topics
Transcript
right now I'm with Joseph chow who is building BTC delay that's a very interesting project connecting Bitcoin in each idiom and makes it helium the first Bitcoin side chain possibly so let's have an introduction from Joseph gel first hi I'm I'm Joseph I've started initially on etherium by contributing to the open-source JavaScript implementations and then start on this vtc relay which is a bridge between Bitcoin theorem and then that was with them some the etherium organization and then joined consensus in September so what is BTC delay so i'll give you am
like maybe the general explanation of BTC relay so the most common one that you know a lot of people can understand and we can poke you know because i can describe it is really in terms of like the general people or to developers i think i think that gentle one would inspect it so so yeah generally and it allows interaction between Bitcoin and athyrium so when there's a transaction and the Bitcoin blockchain the theorem network doesn't know about it and can you know validate hey did this transaction really happen so for example if you're if you're a store accepting payment and you want to accept Bitcoin
payments then BTC relays it is a way that will help you be able to verify that actually happen in the Bitcoin network inside your theory m ok so let's perhaps tix take another example let's say I have a Bitcoin address and I have I currently hold eater and you have Bitcoin and we want to do an exchange so you want my ETA in exchange for your Bitcoin so with BTC relay can we do something like you send the Bitcoin to my address and then the ether gets automatically transferred to your address yes this is a really really good
example and it's kind of a also part of the reason how the BTC really starts so so what what would happen is when I pay the bitcoin to your address in the the second output of that Bitcoin transaction I would encode my ether address and so I have yeah I have some command line tools to to help construct that and then once i send the bit the Bitcoin on the Bitcoin blockchain then i can send the that Bitcoin transaction to another contract in etherium which will use BTC relay to verify that i did i did pay you the bitcoins and then your your
ethers are locked in in the contract which has the the ether and then the contract will verify yet did I really pay the bitcoins and when it does then it will send your either to my ether address okay it's a basic example so so basically in this scenario what is happening is when you pay the Bitcoin on the Bitcoin block chain and the transaction is is there that transaction is included in a block so there is a mortal proof linking your transaction to the block and thence let's say there was enough proof of work done to have six blocks so you have you can prove that the block in which your transaction is it was followed by six blocks and then
would I send the whole proof to BTC delay would you send the whole proof to BTC delay yes yes you would and yeah constructing these proofs are not are you know are not so straightforward so yeah there's at least on a under JavaScript side I have a library that's also an NPM that helps construct that proof and a lot of these things for if your app developer yeah you want to do that for your users because you can ask your users to you know create a proof of your Bitcoin transaction and then send that to BTC relay okay so all you would do is just ask your users what's the Bitcoin transaction and your dad would do that work so so so in essence like
like we have the concept of an SPV wallet in which basically I can I can transact on the Bitcoin network without being a full node and I can verify that something happened on the Bitcoin blockchain BTC relays essentially an SPV wallet of Bitcoin but implemented as a smart contract on etherium right yes that's a very very good way of describing it okay so so so basically basically like this is like one half of a side-chain transaction right like as as as side chains originally conceived by by block stream you do an action X on the Bitcoin network then submit a proof of that action X on another chain and
you get some other assets in exchange for for that particular action so this this is possible today with ptc delay / already right so yes it's it's a key building block that leads that can lead to side chains definitely it's the it's just a very initial building block that you have verifies that the Bitcoin transaction has been you know has been confirmed with Bitcoin blockchain the the other parts of actually verifying a did this Bitcoin transaction actually lock you know certain bitcoins that that would still have to be implemented in theorem contract and what is the
difference between the do so oh so let's say you're a side chain contract right you you are we want to verify that hey where these bitcoins really locked and then how many bitcoins were locked if one Bitcoin was locked maybe you'll get one side chain token so all all that logic has to be implemented another theorem contract and yeah the way we've been describing on that this approach it's just one possible way that side chains might be able to be implemented in theorem I think there there there are other ways that might yeah might might go around it I yeah can't remember those right now though
okay so in terms of this BTW CD layers a smart contract on athyrium how much how much gas does it consume to say verify a Bitcoin transaction so the good thing is that it's since these merkel proofs are our logarithmic depending on at the number of transactions in in the block they're relatively short and I i I've done the computations for how much it is to store Bitcoin block header and that one is around 200,000 gasps to store an 80 bite Bitcoin block header and so very verifying I think is going to take less
gas because storage is one of the biggest gas costs I I didn't get to a run run the numbers yet but i would say that to verify a transaction would be less than 200,000 gasps okay so to follow listeners um so the current price gas prices around say 1550 shannon which is yes 51 channel is like one billionth of a meter and 50 shannon is a very tiny amounts so 200 e it would be am yeah point point 01 ether so it would so verifying a Bitcoin transaction using BTC delay on this helium would be like point 01 ETA which is around a cent so this you can do this essentially this
kind of verification of bitumen transactions in bulk on the etherium network yeah that's right and there are other ways yeah they're definitely definitely plenty few other ways to lower the cost as well and I think you'll probably have one yeah one of your guests Jeff Coleman whose very um who has a lot of the ideas about off chain you know doing a lot of things off chain and I discussed with him some of these ideas so it's possible to do the more these things off chain and and lower lower the costs as well but I'm not sure how much yeah whether we will go ahead with those ideas or currently
release that current version okay so ha have you seen any applications already for bdc delay so as as far as I am aware I'm the I've been the decentralized trustless theron bitcoin swap that's the that's the main which I'm also working on that's the one that I that I i I'm just aware of but I think I some Oracle services would be interested in integrating which is really so the decentralized and so sorry and another on and and yeah some of my teammates like the gnosis prediction
market I think they have also plans to my rigid ok so the decentralized stressless btc-e th swap is exactly the example we went through ideas some you can exchange Bitcoin for ETA yes without that's right a central party at all mm-hmm that's right and just um because i think the the initial explanation that that that I that we discussed where that we already discussed but in as an option example it's quite interesting because what would happen is i would just send you the you the bitcoins directly and then you know if you're most of the time you're going to be a good guy you know say then you'll just send me the ether
right and then that will be completely off chain you know i just sent your bitcoin there in the Bitcoin block chain but in a theorem you know it's quite quite simple that you're just send me the ether directly right so so the so that's that that seems pretty efficient now let's say you're you're you you you decide not to not to send not salitre then that's when we would just really use the contract as like a final judge to that will then arbitrate that if i can give it a proof that i really did give you bitcoin then it would you know give me you're either still even without your cooperation but most of the time
you know that that should not need to be vote because you'll get you'll get punished okay and so so in this case when I'm when I'm asking the contract to verify something in Bitcoin can I also ask the contract that verify that this this transaction has at least six confirmations or ten confirmations of 100 confirmations yes so yeah that would be that that's an extension it could be made right now we just strictly check for six confirmations the tricky thing about further like let's say 100 confirmations is the only way to do that is to like you would have with a
backtracking involved it would just cost cost a lot more gas whereas if you always just check for 46 you know then it's just like looking for six six items back and then that's the end of your guests but if you're checking for 100 confirmations you in a way you might need to do sometimes some kind of like binary search way and then after that you know kind of possibly have more checks needed so it might cost more gas and and now the double reverse is not possible right like you cannot do so right now like the exchange we talked about it's I have either I lock the thing into a smart contract then you send me Bitcoin in an address and then
you send the proof of proof of this payment to BTC delay PT ceilings gives returns like that the transfer was correct to the contact and the contract then releases the ether to you so we can do it this way but the opposite flow is not possible right like have something on the ptc side that can verify any theorem transaction have something on Bitcoin that verifies the theory if that is not possible today right yeah that's right yeah that none of the parts and the Bitcoin sides not we haven't implemented any of the parts of the Bitcoin side so usually yeah that's always been something that that I
thought might be needed but when I but there are ideas that we actually don't need to implement things on the Bitcoin side so as long as we have that primitive where we can do a trust list athyrium and bitcoin swap yeah there are other interesting schemes where we don't actually need to write a bunch of bitcoin script to to be able to do the the other part so like like as we saw in this conference there a couple of financial institutions that are wanting to issue let's say fiat currencies on ET liam like block chains so in principle what could happen is let's say like
there's a big financial institution that issues like USD on another separate etherium like blockchain then essentially could you do a swap between the USD and ether using BTW like not BTC delay but USD relay in this case yeah yeah depending on that I think yet using similar similar ideas it would be would be possible so yeah some of the key ideas of using it merkel proofs yeah as you we've seen a lot in and devcon there's been a lot of merkel izing many things so the key ideas definitely can help so so it's one one other question
that people sometimes ask is if it can work with things like master coin or dogecoin or litecoin and right now you you wouldn't be able to really make a litecoin relay because it use a script and script is not a native Native opcode in EVM so to write write that would cost a lot a lot lot lot of gas so I think metallic even mentioned maybe millions or billions of gas so so that's why yeah so a lot of those some altcoins we wouldn't be able to do and since master coin is just metadata in Bitcoin that would ya
also not be possible so what you're saying is because because litecoins algorithm wanted to be sick resistant so they made it memory hard which means that in order to mine a litecoin you need a lot of memory so any any proof of a litecoin transaction requires memory in order for verification and memory is essentially an expensive operation in in a smart contract is that why is that why it's more like the the script hashing function so in Bitcoin the dashing function is sha-256 which is natively supported evm but the script yet these hashing functions there's enough detail
in them that yeah I'm not too familiar with script but if you're what with what you said if it was memory hard then yeah it would yanny vm we would have to simulate that and it would uh yet cost a lot of gas ok cool so we can our viewers discover your work George I do you I guess the yeah the the site is BTC relay org and so yeah it's a that's where to find the information and it will have links to the github repo as well and get our channel where where people can ask any questions also an email address there thanks Joseph for taking out the
10k thank you thank you me here