Mobile Key Management and dApp Interaction
LisCon 2021 · 20 Oct 2021 · 17:30
Dmitry Bespalov and Andrey Scherbovich speak on mobile key management and dApp interaction at LisCon 2021 in Lisbon. Both are credited with Gnosis, and Bespalov worked on the Gnosis Safe mobile apps. The talk addresses how keys are handled on phones when using decentralized applications.
Speakers
Topics
From LisCon 2021, hosted by LisCon.
Transcript
my name is dimitri i'm leading the mobile team for the gnosis safe hello i'm dmitry from dignosessafe and today together with andre we're going to talk about key management and dap interaction so to start i want you to imagine a fictional character let's call her maria maria is a portuguese grammar specialist and right now she's walking up and down lisbon street wondering how her recent financial life has the same same path she feels sad and hope hopeless
however she thinks that maybe near's future could could bring some change when she arrives at the party where where she sees two of her friends matteo and another friend she learns that matteo wants to to get the group into crypto and he suggests to create agnosis safe so that they could pull their funds together and buy an nft all right how to start so mateo creates agnosis safe on the web interface on the mobile we we currently don't support creating the safe
and he needs to add an address of both of his friends to the safe so he asked them to install the gnosis safe mobile app where they could generate generate a new key right within the app so that they could share the address with mateo all right seems easy they could they could add add their keys to the safe and when the keys are generated and the mobile app on ios we store the keys in a key store which is a secure database that is operating system provides and on android we store the keys an encrypted database encrypted by the keys that app generates during the installation
and then the keys are stored in the um in the keystore system we could use a secure secure enclave on ios which is the hardware hardware component that that stores the keys securely and the keys never leave it however it doesn't support the ethereum hashing sha-3 and it doesn't support elliptic curve variant that is used in ethereum so the next step is the friends need to pull the money to get together to purchase an nft so the easiest the easiest way for them as a newbies actually just give the money to mateo and he would he would just transfer crypto since he's more advanced user to the safe
goes goes ahead to make a transaction um for for purchasing the crypto so people who who connect their mobile wallets to the safe they would receive a push notification which when you open you could see you could see transaction details and confirm the transactions so maria confirms it as well as your other friend but the transaction cannot be executed from the mobile app yet it needs to be executed from from desktop so which material does and after the transaction is is mined they get their nft cool well seems to be easy and life goes on and maria goes ahead
and lives her normal life and every every morning she wakes up and checks some balances goes to the go to goes to the collectibles details to see her nfts however she finds nothing at least on ios it's because our app recently have has been blocked by apple app store review guidelines since the nfts in the wallets are violating the the terms about the digital content so we removed the access temporarily however you could also access your nfts on android and also on the desktop so time goes by and every every day maria
opens opens the save to check if if their investments went up or not and one morning as she wakes up and casually unlocks her phone something doesn't seem right so she checks the prices and it seems that everything has dropped whoa that was that was quite significant money for her that seems just evaporated she feels anguished well what what could she do it turns out there's still there's still half of the funds left in the gnosis safe that they could they could use somehow so maria starts to research these the websites and the diff defy ecosystem
and she finds that there is there is a website called balancer and she could she could make an investment with the rest of their funds on the balancer so she wants to do just that in order to connect the safe mobile app to the balancer website she goes to the experimental feature and enables enables a toggle that allows to connect the app to the two external dapps and then from safari she could open the the balancer web page connect connect through the wallet connect with ignore the safe and the connection is established in this case nazi safe acts as a as a wallet in relation to other dap in
this case the balancer so when she does that she creates a transaction and balancer and gets the confirmations from her friends however she cannot still she still cannot execute the transaction because the app does not allow it in order to do that she would need to do transaction execution from the desktop or with the connected wallet via wallet connect so she decides to to see what it what it looks like to connect the wallet with the wallet connect and after installing several other wallets she picks the first one that she thinks would work she picks metamask and adds additional owner key um via wallet connect so she connects it with the with the metamask confirms and
the wallet has been connected so now she's able to create it to create and execute a transaction she presses execute button however nothing appears she tries again one minute two minutes three minutes nothing's still there so it turns out that the bridge server that connects both transactions is flaky and and she she just doesn't receive any messages after several attempts eventually it starts to work again and she executes the transaction but it fails well why does it fail it turns out when when she waited for too long for the transaction execution the price has
moved and so the investment price is invalidated because her slippage tolerance is violated so now she needs to make a transaction again from from the start so she goes ahead creates a transaction gets the confirmations from her friends and executes it via meta mask and this time it's successful now with all this with all this stress she decides to take a break from from crypto for for a while and then comes back to her normal life being portuguese drama specialist and several weeks later someone someone knocks at her door she opens the door and sees
mateo who is agitatedly speaking to her and pointing on a mobile device and talking something about the prices so what happened was um was that their investment actually tripled and not on not only they could cover the laws for the nfts that um that were a bad investment but also earn something so of course of course they're happy but there is something that that is not that doesn't feel good material learns that the way how how maria connected the keys was not the secure way because she connected both of her he of her keys and stored them within within the same device and this is this is not not a good thing to do
so instead she brings hardware wallet uh with him and helps to set it up and replace another keys with the save so every signer on the on the safe is now has hardware wallet and this is this is a feature that we added recently so you could connect a hardware wallet to the safe you just add the key and connect your wallet there so for better security avoid storing multiple keys on the same device prefer using keys for the singular purpose and use hardware wallets for increased security so after after all this another group of friends has
has been interested in their success and they wanted to join during their safe so it was possible but mateo had one condition so that the other group would have would have need to collect more signatures in order to make transactions to talk more about that i please welcome andrei hello everyone thank you for coming my name is andre and i'm software engineering since
recently i'm also a product owner at another safe on mobile so to continue and finish the story of the demon what happened is that another friends of mateo and maria wanted to join them and to pull the funds together to manage them together but these friends are not so experienced so marie and mateo decides that it they decide to create two separate groups in one group they would be mateo and maria and they would require only two signatures to execute the transaction but another group their friends would require at least four signatures to execute the transaction and here we come to a very nice and cool property of the acknowledge safe account that actually is not only a wallet it's a dap and the best
demonstration of this duality is the fact that you can create you can make your safe as the key in another safe so why would you want to do this well again we want to create a use case when you need two confirmations from one group or fork information from another group to execute any kind of a transaction so how is it possible to organize you can create a one save which would require one of the two signatures and it would have only two owners one owner safe would require two autofan signatures another would require four out of m signatures in this way you achieve your desired properties to generalize this idea you can treat
any one out of n multisig as a or condition and any m out of n multiseek is an end condition and basically you can build much more complicated security schemes and use cases just using these two properties so mobile app on the other hand can be a perfect companion in this user experience but of course what you can do you can use your mobile safe as a key in another safe and using together mobile app and web interface would make this experience much smoother let's come to a more sophisticated use case i'm a family guy and have a wife and i have two nice kids michael and lef so i would like to create my family safe
with some property security properties that i want to design so in these properties my wife or i should be able to spend up to 500 euro per day euro denominated in some stable coin so all all of our funds if we both confirm this transaction our kids mikhail and lab should get the approval from myself and my wife to spend up to 500 euro or get the approval of both of us to spend more so this is quite sophisticated uh use case but let's start with simple steps first i want to make the condition that my wife or wife myself or my wife should be able to spend all funds if we both confirm but our kids can initiate the transaction for that we can create two out of two
multisig and we can delegate for our kids a key so delegate key is not a full owner but they have some niche properties so a couple of words about delegate keys delegate keys is not a smart contract feature it's a convenience feature it's a layer that our transaction services allow and they allow delegates to initiate transactions and then myself and my wife can approve it and execute it so kids can always initiate a transaction on the other hand delegate can be used for other use cases for example we can receive push notifications for our hardware keys on your mobile device also thankfully to delegates okay now we want to add the condition that myself or my wife would like to
spend up to 500 euro per day using our family safe so how to achieve that that many of you already know that we have this pending nice nice feature called spending limit so if you enable it's in your web interface and you're safe and you specify who exactly is allowed to use this feature so it doesn't need to collect all these multi-signature requirements to use this feature all any owner mentioned here can spend the funds up to some limit so yeah we decided to enable this feature for our family safe and it helps in our use case um the way why it works is because safe as a smart contract it supports modules and modules are very powerful so modules
allow executed transactions within all required confirmation without requiring all confirmations as modules are super powerful they're security critical that's why you should be really careful if you want to enable other modules in your safe web interface but you can already use this uh spending limit module okay now back to our use case spending up to 500 euro per day uh the way to do so what i could do i could create a save to auto four when me and myself will have a key with my wife and both our kids will have save two out of three where i my wife will have a key as well
yay we will achieve the property of spending up to 500 euro daily limit requirements because to initiate the transaction our kids would still require one of our signatures and we can spend up to half 500 euro per day easily but we're still not there yet and why we're not there yet is that the fact that we have requirements that all our funds should be spent only we both confirm it so how could we achieve this property using safe contracts since since since contract version 1.3.0 we added support of guards and the guards are separate smart contracts that have a nice property that can they can
do the checks before and after transaction execution so for my use case or for my example i could design a guard that would explicitly check that both myself and my wife provide the signature or a more generic use case we could check that we have only one signature for a single owner from all the nested safe structures so using this combination of the guards and the modules and the nest that saves i achieve the property that i have in my family safe that meets all the requirements that i would like to achieve so yeah just to finish our talk i would like to recap what we have with mobile apps mobile apps right now are still limited you cannot do everything there you cannot create a save there but they
are really helpful you can load there you save you can use already many types of owner keys and recently we added the ledger key that allows you to use the save in a really secure way so good products as you know they focus on specific use cases maybe like cars and focusing on the user groups that are just for personal usage within the safe team we try to build in ecosystem or generic products that would enable thousands of use cases for thousands of users more about our ecosystem and our vision
tomorrow there will be talk by richard meisner who is here and please come and visit it and to see where are we going to go with our organization thank you thank you guys