Why Nostr? What is Njump?
2023-12-18 16:41:33

Pruk on Nostr: Many of you who have explored the world of Nostr for some time probably have a good ...

Many of you who have explored the world of Nostr for some time probably have a good understanding of the Private key or nsec. This is like a crucial key that we use to authenticate and sign events in Nostr. If your Private key is revealed to others, it may not be good, as malicious individuals could potentially misuse your account by impersonating you.

One interesting option for securely storing our Private key is to use the Nostr Signing Device or NSD. It is a hardware device that helps store your Nostr system key and allows you to sign various events. It’s similar to a Hardware Wallet used for storing keys and signing transactions in the Bitcoin system.

The basic operation of the NSD involves working in conjunction with NIP-07. The event data being generated is sent from the client to the NSD through a serial port for the signing process. The NSD then returns the signature to the client.

Currently, you can purchase the NSD on the LNbits website, and the price is around 25 USD.

image

The NSD mentioned earlier from LNbits is an open-source device, meaning that all source code is publicly available. You can use it for your own development, and the equipment cost is more affordable than buying from the website. Therefore, in this article, I will guide you on creating a DIY NSD on your own.

Let’s start by looking for the necessary equipment. We’ll be using the ESP32 development board, and any model will do. LNbits recommends the LILYGO T-Display S3, which aligns with their NSD. Another option I suggest is the LILYGO T-Dongle S3, and personally, I’ll choose this one because it comes with a built-in USB, making it convenient to use like a thumb drive. If you’re on a tight budget, you can also choose a bare ESP32 board without a display. I found the cheapest option at around 5 USD. I’ve created a comparison table as follows:

ESP32 Link Price (USD)
LILYGO T-Display S3 https://s.click.aliexpress.com/e/_Ddy7739 ≈20
LILYGO T-Dongle S3 https://s.click.aliexpress.com/e/_DmQCPyj ≈15
ESP32-WROOM https://shopee.co.th/search?keyword=esp32 2~10

Now that we have the equipment, let’s install the software. We will use the Arduino IDE for uploading programs to the board. You can download it from

https://www.arduino.cc/en/software

Once you have installed Arduino IDE and opened the program for the first time, install the ESP32 board. To do this, go to File > Preferences.

image

In the Preferences window, copy the text:

https://dl.espressif.com/dl/package_esp32_index.json

Paste it into the ‘Additional Board Manager URLs’ field and then click OK.

image

After that, go to the Arduino IDE, then navigate to Tools > Board > Boards Manager…

image

In the Boards Manager window, type ‘ESP32’ in the search bar. After that, click ‘Install’ and wait for the download and installation process to complete.

image

After successful installation, go back to the Arduino IDE, then navigate to Tools > Board > … You will find a list of ESP32 boards. Simply select the board you are using.

image

If you don’t find a matching model, you can choose ‘ESP32S3 Dev Module.’

Next, let’s proceed to download the NSD source code. The source code is available on Github at this link:

https://github.com/lnbits/nostr-signing-device

For those using the LILYGO T-Dongle S3, similar to my choice, which has a smaller screen resolution than the LNbits T-Display NSD, I’ve forked the source code and adjusted the UI to fit the T-Dongle screen size. You can find the modified code on Github at this link:

https://github.com/AlbiziaLebbeck/nostr-signing-device

Once you’ve downloaded the NSD source code, copy all the files in the ‘libraries’ directory, including:

ArduinoJson QRCode TFT_eSPI tiny-AES-c uBitcoin

Paste them into the ‘libraries’ directory of your Arduino IDE. You can find the location of the ‘libraries’ directory under File > Preferences in the ‘Sketchbook location:’ field.

image

When you have installed the libraries, open the file ‘snsd > snsd.ino.’ You will see the entire source code, as shown in the image below:

image

Now, we are ready to upload the program. Connect the ESP32 board to your computer using USB, then go to Tools > Port to select the port corresponding to your ESP32 board.

image

Check the board settings, as shown in the image below:

image

Once everything is set, click on the ‘Upload’ button, as shown in the image below:

image

After a successful upload, you will see ‘Done Uploading.’ This concludes the installation process.

image

If your NSD has a display, you will see the logo as shown in the image below:

image

For initial use, record your Private key on the NSD. Go to Tools > Serial Monitor, and you will find the Serial Monitor window. Set the Baud rate to 9600 as shown in the images below:

image

image

Then, type the command ‘\restore’ followed by your Private key in hexadecimal format. For nsec, please note that it is not supported, and you need to convert it to hexadecimal first.

image

Once you’ve successfully saved the Private key, you can check the Public key using the command ‘/public-key.’ Your NSD is now ready for use.

In some cases, certain clients may not support the Horse extension, preventing you from accessing the system using your NSD. You may need to wait for further development. The clients that I have tested and confirmed working are:

I hope this article is helpful to all Nostr enthusiasts. If you have any questions, feel free to reach out to me at pruks@siamstr.com. Finally, I wish you all happy and secure travels through the Nostr world with your own NSD.”

Author Public Key
npub1pruks45lzhclsq6xdpzlj48gkwz0aenxn2jcnjzmsc8a8ll9ngys9pnj2f