Skip to content

Commit

Permalink
Add Stax layouts for generating SSKR shares
Browse files Browse the repository at this point in the history
  • Loading branch information
aido committed May 6, 2024
1 parent 2f3617c commit df70546
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 114 deletions.
17 changes: 13 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change log

## [1.8.0] - 2024-05-06
### Added
- Add Stax layouts for generating SSKR shares

### Changed
- Use stable cx_crc32 instead of cx_crc32_hw

### Fixed
- Fix build with SDK master for LNS

## [1.7.2] - 2024-05-06
### Added
-
Expand All @@ -10,7 +20,6 @@
### Fixed
- Using Ledger SDK `cx_crc32()` function rather than buggy `cx_crc32_hw()`.


## [1.7.1] - 2024-03-06
### Added
-
Expand Down Expand Up @@ -109,8 +118,8 @@

## [1.5.0] - 2023-10-20
### Added
- Added option to generate BIP39 mnemonics from SSKR shares even if shares do not validate against seed on device
- A user may have lost or damaged original device and now needs to generate the recovery phrase from another secure device
- Added option to recover BIP39 mnemonics from SSKR shares even if shares do not validate against seed on device
- A user may have lost or damaged original device and now needs to recover the BIP39 phrase from another secure device

### Changed
-
Expand Down Expand Up @@ -194,7 +203,7 @@

## [1.1.0] - 2023-04-04
### Added
- Generate BIP39 mnemonic phrases from SSKR shares
- Recover BIP39 mnemonic phrases from SSKR shares
- Add 'SSKR Check' menu option
- Add flow to the 'SSKR Check' menu
- Write SSKR to BIP39 functionality
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ all: default

APPNAME = "Seed Tool"
APPVERSION_M = 1
APPVERSION_N = 7
APPVERSION_P = 2
APPVERSION_N = 8
APPVERSION_P = 0
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

APP_LOAD_PARAMS = --appFlags 0x10 $(COMMON_LOAD_PARAMS) --curve secp256k1 --path ""
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

---

Use the utilities provided by this Ledger application to check a backed up seed or generate [Shamir's Secret Sharing (SSS)](https://en.wikipedia.org/wiki/Shamir%27s_secret_sharing) for a seed.
Use the utilities provided by this Ledger application to check a backed up BIP-39 seed, generate [Shamir's Secret Sharing (SSS)](https://en.wikipedia.org/wiki/Shamir%27s_secret_sharing) for a seed or recover a BIP-39 phrase from a Shamir's Secret Sharing backup.

Not all Ledger devices are equal. The older, less capable devices do not have the capacity to provide a full range of seed utilities. The following table lists the seed utilities provided by each devices type:
<div align="center">
Expand All @@ -28,7 +28,7 @@ Not all Ledger devices are equal. The older, less capable devices do not have th
|[Check BIP39](#check-bip39)|$${\color{green}✓}$$|$${\color{green}✓}$$|$${\color{green}✓}$$|$${\color{green}✓}$$|
|[Check Shamir's secret shares](#check-shamirs-secret-shares)|$${\color{green}✓}$$|$${\color{green}✓}$$|$${\color{green}✓}$$|$${\color{orange}✓}$$|
|[Generate Shamir's secret sharing](#generate-shamirs-secret-sharing)|$${\color{green}✓}$$|$${\color{green}✓}$$|$${\color{green}✓}$$|$${\color{orange}✓}$$|
|[Generate BIP39](#generate-bip39)|$${\color{green}✓}$$|$${\color{green}✓}$$|$${\color{green}✓}$$|$${\color{orange}✓}$$|
|[Recover BIP39](#recover-bip39)|$${\color{green}✓}$$|$${\color{green}✓}$$|$${\color{green}✓}$$|$${\color{orange}✓}$$|
|[Generate BIP85](#generate-bip85)|$${\color{red}✗}$$|$${\color{orange}✓}$$|$${\color{orange}✓}$$|$${\color{orange}✓}$$|
</div>

Expand Down Expand Up @@ -59,8 +59,8 @@ For more information about SSKR, see [SSKR for Users](https://github.com/Blockch
## Check Shamir's secret shares
The Ledger application also provides an option to confirm the onboarded seed against SSKR shares.

## Generate BIP39
When the Shamir's secret shares have been validated the user can generate the BIP39 recovery phrase derived from those shares. This option takes advantage of SSKR's ability to perform a BIP39 <-> SSKR round trip. If a user has lost or damaged their original Ledger device they may need to generate the BIP39 recovery phrase on another secure device. A BIP39 recovery phrase may still be generated even if the SSKR phrases do not match the onboarded seed of a device but are still valid SSKR shares.
## Recover BIP39
When the Shamir's secret shares have been validated the user can recover the BIP39 phrase derived from those shares. This option takes advantage of SSKR's ability to perform a BIP39 <-> SSKR round trip. If a user has lost or damaged their original Ledger device they may need to recover their BIP39 phrase on another secure device. A BIP39 phrase may still be recovered even if the SSKR phrases do not match the onboarded seed of a device but are still valid SSKR shares.

## Generate [BIP85](https://github.com/bitcoin/bips/blob/master/bip-0085.mediawiki)
Coming soon!!!!
Expand Down Expand Up @@ -90,9 +90,9 @@ flowchart LR
2.1[Check SSKR] --> 2.2[Enter SSKR Shares] --> 2.3{Validate SSKR Shares}
2.3 --> |Valid SSKR| 2.4
2.3 --> |Invalid SSKR| 2.3.1[Quit]
subgraph 2.4[Generate BIP39 Phrases]
subgraph 2.4[Recover BIP39 Phrases]
direction TB
2.4.1[Generate BIP39 Phrases] --> 2.4.2[Display BIP39 Phrases] --> 2.4.3[Quit]
2.4.1[Recover BIP39 Phrases] --> 2.4.2[Display BIP39 Phrases] --> 2.4.3[Quit]
end
end
subgraph 3[Version]
Expand Down
6 changes: 3 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
- [x] Save memory by setting the SSKR word buffer (G_bolos_ux_context.sskr_words_buffer) to a sensible size
- [x] Add unit tests
- [x] Add code coverage to GitHub actions
- [x] Add option to generate BIP39 mnemonics from SSKR shares even if shares do not validate against seed on device
- A user may have lost or damaged original device and now needs to generate the recovery phrase from another secure device
- [x] Add option to recover BIP39 mnemonics from SSKR shares even if shares do not validate against seed on device
- A user may have lost or damaged original device and now needs to recover the BIP39 phrase from another secure device
- [x] Fix warnings about deprecated functions during build
- [x] Remove duplicated nano code
- [x] Simplified flow code
- [x] Add flow to set SSKR threshold values
- [x] Add automated tests
- [x] Fix issue with using 'cx_crc32_hw()' function in 'onboarding_seed_sskr.c' when testing with Speculos
- [x] Generate BIP39 mnemonic phrases from SSKR shares
- [x] Recover BIP39 mnemonic phrases from SSKR shares
- [x] Add SSKR Check menu option
- [x] Add flow to the Check SSKR menu
- [x] Write SSKR to BIP39 functionality
Expand Down
8 changes: 4 additions & 4 deletions src/nano/nanos_enter_phrase.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ UX_STEP_VALID(ux_bip39_match_step_1,
clean_exit(0),
{&C_icon_validate_14, "BIP39 Phrase", "is correct"});
UX_STEP_CB(ux_bip39_match_step_2, pb, clean_exit(0), {&C_icon_dashboard_x, "Quit"});
UX_STEP_CB(ux_bip39_generate_step_1, pbb, set_sskr_descriptor_values();
UX_STEP_CB(ux_bip39_recover_step_1, pbb, set_sskr_descriptor_values();
, {&SSKR_ICON, "Generate", "SSKR phrases"});

UX_FLOW(ux_bip39_match_flow,
&ux_bip39_match_step_1,
&ux_bip39_match_step_2,
&ux_bip39_generate_step_1);
&ux_bip39_recover_step_1);

UX_STEP_CB(ux_sskr_invalid_step_1, pbb, screen_onboarding_sskr_restore_init();
, {&C_icon_warning, "SSKR Recovery", "phrase invalid"});
Expand All @@ -158,14 +158,14 @@ UX_FLOW(ux_sskr_nomatch_flow,
&ux_sskr_nomatch_step_1,
&ux_sskr_nomatch_step_2,
&ux_sskr_nomatch_step_3,
&ux_bip39_generate_step_1);
&ux_bip39_recover_step_1);

UX_STEP_VALID(ux_sskr_match_step_1,
pbb,
clean_exit(0),
{&C_icon_validate_14, "SSKR Phrase", "is correct"});
UX_STEP_CB(ux_sskr_match_step_2, pb, clean_exit(0), {&C_icon_dashboard_x, "Quit"});
UX_STEP_CB(ux_sskr_match_step_3, pbb, generate_bip39();, {&BIP39_ICON, "Generate", "BIP39 phrase"});
UX_STEP_CB(ux_sskr_match_step_3, pbb, recover_bip39();, {&BIP39_ICON, "Recover", "BIP39 phrase"});

UX_FLOW(ux_sskr_match_flow, &ux_sskr_match_step_1, &ux_sskr_match_step_2, &ux_sskr_match_step_3);

Expand Down
8 changes: 4 additions & 4 deletions src/nano/nanox_enter_phrase.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,14 @@ UX_STEP_NOCB(ux_sskr_nomatch_step_2,
"order and spelling",
});
UX_STEP_VALID(ux_sskr_nomatch_step_3, pb, ui_idle_init(), {&C_icon_back_x, "Return to menu"});
UX_STEP_CB(ux_bip39_generate_step_1, pbb, generate_bip39();
, {&BIP39_ICON, "Generate", "BIP39 phrases"});
UX_STEP_CB(ux_bip39_recover_step_1, pbb, recover_bip39();
, {&BIP39_ICON, "Recover", "BIP39 phrases"});

UX_FLOW(ux_sskr_nomatch_flow,
&ux_sskr_nomatch_step_1,
&ux_sskr_nomatch_step_2,
&ux_sskr_nomatch_step_3,
&ux_bip39_generate_step_1);
&ux_bip39_recover_step_1);

UX_STEP_VALID(ux_sskr_match_step_1,
pbb,
Expand All @@ -210,7 +210,7 @@ UX_STEP_CB(ux_sskr_match_step_2, pb, clean_exit(0), {&C_icon_dashboard_x, "Quit"
UX_FLOW(ux_sskr_match_flow,
&ux_sskr_match_step_1,
&ux_sskr_match_step_2,
&ux_bip39_generate_step_1);
&ux_bip39_recover_step_1);

unsigned int screen_onboarding_restore_word_select_button(unsigned int button_mask,
unsigned int button_mask_counter);
Expand Down
2 changes: 1 addition & 1 deletion src/nano/ux_nano.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void screen_common_keyboard_init(unsigned int stack_slot,
keyboard_callback_t callback);

void set_sskr_descriptor_values(void);
void generate_bip39(void);
void recover_bip39(void);

#include "ux_common/common_bip39.h"
#include "ux_common/common_sskr.h"
Expand Down
2 changes: 1 addition & 1 deletion src/nano/ux_nano_bip39.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ UX_STEP_CB(step_bip39_clean_exit, pb, clean_exit(0), {&C_icon_dashboard_x, "Quit

UX_FLOW(display_bip39_flow, &step_display_bip39, &step_bip39_clean_exit, FLOW_LOOP);

void generate_bip39(void) {
void recover_bip39(void) {
// BIP39 phrase should already be in G_bolos_ux_context.words_buffer so just need to display it
ux_flow_init(0, display_bip39_flow, NULL);
}
Expand Down
Loading

0 comments on commit df70546

Please sign in to comment.