Grin ledger hardware wallet progress thread by @markhollis

Yes, Grin does have view keys, just like Monero; see

3 Likes

Is that documented for grin-wallet somewhere? I can remember having that searched before and I could not find any hints. Maybe it has different naming?

Edit: I assume it has not been implemented for wallets yet.

1 Like

Update for weeks 27/04 to 11/05.

  • I have integrated my existing code now into libwallet.
  • The approach now is to add a ‘–hardware’ flag to commands, to test during during development. This can change later. This is mostly done now.
  • I focused mostly on the receiver function these weeks. In particular on the offset adjusting and the payment proof. On the firmware side, I worked on the nonce generation using the secp256k1-zkp library. I was also looking into the payment proof signature.
  • Last week I was sick, I couldn’t really work as much as I wanted to do.

The first thing I will do now is to work further on the initialization of the hardware wallet, on the grin-wallet and the firmware side. After that, I will work further on the different items in the SRS workflow, starting with the sender.

Some things to keep in mind:

  • To communicate between grin-wallet and the firmware, APDU packets are needed. Items like payment proofs need to be serialized in a fixed format. This can sound obvious, but the grin-wallet has to be able to decode the data from the APDU packets.
11 Likes

Looks like there is a bunch of APDU related crates available: https://crates.io/keywords/apdu

2 Likes

@mably I use the Ledger library from Zondax.
My last comment was about the thought that the library provides functionality for sending commands and getting data answers back in bytes. But it is up to the developer to decide how the data answers are formatted, which data to send and in which order the bytes appear.

6 Likes

Update for weeks 11/05 to 25/05.

  • Researched initialization and sender/receiver wallet functions further + implementation.
  • Made an interface that encapsulates the logic for dealing with the device and keys, similar to how Beam uses a KeyKeeper interface.
  • I researched rangeproofs somewhat these weeks, but it isn’t yet clear to me how I should approach this further. I’ve been reading through GitHub - AdamISZ/from0k2bp: From Zero (Knowledge) to Bulletproofs - writeup and through how BP’s are used in grin. Here (grin/proof.rs at 1b8acee72e7a4236cdf8561a7af5f894bfe11985 · mimblewimble/grin · GitHub) it seems like BP’s should be created at the device. Creating BP’s is however computationally expensive for the HW. Maybe the HW should do only the part before the call to secp.bullet_proof()?
    *One thing I’m thinking of as I write this, in grin-wallet, an input is a Vec<(Identifier, Option, u64). The Option<64> is an mmr_index. See: grin-wallet/types.rs at bdc5bd748a4e399e6febc5e3c4974e569ee39638 · mimblewimble/grin-wallet · GitHub. I should look into how this MMR index is generated.
  • I did some work again on the Grin++ side. I found a C++ library to work with Ledger, which I can communicate with the device. The plan here is to implement the same ideas as I already did in the grin-wallet. Furthermore, it is informing to see two implementations of the protocol; it makes somehow the protocol more clear to me at certains points.
  • I made a document for grin-wallet and Grin++, for listing parts in the source code that should be delegated to the HW wallet. (The documents cointain permalinks and some comments about the code structure.) However, these are not ready to share yet.
19 Likes

You might be able to split the bulletproof up into pieces that require the user’s secret keys, do those operations on the HW, and do the rest of the proof on the machine. Not sure how intensive of an implementation challenge that would be, or how much work it will involve.

2 Likes

Is it possible to embed Grin into Trezor in future?

2 Likes

This would require a separate application for Trezor. But with Ledger wallet I should to make sure that the interfaces are defined in such a way that future hardware wallet can be supported.

11 Likes

Update for weeks 25/05 to 8/06:

  • I was sick for the greater part of the last two weeks. I couldn’t make much progress.
  • I am writing an RFC that standardizes the serialization of a packet necessary to send to a hardware wallet.
11 Likes

Hi. any update?
Hope you healed man.Take care.

1 Like

Hello,

I’m still somewhat sick at the moment.

  • I received the Beam Ledger app code, thanks to Vladislav.
  • I worked further on said RFC and the reference implementations. I try to publish this as soon as possible.
  • It is best to keep in mind that a Trezor wallet may come. So the code should be separated between which is platform specific and what is not, so that code can be reused in a future Trezor wallet implementation.
  • There are some C libraries for working with PSBTs (BIP174), which can be useful on the firmware side.
18 Likes

This is FANTASTIC news - greatly appreciate all your efforts!

2 Likes

Are you feeling any better?

1 Like

Not really, but I keep working on it if I am able to.

4 Likes

Update for weeks 22/06 to 06/07:

  • These weeks I worked further on the Ledger firmware. I concentrated on reusing parts of the Beam firmware.
  • I started implementing tests in C and Python.
  • The memory space of the Ledger device is rather limited. So I would first implement the firmware without the Grin version of PSBTs.
18 Likes

Update for weeks 06/07 to 20/07:

  • I worked further on the Ledger firmware. I worked on the user interface code. I implemented the tests further.

  • I looked into detail on the BIP standards as they are used in Grin and Ledger, surrounding the topic of key derivation.

  • Lots of small things in the firmware, a lot of debugging.

19 Likes

Update for weeks 20/07 to 03/08:

  • I looked these weeks into the Bulletproof paper and code, to understand the elements I need. It’s the generation side I need to focus on, verification can happen on desktop.

  • I worked further on the Grin++ code, removing compilation errors. And a lot of reading code.

21 Likes

Update for weeks 03/08 to 17/08:

  • On the firmware side, I worked further on the test for signing, which included some utilities, like using the RNG from Ledger, printing a hex number etc. I made a handler instruction for running the tests.

  • On the grin-wallet and grin++ side, I worked further on PSGT, for some alternation.

  • I started writing some documentation, such as the required third-party article as described here, by Ledger: Documentation requirements | Developers

Next, I will design the 2 mandatory icons, as described here: Design requirements | Developers

Then, I will work further on the firmware tests.

24 Likes

Update for weeks August 17 to August 31:

16 Likes