New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Human Readable Ethereum Transactions - Alex Miller

Ethereum DenverSat, Oct 9, 2021, 12:00 AM

This talk is from ETHDenver & ColoradoJam , the world’s largest Web3 BUIDLathon and Community Gathering. ETHDenver’s content is crypto and blockchain focused. Learn more: ethdenver.com Subscribe to our channel to learn more + connect on Twitter: https://twitter.com/EthereumDenver. Speaker: Alex Miller This talk was recorded Sunday, February 7, 2021. ETHDenver 2021’s content themes included DeFi & Money Legos, NFTs & the Creator Economy, ColoradoJam & the Next Frontier of Statehood, Protocols & Interoperability, Open Source & Public Goods, The Ownership Economy & Digital Orgs, Usability Design & Adoption and Legal, Privacy & Identity. Industry experts also weighed in on topics like decentralization, privacy, identity, non-fungible tokens, scaling, governance, diversity, and arts and culture in blockchain technology. The 2021 event was February 5-12 and hosted virtually in 2021 with 5000+ blockchain enthusiasts, developers and community members from 80 countries and 50 U.S. states. 🔴 SUBSCRIBE ETHDenver’s YouTube https://www.youtube.com/channel/UCgz9NU06t_FkT0Py1Vadczw 💡 LEARN ETHDenver’s Official Website https://www.ethdenver.com/ 👋 CONNECT ETHDenver Twitter https://twitter.com/EthereumDenver 📖 READ ETHDenver News on Medium https://medium.com/ethdenver 🛍️ SHOP ETHDenver Official Merchandise bufficorn.com 💬 CHAT Telegram https://t.me/Ethdenver Discord https://discord.gg/AxFmNdCVnU 📱 FOLLOW LinkedIn https://www.linkedin.com/company/ethdenver Instagram https://www.instagram.com/ethdenver/ Facebook https://www.facebook.com/ETHDenver/

Transcript

on the right you can see our state card packs now inside one each of one of those packs is a like it's like a debit card looking thing i just had it looks like this um it has this little chip and that's where the wallet goes so what this allows you to do is have offline backups um and there's all sorts of different backing up restoring splitting key mechanisms that we're developing and then it has a bunch of physical security features as well i mentioned it was wirelessly connected so we're aware of um attack vectors that that may introduce and we've designed with that in mind so if you want more information on this go to plus dot o slash lattice it should give you a a lot more information about the security features in particular and then the last thing i want to cover just briefly is that we have lots of dev tooling so we are trying to get um more integrations with you know defy apps that that our users want to use so if you are interested in pursuing an integration we have a discord server it's on our our sites so just um hop in and i can point you in the right direction for for dev to win okay so uh as far as readable ethereum transactions let's set the stage by going back to 2017 and kind of looking at how user experience has changed over the years so metamask was first launched in 2016 and i'm not totally sure what version the screenshot on the left is from but it's one of the older versions and as you can see there's just a lot more information than you might be used to today um it's a clunker ux it's a 2016 ux right and when you when you fast forward to the year 2021 those of us who have been using metamask for a number of years the the user experience is just so much better there's so many more features um screenshot itself doesn't really do justice to the point but it's just it's it's improved pretty precipitously over the last four years similarly when you look at dapps that are running on ethereum back in 2017 in the in the deck space you had ether delta which was essentially trying to replicate the coinbase pro experience but with 15 second to 30 second settlement times um so you'd be staring at this screen and then like every 15 seconds it would like update because trades have been made it was a terrible experience so uni swap and bennett the automated market maker and today um you know dexes in particular but also you know adapts throughout the space have just gotten so much better from a user perspective it's just when you look at these two uis it's just night and day um however if you're talking about sort of the last mile as i call it of you know using ethereum i i would kind of argue that your your final endpoint your hardware wallet hasn't really changed all that much um in the last four years so on the left there's the ledger nano s which is the hardware wallet that i used um for for a number of years before the lattice um and it was great for what it was designed for it was designed you know sort of in the early days of crypto for the purpose of really storing your bitcoins offline um having some sort of peace of mind that your your cryptocurrencies weren't being stored on like a hard drive because there were all of these stories about people getting hacked so that that was really to me the purpose of a hardware wallet back in the day so if you fast forward to 2021 the this this particular the ledger in particular has upgraded to the ledger nano x which i understand has you know more storage a few more features as you can see on the screen it certainly has more resolution so it's able to display a bit more data but sort of at the end of the day you know you're looking at a usb like uh sort of like something that looks like a usb stick it's just it's going to be limited by the size it's going to be limited by um the the the chip that you that you could put in that device so also in 2021 we have the lattice um so right off the bat you know personally i i would say this is a it is a better it is better experience just just due to the fact that you can display so much more information on one screen um that said it's not where we want to be right because the real problem here um aside from just you know not having enough information on a small screen is that even if you do have enough information you know hex strings are not really designed for users to interpret right so you take your average your average d5 user right um if they're looking at the thing on the right like yeah it's a lot of information but honestly what are they going to do with that um so we need to do better and that is kind of the purpose of this talk so the lattice um you know one of the major thrusts of this product especially in the ethereum on the ethereum side is that we want the the experience of using ethereum and signing transactions to be vastly improved and we want it to to kind of catch up to the uis that that we've seen evolve much faster on the website so we have kind of three major focuses in this in this vein so the first one we get for free basically it's the large screen it's the first thing you notice with the device like i pointed out you get to view a lot more information on one screen which is great the second um the second thing which i will be covering in this talk is readable transactions we want to actually you know take take that hex data and display it in a way that is at least more intuitive for the average user um and then the third thing which we haven't implemented yet but is on the roadmap is this concept of an address book because we're still um we're still using in 2021 we're still using hex addresses now you know ens has been around for a few years and that is certainly gaining traction um but you know on the hardware side it's difficult to incorporate that for for a few reasons um so at some point we'd like to get an address book in and maybe that would use ens but we're just not quite there yet okay but readable transactions we do have something for you here before understanding how the lattice makes transactions more readable i just want to cover what makes that possible which is the ethereum abi protocol so the abi stands for application binary interface and ethereum's avi protocol is specifically a protocol for serializing parameters that go into you know for example a smart contract call and it's uh it's a it's a protocol for serializing you know all these different parameters into one string one byte array that can be sent to an ethereum contract and parsed now of course if you have a protocol to serialize you can also use that to deserialize which is what we do with the lattice so um static parameters as i call them so like your integers your boolean stuff like that these are all encoded these are pretty easy to parse these are encoded as 32 by buffers because they are fixed size dynamic parameters strings and byte arrays they're going to have more specific rules as far as how they're how they're serialized depending on where they are in the api definition and if you want to learn more about how this works uh there's good documentation with the uh with the solidity docs that's in that link at the bottom there so once you have your parameters serialized you're gonna prefix them with a four byte function selector and that that function selector is basically just the four first four bytes of the cac 256 hash of the quote unquote canonical definition of the function that you're calling i'll do a very simple example here just to hammer this home erc20 transfer function very simple function anyone who's ever looked or worked with looked at or worked with solidity in any way should be able to understand what that first line is saying it's just declaring the function it's called transfer takes two parameters the receiving address and the number of tokens so to transform that into a canonical representation for abi purposes you strip out the decorators and in this example that would be the word function and you also take out spaces and parameter names and then finally if you have any non-canonical types so for example you ain't they need to be swapped with a canonical representation these are just um you can use them interchangeably in solidity but for for the purposes of api serialization you need to use the one canonical type so once you have that definition that's your canonical definition you do the hash of it and you take those first four bytes and that is your function selector so every erc20 transfer function that you would ever pull up on etherscan if you go to the transaction data field the first four bytes of that data are going to be that function selector right there so i went and pulled a random erc20 transfer transaction and if you go on ether scan there's two different there's three different views one of them is not useful here the two views relevant here are the at the top you have your raw hex string so this is what is actually this is the serialized call data payload with the function selector in front and then you have 64 bytes 32 per parameter and that first that first 32 bytes is going to have the address the second 32 bytes is going to have value now um etherscan i don't know when they did this it was maybe two years ago or something like that they they brought out this parsed view um which is the default which is that bottom one and this is using the api definition and it's it's you know stripping out that that function selector at the front and then it's slicing out those parameters so you know you're still the user still looking at hex here so it's not where we want to be but it's it's certainly a step in the right direction because it at least shows you what the different parameters are that you're calling so this is actually the inspiration for the feature that we have built into the labs so unfortunate incident here that kind of bumped the priority level of this feature there was an attack on a co-founder of a startup in the space who had a lot of nexus mutual tokens the attacker was able to gain control of this this person's laptop and swap out the metamask instance so that whenever he went to interact with the contract like for example calling harvest on some yield farm it would take that transaction it would just replace it with this since various one and it would send that to his hardware wallet which he was using so he actually was using a hardware wallet for this transaction and what came across was that input data at the bottom there and for whatever reason he either you know just assumed that it was fine or was unable to read that in either i mean regardless of what the reason was uh it just wasn't a very good ux it was in the ux that afforded him uh sort of the the the skepticism of the nefarious transaction so he signed it unfortunately i just lost a ton of money so yeah i mean this is we saw this happen and we had already had this feature in development and we were like we need to we need to move a little faster on this okay so how does the lattice project against this so we have the ability to use abi uh to decode this raw hex blob and i'll show you what that looks like in a sec but just the mechanics of how this works so the a user would first identify contracts that they want to you know be using in the future for example the uni swap v2 router would be a common example and the first step is that they would load abi definitions um and i'll show you in a demo real quick how that works but basically they initiate this request the device asks and validates that they that they initiated that request and then once they say that they did it's going to start negotiating with the the interface that is loading these definitions so once they've all been loaded they are not yet committed to the device they have to be approved and on the right here it may be hard to see but it's it's showing you a set of canonical representations of these api definitions that you're loading in in this example is the uni swap v2 router so once you approve these it's going to commit these to secure storage which means that you know we have this level of confidence because the user first of all told us told the firmware that they initiated the request and second of all they told it that the the data that they're loading into secure storage is valid so we have some level of assurance that this is a proper api definition and at that point any transaction that comes through is going to be able to access the definition and use it to mark down the hex so this is actually the same transaction in a different view again this may be difficult to see apologies if it is but it's showing you the name of the function in this case swap exact ether token so immediately that gives me a sense of what's going on here and then it's going to deconstruct all the parameters and give you the values associated with those parameters it's also going to obviously give you the human readable names of those parameters so just as a quick example just to point out that first parameter there is going to be the amount out min which is the number of tokens that you're receiving and you probably can't see that but it's like 1.08 times 10 to the sixth in this example this is one dollar and eight cents worth of usdc being received usdc i didn't know this has six decimal places for some reason so that's what that e6 is unfortunately because we don't have context it's like what this transaction is doing at a firmware level we have to use atomic units as i call them so for example with ether that would be whey rather than the e unit but it's still in base 10 which we think is a pretty big improvement at least over displaying this in hex so um the process of what's happening here for those interested when you have abi definitions loaded into secure storage and you have a transaction come in the firmware and it's an ethereum transaction you should specify the firmware is going to first of all make sure that there's contract data there's call data in transaction so you need to have a minimum of four bytes for that function selector and once it confirms that it's not you know just a simple e transfer it's going to fetch the api definitions from secure storage and it's going to search for an abi definition from that set um it's going to search for a match using the first four bytes of the call data from the transaction coming in so if it finds a match it's going to go through a series of checks and it's going to attempt to deserialize that data now we're pretty strict on the firmware side so if it fails any one of these checks it's just going to sort of abort the process and this is going to show you the raw hex so in a sense that in itself is a sanity check for the user so if i know that i've loaded up uni-swap api schema and i go on uni swap and make a transaction and it shows me hex that might be an indication that something has gone awry and that might give me pause as a user so that's really what we're trying to afford here we're trying to give the users at least some you know leverage over an attacker who could just you know swap data that they otherwise wouldn't be able to read we want to give them you know the ability to at least have some sort of defense mechanism against that um so just one more point we like i said we're pretty strict so you know if we find a match we we have to deserialize every single parameter all of the types have to match the order has to match and we can't have any leftover data in the call data and we can't we can't overrun the call data either so there's quite a few sanity checks that go into this so assuming we have found a match we were able to deserialize we're going to loop through all of the deserialized decoded parameters and we're going to display each one individually so what we're doing here is we're just building we're just building a display um and if the user approves off of that display we just hash and sign the original payload so we're not mutating any payload here it's just purely a display feature um and yeah again if any check fails we display the original payload in x okay so i'm going to do a demo here see what the lattice is like um okay so i have my lattice here sorry the screen is reversed um so i'm just going to pin in okay so uh yeah a lot of text on the screen but if you go to your smart contracts tab i don't have anything saved in there and i am going to it's going to take some coordination so apologies this is a little clunky i'm going to go to uni swap and i'm going to try to well first of all so we have a fork of metamask that we maintain that gives you lattice access so technically anything that you're using that uses metamask should work on the lattice okay so i'm going to swap point one ether for some ave i'm actually going to stop it just let me know alex and i'll go back and forth for you oh you will okay i can once you start sharing i can bring it up and take it down if you just let me know okay i will do that great go back to so uh i also have to like have this beautiful uh okay [Music] so i'm gonna initiate this transaction reload should pop up in a second here so here's the hex blob um as you can see uh yeah there's actually two screens worth so so you you are able to page through if you if you want to look at additional data but yeah this is like not super useful to me if i didn't have very much money on here which i don't actually um i would probably just approve it but if i have a lot then i would very much prefer to look at the api view so um i can exit out of that i actually need to go sorry now i need to go to the grid plus web wallet which i should have had pulled up [Applause] sorry okay um so the grid plus web wallet is a very very simple wallet tool but it's really more used for management of the device and for things like this so if i want to add the uni swap router functions i would go to the web wallet i'd search for that address this is the router we do address um and it's going to search for etherscan and find the number of api functions that are state updating functions so we don't we don't care about things like view balance um this is really only relevant for things that you would you would be using when making a transaction so while there are more than 20 functions in this contract there are only 20 functions we would actually interact with okay so i'm going to send those to the lattice it's going to pop this up this screen again is going to say you're trying to add 20 20 functions yes it did initiate that so it's now negotiating with my browser it loads two at once because the um the data that goes into them are very fairly large we do have a kind of constrained request size here so it's just going to take a minute and once it's done it's going to start showing me those definitions okay so bring this up so as you can see um like i was talking about the tightly packed um definitions there's no parameter names just the the types i'm going to go ahead and approve these proof it's going to bring up another set i can actually only do 18 at a time okay so it says they're added this is good so if i were to go back to this smart contract screen it would now say instead of zero i have 20. all right so now i'm going to go back to uni swap i'm gonna do the exact same transaction i'm actually going to stop sharing just so i can show you this screen [Music] okay so now when it pops up it should look very different so yeah um loading those contract definitions allowed me to um to start getting more parsed views for when i use you know uni swap in its function so again you can scroll through there's a few more parameters um and they just kind of give you human readable names and you went or base 10 numbers okay back to my dark okay so yeah i mean i'm quickly running out of time here so i'll just say that this is not exactly where we want it to be um there's much better user experiences that uh that can go into this that would not be terribly large lifts so obviously having to find the uni swap v2 router specifically as a singular contract is not the greatest user experience so we really prefer to have some sort of searchable registry or like even a d5 pack that would just load a bunch of d5 functions out of the gate the other thing is we can actually preload functions so the erc20 functions are already pre-loaded in here so you will never if you have a lattice you will never have to look at hex for a erc20 transfer uh better definition management in the lattice i didn't cover this i'm just going to skip it for now but basically there's not a lot of resolution in what you can delete if you want to delete stuff and then sourcify is a great project a great open source project um with collaborators from the ef that is working on a similar problem to this working to to get a better sort of data source for these api definitions um that would have uh you know validation built into the metadata which would potentially allow us to load these in real time i don't want to commit to that need to look more into it but that would potentially be a future direction okay so um just real quick a little plug here grid plus we're hiring we are very small team we need help so if you are a software engineer who wants to work in the crypto space um give us a shout see what you would be doing specifically is you know i talked about the integrations with third party applications you'd probably be maintaining some set of dev tools and also maintaining some integrations uh that web wallet we're adding features to that as we add features to firmware so that would need to be maintained as well we have stuff going on in the cloud as far as message routing which we um also want to allow users to kind of self-define so i'll have a blog post coming out on that shortly and then additionally lattice software there's there's stuff that runs on the the linux chip inside of this this lattice specifically that you would be working on and yeah like i said we're a small team so you'd be doing a ton of stuff so if you're interested careers at groups and that concludes readable ethereum transactions so i guess one minute if there's any questions uh let me know otherwise feel free to reach out on twitter thanks thanks for having me and thanks for thanks for watching i don't see any uh questions there's some good comments though if you want to check them out yeah just put a comment or question uh yeah we'll be able to use wallet link or wallet connect uh we just flashed it on the screen alex you can read it right there yeah i see it um [Music] probably not uh we'd explored this before but i think generally speaking we don't want to be in the business of being a wallet provider so um honestly i have to look more into it i can't remember where we landed on that but right right now we're you know we're pretty content with direct integrations and our metamask work um eip712 i want to get to this real quick we really want to add eip712 there's some technical blockers at the moment um once we're doing a firmware update which is going to take some time but once that's in um i actually have the code for eip712 in it doesn't fit and it requires some dependencies we don't have so we are working on that um well let's see native ens i really don't have time to get into why that's difficult for us but basically generally speaking we want users to pre-commit data to secure storage we don't want to just be pulling data from the internet and using that on a secure screen to display transaction data so that is the real problem with ens that's not to say there aren't solutions around it but that that's kind of the blocker at the moment

Automatic transcript — names and jargon may be misspelled.