Scaled - way to offchain microtransactions with Janmajaya Mall

ETH Seoul 2022 · August 2022 · 28:45

Janmajaya Mall of the Privacy and Scaling Explorations team at the Ethereum Foundation looks at how to make microtransactions practical, such as paying per second or per byte. The talk sets out the properties a good system needs (off-chain, secure, no per-interaction setup, low latency) and compares state channels, virtual state channels, the Lightning Network and probabilistic payments. It then presents Scaled, a state-channel approach that batches opening and settlement with BLS signature aggregation, and discusses zero-knowledge proofs with accumulation as a future option.

Speakers

Topics

From ETH Seoul 2022, hosted by Kryptoplanet.

Transcript

so hi everyone i'm john majer and i hello i'm audible okay i'm john mccain and i work at privacy and scaling exploration group at ef and today i'll be talking about scale which is a way to offshore microtransactions but throughout the presentation i'll be going through what are the different ways of performing microtransactions today and then how we can improve it further so what are microtransactions you can think of microtransactions as small transactions which are not feasible to put on chain directly you can sort of aggregate them off chain and

then put them on chain because you know they're not feasible to compete for the block space so for example you would want to pay a person let's say one dollar every 10 seconds so it isn't feasible to actually put that on chain because even in a very optimistic case it might be like the transaction fee on a roll-up would be like let's say five cents and if you pay them over time it wouldn't uh be good for use it would be really expensive for you so and in most cases microtransactions are paid in higher frequency so you can sort of imagine that you pay per second or per minute or per five minute so you wouldn't want to actually do that on

chain directly which is why you need to off chain transactions so i'm here talking about microtransactions but why do you need them so one of the very futuristic applications that at least uh i have in mind and people at pse have in mind is the mesh network so you can sort of imagine a mesh network as a network of hotspots that actually extend your current network so for example it extends the internet to remote places where you could hot spots and then those hotspots are paid for every bite that they're out so you can sort of imagine paying them a cent for a bite or less than that as well so without micro transaction this

wouldn't be possible you can sort of imagine turning ipfs which is a product by which is open source product by file coin into a cdn so where you actually get paid for per byte of transfer that the bite of data that they transfer you already have existing applications like lifebear uh the graph and in graph you can sort of imagine that i'm not sure whether they're doing it right now but in the decentralized index network you can imagine that you pay per query right so you could have things like that with microtransactions you've got also network which is a p2p vpn where you can you cannot right now you can check it out that it's uh

per byte so they actually pay per byte of data that is routed through the nodes uh and then you can also sort of transform the way you actually pay on online you can sort of pay per second for live shows or podcasts so uh what are the ideal properties that a particular microtransaction system should have and i believe that these are the ones so it should be off chain as i said before your micro transactions should be competing for block space because they'll be very expensive for you it should be secured so what do you mean by secure let's say you're doing offshore transactions but what if you're not able to redeem it for value on chain so

there should be a guarantee that the off chain transactions the value underneath every received or whatever you're exchanging off chain should be redeemable on chain you should not require setup for every new interaction that you do so for example you've got a and b and a is paying b in microtransactions you don't want that when a wants to pay c in microtransactions they will have to interact on chain because okay fine you can do it for five people but you cannot do it for 100 people you cannot do it like every other ah ev every other every day fourth point is that it should and i think it's one of the most important

points for microtransactions as i said it's one to one it should be low in latency so what i mean by low in latency uh let's say a and b uh want to perform microtransactions off chain a should be able to send microtransaction option directly to b rather than routing through other things or using some complex routing mechanism and i'll sort of discuss that one of them in in in in in upcoming slides so yeah so what are the systems that already exist for performing microtransactions the first one is state channels so who all are aware about state channels i guess

yeah most of them so i'll briefly explain what state channels are so let's imagine a and b wanted to perform microtransactions so what a and b can do is that they can deposit certain money on chain that is create a state channel on chain and then they can just sort of send each other received off chain which would be a replica of the state on chain and then in begin agree upon and then settle the state on chain so like three steps so you first open the state channel exchange receipts and then agree upon and settle the state on chain so you can easily see that it's great for one to one exchange so a and b can directly exchange the receipts of chain

it is low in latency and one ideal property that state channels have that is that it is secure that means a and b have a guarantee since they've already made a deposit on chain they were guaranteed that they can actually redeem it for the under its value on chain but the problem with state channels is that you would require an on chin set up for every new person that you want to do micro transactions with so a and b have a state channel but now a wants to pay b a wants to pay c in micro transaction so a will have to create a new state channel with c on change so that's per user that you you're doing micro transaction with plus um we are thinking of applications that are small in value so for example i

would be paying five dollars over an hour or something like that and locking up five dollars in a state channel for an hour is in capital efficient and if you want to scale that linearly it wouldn't be capital efficient or at all because i mean once you're done paying the person you wouldn't want to retain because the transaction fee would exceed the amount that you receive back so it is not capital efficient so there's an improvement on state channels and we call them virtual state channels anyone have any family with virtual state channels okay so virtual state channels are so they follow the properties of state channels but the special property

that they have is that they eliminate the need of interacting on chain for every new person that you want to set up state channel with so the way it works is is that you've got a b and c and let's imagine b as the intermediary so a has a state channel on chain with b and c has a channel on chain with b and through b a and c can set up a virtual state channel that means they did not have to interact on chain to actually have a state channel and that's good right so you don't have to actually set up station for every new person that you want to pay in microtransactions and it follows the properties of state channels that means it is low in latency it is secure so

a and b have a a and c have a guarantee that once they settle the virtual state channel with b they would be able to redeem it for some value that is underneath the received that the share but the expense the bad part about virtual state channel is the intermediary that is b so there's a huge amount of reliance upon the intermediary so if tomorrow b turns out dishonest and stops cooperating then it will be really expensive for a and c to settle all their amounts on chain so for example let's say a and a b and c now they've got many many virtual state channels there many people connected to

b as the intimidatory it will be very expensive for each and every person to actually settle their virtual stage in an enchant without the cooperation of the intermediary that is b in this case so it's very expensive and this could easily turn into a situation where b might ask for transfer of certain amount of money to their account if they if others want to actually settle with it so it could easily turn into extra extortion case the second point is that intimately needs a huge amount of capital so what do i mean by this so when a and c set up a virtual state channel b is representing c

for in p is representing c in this case and b is also representing a in this case so the amount of capital that b needs is the amount of capital a and c put in and you can imagine that if there are several people connected to b as the intimidating which would be the case because b is this is it's sort of a hub network where b is the center b would need the capital that is required by each and every user and that's a huge amount of capital up front which is why uh integrity needs huge capital so we have another thing that is lightning network i um so how many people are aware about lightning networks

one of the oldest ways of performing microtransactions of chain right so uh what a lighting network what is the lightning network so basically in lightning network you [Music] upgrade yourself from l1 to l2 and l2 is the network on which you perform transactions so the way you do is that you set up a state channel or a multisig contract with one of the l2 nodes and then you upgrade your l2 node and lay to network and then you perform transactions it is so it follows the properties of state channels that it is off chain it doesn't require per interaction setup so for example i want to pay my i want

to pay i want to send transaction to someone else on the network so i can route through the network and send them a transaction rather than have a direct channel with them so it doesn't require per interaction setup and falling from state channels it is secure but the problem with lightning network is the time complexity for the routing protocol so what do you mean by that let's say the lightning network has n nodes on the network and have an a needs to send a transaction to b and they do not have a direct channel set up between them so what would happen is is that in the worst case it would take log n hops

from different nodes to actually for the transaction to actually go from a to b and that is really bad for situations where you want one-to-one interaction like like it was in state channels and i said that it is very bad for low latency because login is not good for [Music] low latency transfers plus i believe that routing protocol adds unnecessary complexity to the problem that we are trying to solve over here that is microtransactions and the second thing and the third thing is that given the nodes on the enlightened network are not altruistic they would charge fee for every every hop that you do

so the more the hob that you have uh the the greater the amount that you will pay in fee for the transaction to be routed and that's bad for microtransactions right you're routing one cent or you know let's say one usd or something like that and if there are many hops then you would exhaust some amount of the money that you're routing in fee so yeah uh these are the problems with lighting network and there's something called probabilistic payments anyone heard about property payments right so the way it works is that let's say we have a and b b would set up a rate let's say in this case b would set up a rate that they

want to receive one eighth every five minutes so what would happen is that a would send receipts constantly during during the during five minutes a would constantly stream receipts to b but only one of those receipts would be valid so that means only one of those received can be redeemed for value on change so the way it works is that a would constantly send the receipt to b and all the receipts are invalid except one of them so and which is why we call them probabilistic payments and the key over is that neither b nor a can actually gain the systems so

the the way we it works is that bo neither of them can actually change the probability by which b would receive a valid received the point is that it is low latency because a is paying b of chain directly and it is off chain but as you can imagine as i said before that ax continue continuously streams the receipt to be for this to work out it only works for long continuous continuous streams of payments so you cannot do one of micro transaction payments the second point is that probabilistic payments are either secure or they do not require onsen setup per user so what happens is that in order for a to pay b a needs to first deposit balance on

chain and then only they can pay in microtransactions of chain so now if a wants to pay c as well they would use the same balance pool to sp pay c but what would happen in this case is that a can keep paying different people without guaranteeing that they can redeem it for value on chain and that would mean that it is not secure you can make it secure by having a commit it commit certain amount of balance for every user that they are paying off chain and that would require per user interaction so so that means it is either secure or it does not require any on chain set up a user

so we've got these uh four systems that they already exist and i would be introducing to scale so what is scaled so scale is a project that i've been working on for past two months and it's a off chain micro transaction system and the good thing about scale is that it is built on top of l2's that means it actually leverages the fact that the execution cost on elton's is very cheap and trades it off and and uses that fact to actually reduce the amount of data that needs to be posted in transaction call data on chain

and that is how it minimizes the amount of fee that you need to pay for micro transaction settlement uh before i move on further i would mention that scale does not fit into all the prop ideal properties of microtransactions and i will be talking about how to improve that in future right after this so how does it work let's say a let's say b wants to pay in microtransaction to a so what would happen is that b would first make a deposit on chain and b would also make a security deposit on chain and then a and b would share it received off chain and the received is time logged

as well as unidirectional what do i mean by unidirectional that means that only using the receipt only b can pay a in microtransaction it cannot get go the other way around and then the the receipt also records how much b owes a and then after some time after a thinks that they've received enough amount from b in microtransactions a can redeem the received on chain for the value that it contains that is how much b owes a so they received somewhat looks like this so you've got a's address b's address so a is the one who's receiving the

payment off chain b is the one who's paying in this case since the receipt is unidirectional you only need b signature you do not need a signature right because they're the one who are receiving the payment and b is the one who's paying which is why we only need b signature amount is how much b owes a expires by is that is the time after which the received is no more valid and the sequence number records that the num records the number of they receive so for example a and b share received after which a settle it on chain but like if if a and b want to share another receipt they would have to

increment the sequence number by one and that would be the latest received so that sequence number is actually used for uh tracking the latest receipt that is shared between a and b so when you actually add all these bytes you get 201 bytes and that's a huge amount of call data to be posted on chain and you would and you would notice that uh and we and in subsequent slides we'll be actually improving upon how much amount of data we will be actually optimizing the amount of data that is needed per receipt that should be posted on chain for micro transactions so you can imagine a scenario where you've got a

that is receiving union directional micropayments from b b1 b2 and the same thing goes for a1 so you can sort of imagine that you got a who's receiving microtransactions from several people and then they take all these receipts which are from a microtransaction and then post a margin together and together is the key over here because that's where we actually optimize data that is needed per receipt so why do we make it together why why does a needs to aggregate all the receipts that they have received from b b1 b2 and then post them together under one transaction on chain because in that case we can actually benefit from bls signature aggregation so what happens is that in bls signature

aggregation you can aggregate different signatures into one aggregated signature and then post them on post that on chain so we actually go from every receipt having to every receipt every receipt having the field of b signature only one signature and there is no need of including signature for every receipt so we already removed we've already removed 32 bytes per receipt that needs to be posted on chain but turns out that the moment we actually take many receipts and post them on chain we can perform a lot of a lot more optimizations in terms of data so the first one is that first one is very simple so we can

actually replace every user's index every user's address with with an index so an index could be an 8 bytes that would be 2 64 minus 1 users and that there are many and that is a lot of users so we actually replace a address with a index and b address would be index so now we refer to users using their using their index rather than referring to them using their address the second thing is also simple that we reduce the data we reduce the data by reducing the amount of bytes needed for

amount so we go from 32 bytes for the amount field to 16 bytes and the point in this case is that you actually don't need 32 bytes for the amount and you can actually if you want to go from if you want to match um yesterday transfer something like that you can directly multiply it on chain so you don't need that the third point is that you can remove expires by field and replace it unchained by an epoch so you can sort of set up an epoch field that is like every week or and every two week and every receipt needs to expire within an epoch so rather than having expires by which

which determines that which determines the exact time when the receipt will expire you replace it by an epoch so you don't need the expire by field you only post the receipts that would expire within that epoch and then we can adjust the epoch depending on the usage from one week to one day or within an hour doesn't matter we can also remove the sequence number and reproduce it on chain since i said that sequence number tracks the latest number is latest receipt that a and b share and every new receipt would increment the number by one what we can do that we can actually drag the number on chain and every receipt that you every receive that you receive from aab

you can sort of increment the number and check whether it is valid or not and you don't need to include it per receipt and another optimization optimization that you can do if you restrict that only a can post their receipts on chain you can actually you can you can remove a's index and include it just once so you don't need to include a is index in every received so finally after all these optimizations we come down to something like this so every received only needs b's index and the amount and we need one aggregated signature and a index so we went so we went down from

201 bytes per receipt over here to 24 bytes per receipt and that's a huge amount of saving and we're only able to do it by having few assumptions about that only a can post the data and he will have to aggregate many receipts into one particular transaction and these are the results so if a is agree getting 10 receipts they would have to pay 0.5 usd if you actually take conversion rate 3000 usd 3000 300 3000 usd per each so for 10 receipts the total cost is 0.85 usd and for 100 receipts the roll cost cost is 3.7 usd which is

a good amount of optimization and if you want to dive deeper deeper into scaled contracts and documentation and stuff you can scan the qr code and have a look at it so as i said before scale is not ideal because uh it is not secure as i said that uh you depos b deposits certain amount on chain and then they can actually send payments to a a1 a2 a3 of chain the point is that b doesn't guarantee that all the receipts can be redeemed on chain for the specific value because they haven't committed committed

to every specific user because every specific user is sharing the same pool of balance uh it's it's it's similar to probabilistic payments in terms of security the second point is gas cost so since we are verifying aggregated signature that requires pairing and since every receipt is a different message that would require n plus one pairings operations on chain and if there is a limit of if if there's a limit on gas units that can be used per transaction that would limit the number of receipts that you can post on chin at once so that's the limit in case of gas cost

okay so where are we headed in terms of microtransactions so this is sort of a speculative thing and i still have to research a bit more on this but i can sort of say that i think we're headed to state channels because state channels are one-to-one they are secure which none of the other which others don't which is a property that other systems don't have plus state channels are easy and then and they can represent our arbitrary straight and these are the things these are the good things about state channels and if we are able to make it very cheap in terms of opening and settling many

state state channels at once then we would overcome the problem of locking up capital per channel because you can settle one very easily and very cheaply and you we would also overcome the problem of having to require onshore interaction per user because you can open a state channel and settle the state channel very easily and cheaply on chain so how will how can we go how can we do that so the first way we can achieve that is by having bls signature aggregation so what you can do is that you can actually aggregate several state channels settlement or opening into one aggregate their signatures and post them

on chain and by that you would you would actually save a lot of huge amount you would say huge amount of call data and so and this is what we did in scaled and hopefully in future the data cost reduces so that would be that would make it much cheaper as well plus the good thing about bna signature aggregation is that it is easier to implement you can implement it right now the second part is that we can use zq proofs plus accumulation scheme to actually achieve this so what you can do is that you can create a proof of opening or settling a

state channel and then aggregate all the proofs into one aggregated proof and then post them on chain i'm not sure how much benefited how beneficial it would be as compared to bela signature in terms of call data but i think that if you actually take only the balanced delta that is the balance change of every user as the public input then you can actually optimize it further and reduce the amount of call data that needs to be posted on chain but i'm still uh sort of fuzzy on how to achieve that so we can reduce the i believe that we can reduce the called data that needs to be posted using zk proves

uh much more than using bls signature but the hard part about zika proves an ikea mission scheme is that it is very hard to implement the prover time is a lot and uh there are a lot of things that can go wrong in zika proof it's very hard to audit the circuit's really hard to audit and that in accumulation means that it is really hard to get it right uh so thank you so if you're interested in learning more about us that is psc that is privacy and skilling exploration group was joining us you can scan the qr code or visit our site is at appliedckp.org and if you want to get in touch with me my twitter handle is janmaj

underscore mul or if you want to get in touch on github i'm not sure you can chat on twitter but yeah you can visit my github and check it out thank you