Keystone Hardware Wallet Support Grant Application

Of course we will do this!

And we can also make a special version with Zcash-theme image on the back of the device. You can check this (our special version for Bitcoin Halving 2024) as a reference -

I am not 100% sure how to realize this but I will consult our friends in the ECC team.

12 Likes

The signatures are over the effecting data of the transaction, which will be passed to and verified by the user on the offline device.

5 Likes

The specific answer depends on what you mean by “fraudulent” or “tampered with”. In general, two aspects constrain the online wallet:

  • The design of the transaction signature digest in ZIP 244: Transaction Identifier Non-Malleability ensures that a transaction cannot be created without the signer observing all “effecting data” (inputs that have a material effect on the semantics of the transaction). As long as the hardware wallet is not accepting an opaque hash to be signed, and is instead taking all of those inputs to the sighash and checking them (which is the intention for this proposal via a to-be-designed PCZT format), there is nothing the online wallet can do to have the offline wallet sign a transaction they didn’t intend.
  • The proofs created by the online wallet need to be valid or else the transaction can’t be mined. The verification parameters for Orchard, and the circuit they embody, constrain the online wallet to only provide valid inputs (assuming no bugs in the circuit, but that would not be a hardware-wallet-specific problem).

There are things that the online wallet is trusted with, however - specifically, privacy. In the extreme, the online wallet can take the private data for the transaction and publish it “out-of-band” on Pastebin. More subtly, the online wallet could select bad or malicious randomness to create proofs that aren’t correctly zero-knowledge (they would still satisfy correctness and soundness). Without the ability to create proofs on the offline wallet (which is not possible for any of the hardware wallets currently available), this privacy trust assumption is fundamentally necessary, because the device that creates the proofs necessarily sees the private inputs.

But from the perspective of controlling spend authority, the signature digest constrains everything that matters, and the hardware wallet can refuse to produce a signature until it has received sufficient information from the online wallet that it knows what it is signing.

9 Likes

Thanks @nuttycom and @str4d especially for spelling it out. My main concern is ensuring that the user consenting to the transaction presented on the hardware wallet can validate and be confident in what is being processed. I see how this should be addressed, so thank you.

2 Likes

Hell yeah!

1 Like

Thanks for your application @Lixin.

Chainsafe was recently approved funding to develop a Zcash MetaMask snap. Would this work also allow for a MetaMask snap to easily integrate with the Keystone hardware wallet?

1 Like

The grant we are applying is adding Zcash support on Keystone.

Then developers from ECC will add Keystone support on Zashi Wallet. This part is done by ECC team which is not included in the grant.

If Chainsafe team adopt the same open QR protocol like Zashi, the Zcash MetaMask Snap can be integrated with Keystone, to make Keystone a signer for that Snap.

I hope I have explained well for the question you asked.

6 Likes

@Lixin Thanks for submitting the grant. Zcash is short on Hardware Wallet support so it’s super strategic that we can count with a neat solution like Keystone.

I see the QR code integration as a good advantage for integrating with wallets that have access to a camera. Connecting to a device via USB or bluetooth is not only risky but also it’s complicated technically because every operating system and platform has its own policies, drivers, SDKs, APIs and many etceteras whereas the QR code seems a way to avoid all of that platform specific stuff.

What would be the trade-offs that your team has evaluated in terms of this approach? Could you point me to the product’s threat model if you have one?

The grant specifies that you would integrate to ECC’s Zashi first (that’s ok, ledger chose a specific wallet for their first integration as well). What is your estimated effort that other wallets would have to do to integrate as well? do you plan to work on tooling to facilitate that or is that outside the grant’s scope? If so would you be open to collaborate on that?

4 Likes

Probably with liberated key exchange but transaction expiry would hinder signing transactions to be broadcast in the extended future.

1 Like

Could you please comment on the following binary blob present in your repository?

2 Likes

Hey @pacu Thanks so much for your kind words and your questions!

Here are my answers -

What would be the trade-offs that your team has evaluated in terms of this approach?

  1. Some webcams on PC can’t recognize the QR very well.
  2. If you sign transactions at a high frequency, for example for some DeFi degens, USB is more convinient.

Could you point me to the product’s threat model if you have one?

We don’t have a documentation for that. Aside from what you mentioned about platform specific stuff, QR won’t suffer from this attack surface - https://www.youtube.com/watch?v=BZnflNZB3bw

What is your estimated effort that other wallets would have to do to integrate as well? do you plan to work on tooling to facilitate that or is that outside the grant’s scope? If so would you be open to collaborate on that?

  1. We do have an SDK to help other wallets to speed up the integration. Details - https://dev.keyst.one/docs/integration-guide-basics/install-the-sdk
  2. In our grant you can see that milestone 4 is about updating this SDK for Zashi team.
  3. We won’t just throw this SDK to Zashi and just leave the integration to them. We will work closely with them for a perfect integration for the Zcash community. BTW we have started working with them even before applying for this grant. We are very thankful for the help from them.

If anything is still unclear, please let me know.

3 Likes

Keystone can be used “100% offline” means:

4 Likes

Thanks for pointing it out.

This is the QR recognition library developed by our MCU vendor and we can’t open-source this part (not our code). They did some deep optimization for quicker QR decoding. And this library is audited by us, just for decoding QR, nothing else. But we can’t open-source it. Hope you can understand this.

3 Likes

Not to say you can open-source it, yet it’s under your firmware repository and clearly not open-source. Do you believe advertising your firmware as open-source is still fair accordingly? What’s the delineation of your firmware and any binary blobs in this discussion? Are there other closed source components?

6 Likes

This is exciting, I also look forward to this and hope it’s funded.

The timeline seems too optimistic, but at this point I would be OK missing deadlines as long as it is delivered.

Zcash uses a custom derivation to turn seed phrases into key material for shielded wallets, does that work with your security architecture?

4 Likes

Thanks for your detailed response @Lixin!

I meant other wallets that are not powered by ECC SDKs like Ywallet or Zingo. Sorry for not being specific enough. :pray:

Does Keystone have a react-native SDK?

100% agree with Conrado here! Excited but also concerned about the optimistic timeline. It would be awesome, yes, but I think it might take a bit longer considering processes, reviews, audits.

Best of Luck!

2 Likes

I think it depends what you mean by “fully offline”. According to this post on their support forum, you can do this:

Creating and broadcasting raw transactions (when you are not connected to any network)

To create raw transaction data:

  1. Create a new transaction with Broadcast set to off.
  2. Click on Sign.
  3. Review all details on your Trezor and confirm that they are correct.
  4. Copy the signed transaction data or save it as a text document. Close the window.

and then send the raw transaction yourself, or via a service that does so. I have not confirmed that this works or what caveats there are (I assume that Trezor Suite needs to have been connected to the network in order to get recent blockchain state, but needn’t be connected while it is creating and signing the transaction).

My experience is that updates to Trezor Suite are pretty frequent, but you can install those manually rather than via the auto-update if you want. Of course Trezor and Trezor Suite do not currently support Zcash shielded transactions at all.

I agree that the ability to implement a complete air-gap between the network and the wallet (not just the Keystone device, the full wallet application as well), where you get updates to the blockchain via a file and save the transaction to a file, would be incredibly useful for some high-security scenarios. The implementation of that is kind-of orthogonal to the h/w wallet support, but of course you still need a wallet that supports both in order to be able to do both types of isolation at the same time.

I don’t know whether that would fit as a feature for Zashi (which has so far been designed as an on-line wallet), but a great thing about this grant is that, with some feasible wallet-specific work, any librustzcash-based wallet should be able to take advantage of it.

4 Likes

Note that a fully offline wallet like @daira describes cannot run on the Keystone device, because of computational limitations (it cannot create proofs). However, you could indeed have a fully offline wallet on a device that can create proofs, that still uses Keystone for spend authority.

2 Likes

Trezor does the one-time pad thing where the h/w wallet display shows a permuted keypad and you click the corresponding positions on the keypad displayed by Trezor Suite. That should be sufficient to hide the PIN from Trezor Suite, modulo the limitation of it being a numeric PIN. Does Ledger not do that?

And yes, a device with a big touchscreen like Keystone is fundamentally more usable. The one-time pad trick isn’t awful but most people only use short PINs. (Even though Trezor Safe 3 does support up to 50-digit PINs apparently; not sure about earlier models. It’s harder to remember a numeric PIN reliably though. I guess you could write down part of the PIN and remember part of it.)

To fill in a small detail: in the Bitcoin transaction format, and therefore also in the transparent parts of the Zcash transaction format, a transparent input does not explicitly encode its value. It only points to an output from some previous transaction. However, the “effecting data” that is signed does commit to the input values, as of v5 transactions. Zcash started using this approach with ZIP 244, which activated in NU5. A Zcash hardware wallet could just always use v5 transactions, or alternatively it could always use shielded inputs (if it supports that), for which the sum of all shielded input values has always been explicit.

Even without this, the h/w wallet can infer that the total value of inputs plus fee matches the total value of the outputs, by definition. The issue that motivated the change in BIP 341 or ZIP 244 is that the fee is also not explicitly encoded, in either Bitcoin or Zcash. We’ll fix that as well in Zcash at some point, I think in NU7. (It was a candidate change for NU6 but we decided not to do a transaction format change.)

1 Like