Build and secure your use of a dApp with hardware device

EthPrague 2024 · 31 May 2024 · 14:52

Developers can connect a dApp to a Ledger hardware device through four integration layers, and this session demonstrates the quickest one, the connector libraries, with a small sign-a-message web app. The layers run from apps embedded on the device to connection libraries for USB and Bluetooth, blockchain support in the companion app, and live apps inside it. In the demo, the app is cloned from a public repository, signs a personal message through the device's Ethereum app, and the resulting hash is checked in an online code runner. In Q&A, the presenters describe a clear signing initiative meant to show users what they are signing rather than only a hash.

Speakers

Topics

From EthPrague 2024, hosted by ETHPrague.

Transcript

[Music] JM everyone happy to meet you I am omj from inot Club I will be moderating um afternoon session of the Le stage we have like we are packed with amazing talks so let me introduce our amazing speakers we have next session is build you uh build and secure your B back uh to interact with the ethereum app we have acam and ATM from Ledger please welcome them thank you very much hello everyone so yeah we are Akram and Ian and today we're going to talk to you about Leisure and more specifically

how you can integrate to The Ledger ecosystem as a developer uh and we'll go through a little proof of concept together to see how this all works in in practice because there's no better weight of learning than doing things yourself um so before we start who here is is already familiar with Ledger by show of hands okay that's um who here has a ledger device at home all right um so for those of you who don't know yet or at home watching this um we essentially make Hardware devices to help blockchain users secure their assets and we also have a software uh wallet that's connected to the device that helps people interact with it um one of these

devices is The Ledger Stacks you might have heard about it it's the brand new device it's very cool has a e in display it's curved on the side it does not come pre-installed with a chess background but you can have your own you can have an nft on there if you want to it's very cool and if you want after this talk you can come and meet us and you can come and try it and play with it um all right let's dive in um so yeah I went through this already um okay so the different ways to in to integrate with Ledger let's let's dive in um so first you have the embedded apps which is the base layer so essentially when you turn on your device

this is what you see often you've opened your device you've maybe opened the ethereum app on your device this is exactly the embedded app level uh you can build your own you can submit it as well um then we have another layer which is the connect your app so this is more like a set of libraries to help you interact with your device typically you want to connect your app to your device we're talking about USB connections or Bluetooth um you know for for both web desktop and mobile uh then we have two parts which are really linked to Ledger live so the companion app I mentioned that uh that's more user friendly way to interact with your device we have the blockchain support so this is how you

can really interact with your blockchain on the Leisure Live app so here you would have you know the native tokens management um yeah so essentially the apps in ler life to interact with your device and we also have live apps which are all the decentralized apps um you know um also that lives on this layer to interact with your device uh you can build pretty much any of these uh layers and submit them and be integrated with Ledger okay um and now I is going to talk to you about what you need to get started how you can start integrating your projects with

Ledger thank you um soin presented you the different kind of integration we do uh just to quickly get back so we will focus on the second one uh the connector app option um you have these four different uh Pathways the second one the connector app is the fastest straightforward way to integrate uh with The Ledger Hardware way so we are going to uh kind of presentation Workshop so if you want we can stop if you want to take pictures on how to do it don't hesitate to interrupt me so to connect your app let's say you have a web application a dab you want to allow your dab to be able to communicate

with the with the Ledger Hardware device there is a straightforward way to do it so let's dive in with a quick uh kind of web app we build and uh put it on GitHub I will give you the link of course and show you how it works so you just need a kind of uh package manager of course a n Hardware device ler Nano device an etherum address on your etherum embedded app and some libraries that I will show you uh just after so this is the link of the repo if you want you can take a picture do it at home um maybe this you can't see but on the here

on the in the bottom you have the link of the repo so you can you can clone it uh at IL Mig Ledger SL example Ledger you clone thiso and you will have a bunch of different workshops uh web applications you can play with and the one we are using today is the sign personal message uh tutorial we have uh and we showcase to explain how it works so this uh this Workshop um is using the EIP 91 functionality that will interact with a ledger Hardware device through the ethereum app so once you clone this rupo uh you just have to it's ready so you just have to do an npm install and then npm run start

and this is how it looks like so it's not pretty the goal is here to show you uh how quickly you can build it it's a really simple web app that will allows you to connect your Hardware device and sign a message with your personal address so you have these on local host of course so when you have your web app launched you just plug your uh Hardware device open the ethereum uh app and click on hash my message this is what it it's written here so you do it so you open your your uh your etherum embedded app you have the option to sign the

message you sign the message then it will display you a kind of hash the hash message will have it and below it you will have your address how could I be sure that I am signing this message uh that everything is working correctly you have a kind of tool called run kit so once you send your message you take the hash uh sorry I pushed one two more oh no you told me this way yeah yeah perfect so you go and run kit you take the hash you obtained earlier you put your hash On The Run kit and uh you will be able to verify that you are the

signer of the message so this is how um and this is the bunch of code you have to run on the Run kit so it's already there so how does it work I show you it's a really simple uh web application no no uh no more no no complication on on the web application what you have to do import the right transport Library um the different Hardware devices uh Ledger Hardware devices you can plug it through USB you can also plug it through Bluetooth with your mobile phone so depending on what your web application where your web application is working on a phone or on a browser you choose the

right transport Library uh so you ensure that you using the right import also and uh we have some docs with all the functions you can use so depending on what you want to do if here I use only the functions responsible for signing so these are the function for the signing part if you want to do kind of s reive swap depending on the complexity of your web application you will have different uh functions that you can use and here this is kind of uh cinematic of the assigning uh um signing compartment we have on the web application so you have to uh open the connection and do the needed steps to be able to sign um the the

message and on top of that so when you will try to do it of course you won't succeed at at the first time you will have bunch of errors that will show up uh you just have to know how to handle the calls and also to handle the errors and on top of that on top of the functions you have kind of translation of all the errors you can have that will help you understand the the behavior of your device with your web application and ensure that you're uh building this in the right way and that's it for the explanation I think yeah so this is really the goal of

this presentation was to show you how it's simple to integrate uh your Ledger Hardware device with for example an application you already have or you want to to build even if it's for a sign in or for signing also transactions um the as you saw the the the web application is really simple uh no complexity uh really straightforward so this is this is the goal of this presentation uh we have Al of course other kind of Integrations but this one is the more efficient in term of uh efforts Workforce time you have to spend on uh and yes uh that's it um so we have these Integrations that are most of them

uh can say open open source uh all the repos are accessible uh uh you have a ledger HQ repo on GitHub you can have a look at it you will find all the embedded app we integrated from ethereum to bitcoin to pado to really everything you have all the blockchain uh we support today that are integrated with the code that you can read on on the GitHub the live apps also the the the plug-in everything is on the GitHub and accessible to you so don't hesitate to to have a look uh at that so we try to stay open an open platform but of course we we have to to have the final say when you try to integrate something it may

take time also so don't be sad if you some someday you try something and it take too much time and we also want to ensure the kind of quality for our users uh and security when they use the hardware device so we that's why we have the final say uh at the end uh and here are the different links you can you can have a look at so the first one the developers. ledger.com you will find what I explained earlier uh H and and myself you will find other also tutorial tutorials documentation other libraries code Parts code explanation everything if you want to try to play with Ledger

Hardware devices as a developer uh we have a Discord where you can reach us when you have questions and if someone from Ledger is available and also we have a community that can answer to you also don't hesitate to to dive into the Discord we have a kind of um blog where we explain some some Journeys and the most important part also with the developer portal the repo The Ledger HQ repo go on GitHub type Ledger HQ and you will find everything I explained uh today and thank you so we have time for questions don't hesitate to

ask thank you very much [Applause] thanks any questions it was clear perfect that's a good sign if there's no questions uh I'd love to take the privilege and asking one questions that all the developers here you just share a lot of resources how they can build a secure app using utilizing Ledger if there's any application you'd like to see that like nobody really tackle or you want to see that how people are utilizing Ledger a little bit more any idea tips the F you are go ahead the first idea and it's good question because it

is a subject we are trying to tackle today and we will push this year is uh what we call the clear clear signing so what we are trying to do this year and the the next years and after we are trying to push a clear signing initiative that will allow people when using a hardware device to so what when we say clear signing it's allow user under understand what they're signing so when they use a hardware device or even a software wallet like other competitors they have to understand what they are signing not only a hash but to know that they are doing a send a receive a swap everything uh and um avoid them to be uh scammed and everything so there

this is there is this initiative we're trying to tackle uh this year we already began actually but uh we are trying to uh gener General iiz it my English is not so perfect uh to um to to a wider scope and uh this is a subject we began this year uh like for other partners um we also trying to push this to developers so yes if there is a subject you would like to tackle this will be a high priority for not only Ledger but also all users on what users very interesting so if anybody want to know about Ledger more uh please catch these amazing engineers and try to learn

more and testing Hardware worldly the newest ones going to be very curious you know very uh interesting to try out please give amazing Applause to our fantastic speakers and we will see you soon thank you very much thank you and if you want to have a look at the stacks device uh yeah come over and don't yeah to ask us