KeystoneHQ / keystone3-firmware

Keystone3: Best Open Source Cold Wallet & Hardware Wallet
https://keyst.one/
Other
59 stars 20 forks source link

Implement slip39 extendable backups #1102

Open onvej-sl opened 3 weeks ago

onvej-sl commented 3 weeks ago

This pull request implements a recent revision of the SLIP-39 specification. The highest bit of the iteration exponent has been repurposed for a new "extendable backup flag". Setting the flag indicates that the random identifier is not used as salt in the encryption of the master secret. This makes it possible to create multiple sets of shares, such that each set of shares uses a different identifier and each set of shares leads to the same master secret for every passphrase. This is a desirable property, which unfortunately was not considered in the initial specification. It allows users to start working with their wallet by creating a single-share (1-of-1) scheme and later upgrade to a multi-share scheme while maintaining the same encrypted master secret and passphrases. Existing SLIP-39 shares remain valid. New shares created using the revised specification use a different checksum customization string and are not compatible with older implementations.

Since I'm not able to run tests (see https://github.com/KeystoneHQ/keystone3-firmware/issues/1096#issuecomment-2145024318), consider this pull request completely untested. Please take extra care to ensure that the changes I made (in particular in src/managers/account_manager.h) are backward compatible.