Lite HSM Wallet
Lite HSM Wallet provides a cost-effective solution for secure private key management for Flow. It utilizes the nature of Flow account model and it supports both single-sig and multi-sig.
Created on 26th February 2023
•
Lite HSM Wallet
Lite HSM Wallet provides a cost-effective solution for secure private key management for Flow. It utilizes the nature of Flow account model and it supports both single-sig and multi-sig.
The problem Lite HSM Wallet solves
Since the advent of Bitcoin, secure management of private keys has been a challenge. Cold wallets, such as paper wallets or hardware wallets, are generally considered to be the safest methods, but paper wallets are vulnerable to theft and hardware wallets are at risk of breakdown. While hardware wallets offer a backup feature using mnemonics to avoid the risk of breakdown, there is still a risk of mnemonic theft.
On the contrary, Flow manages accounts that is not directly linked to keypairs in themselves. That's why key rotation is possible by adding or deleting public keys for the account. This nature makes it possible to make wallet backups while secret keys are kept in enclaves like Hardware Security Modules (HSMs)
Typically, HSMs store private keys internally in hardware, and there is no direct access to them from the outside. This means that private keys cannot be stolen, and only users with the appropriate permissions can sign transactions securely. However, HSM is expensive and not convenient to use.
Therefore, the Lite HSM Wallet project aims to implement a HSM-like wallet with simple manners, which utilizes Android StrongBox Keymaster. StrongBox Keymaster protects private keys in a isolated hardware. Anyone, even the owner cannot retrieve secret keys from StrongBox Keymaster. Lite HSM wallet also provides QR code based backup mechanism where 2nd Android device is used as a backup. Furthermore, it supports both single-sig and multi-sig.
Lite HSM wallet solves private key management challenges with simple, low-cost manner.
Challenges I ran into
-
The Public Key and signature format are different between Flow account and StrongBox Keymaster. I needed to dive into the encode style on the device and convert it to the format which Flow can understand.
-
StrongBox Keymaster relies on Biometrics authentication which is executed asynchronously. On the contrary, Flow JVM SDK assumes the sign function runs synchronously. Therefore, I needed to implement complicated co-routine handling
-
QR code cannot contain whole TX information because it's too big. TX needs to be shared by devices when multi-sig is used (imagine that you create a TX in 1st devce, then send it to 2nd device and sign it). Therefore, I decided to share minimum information like address, amount and referenced block ID and display them as a QR code.
Tracks Applied (2)
Best Mobile Experience
Best Use of Walletless Onboarding
Technologies used