diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c1774a6..a2970e88 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change log -## [1.5.3] - 2023-11-16 +## [1.5.3] - 2023-11-18 ### Added - Added unit tests for BIP39 - Added unit tests for BIP39 word list and SSKR word list @@ -10,6 +10,7 @@ ### Fixed - Fixed CodeQL warnings about sign check of a bitwise operation +- Fixed issue with restarting input from a previous word on Nano S ## [1.5.2] - 2023-11-15 ### Added diff --git a/README.md b/README.md index 69952ed2..8bf31709 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,9 @@ 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. + ## Generate [BIP85](https://github.com/bitcoin/bips/blob/master/bip-0085.mediawiki) Coming soon!!!! diff --git a/src/nano/nanos_enter_phrase.c b/src/nano/nanos_enter_phrase.c index 2a633b09..f3fb0afc 100644 --- a/src/nano/nanos_enter_phrase.c +++ b/src/nano/nanos_enter_phrase.c @@ -23,7 +23,8 @@ #ifdef TARGET_NANOS // allow to edit back any entered word -#define RESTORE_WORD_MAX_BACKWARD_STEPS 24 +#define RESTORE_BIP39_WORD_MAX_BACKWARD_STEPS 24 +#define RESTORE_SSKR_WORD_MAX_BACKWARD_STEPS 46 const bagl_element_t* screen_onboarding_restore_word_before_element_display_callback( const bagl_element_t* element); @@ -280,9 +281,15 @@ const bagl_element_t* screen_onboarding_restore_word_keyboard_callback(unsigned // update the slider's possible words // account for the extra clear word, and clear any previous word items (go back // in the onboarding process) - bolos_ux_hslider3_init(G_bolos_ux_context.onboarding_words_checked + - MIN(G_bolos_ux_context.onboarding_step + 1, - RESTORE_WORD_MAX_BACKWARD_STEPS)); + if (G_bolos_ux_context.onboarding_type == ONBOARDING_TYPE_BIP39) { + bolos_ux_hslider3_init(G_bolos_ux_context.onboarding_words_checked + + MIN(G_bolos_ux_context.onboarding_step + 1, + RESTORE_BIP39_WORD_MAX_BACKWARD_STEPS)); + } else if (G_bolos_ux_context.onboarding_type == ONBOARDING_TYPE_SSKR) { + bolos_ux_hslider3_init(G_bolos_ux_context.onboarding_words_checked + + MIN(G_bolos_ux_context.onboarding_step + 1, + RESTORE_SSKR_WORD_MAX_BACKWARD_STEPS)); + } screen_onboarding_restore_word_display_word_selection(); } return NULL; @@ -635,28 +642,33 @@ unsigned int screen_onboarding_restore_word_select_button(unsigned int button_ma G_bolos_ux_context.onboarding_words_checked; // remove x words while (word_to_delete--) { - if (G_bolos_ux_context.onboarding_step && - G_bolos_ux_context.words_buffer_length) { - // remove the last space and up to the previous space (but keep the - // previous space) - do { - G_bolos_ux_context - .words_buffer[G_bolos_ux_context.words_buffer_length - 1] = 0; - G_bolos_ux_context.words_buffer_length--; + if (G_bolos_ux_context.onboarding_type == ONBOARDING_TYPE_BIP39) { + if (G_bolos_ux_context.onboarding_step && + G_bolos_ux_context.words_buffer_length) { + // remove the last space and up to the previous space (but keep the + // previous space) + do { + G_bolos_ux_context + .words_buffer[G_bolos_ux_context.words_buffer_length - 1] = 0; + G_bolos_ux_context.words_buffer_length--; + } + // until a previous word exists! + while ( + G_bolos_ux_context.words_buffer_length && + G_bolos_ux_context + .words_buffer[G_bolos_ux_context.words_buffer_length - 1] != + ' '); + + // decrement onboarding_step (current word #) + G_bolos_ux_context.onboarding_step--; + } + } else if (G_bolos_ux_context.onboarding_type == ONBOARDING_TYPE_SSKR) { + if (G_bolos_ux_context.onboarding_step && + G_bolos_ux_context.sskr_words_buffer_length) { + G_bolos_ux_context.sskr_words_buffer_length--; + // decrement onboarding_step (current word #) + G_bolos_ux_context.onboarding_step--; } - // until a previous word exists! - while (G_bolos_ux_context.words_buffer_length && - G_bolos_ux_context - .words_buffer[G_bolos_ux_context.words_buffer_length - 1] != - ' '); - - // decrement onboarding_step (current word #) - G_bolos_ux_context.onboarding_step--; - } - if (G_bolos_ux_context.onboarding_type == ONBOARDING_TYPE_SSKR) { - G_bolos_ux_context - .sskr_words_buffer[G_bolos_ux_context.sskr_words_buffer_length - 1] = 0; - G_bolos_ux_context.sskr_words_buffer_length--; } } // clear previous word @@ -673,7 +685,6 @@ void screen_onboarding_restore_word_init(unsigned int action) { // start by restore first word (+1 when displayed) G_bolos_ux_context.onboarding_step = 0; G_bolos_ux_context.sskr_share_index = 0; - G_bolos_ux_context.sskr_share_count = 0; // flush the words first memzero(G_bolos_ux_context.words_buffer, sizeof(G_bolos_ux_context.words_buffer)); diff --git a/src/nano/nanox_enter_phrase.c b/src/nano/nanox_enter_phrase.c index 2cb4f422..f9d76446 100644 --- a/src/nano/nanox_enter_phrase.c +++ b/src/nano/nanox_enter_phrase.c @@ -702,7 +702,6 @@ void screen_onboarding_restore_word_init(unsigned int firstWord) { // start by restore first word (+1 when displayed) G_bolos_ux_context.onboarding_step = 0; G_bolos_ux_context.sskr_share_index = 0; - G_bolos_ux_context.sskr_share_count = 0; // flush the words first memzero(G_bolos_ux_context.words_buffer, sizeof(G_bolos_ux_context.words_buffer)); diff --git a/tests/deprecated/README.md b/tests/deprecated/README.md index 4a589878..9f850fc3 100755 --- a/tests/deprecated/README.md +++ b/tests/deprecated/README.md @@ -7,7 +7,7 @@ There are a couple of ways of running each test. Using curl to POST button pushe ### 12 Word Tests #### API with curl ```bash -./speculos.py ../app-sskr-check/build/nanos/bin/app.elf --model nanos --seed "fly mule excess resource treat plunge nose soda reflect adult ramp planet" +./speculos.py ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "fly mule excess resource treat plunge nose soda reflect adult ramp planet" ``` ##### nanos ```bash @@ -22,12 +22,12 @@ cut -d# -f1 ./tests/deprecated/stax-bip39-12-word.test | while read LINE ; do ec ``` #### Speculos automation ```bash -./speculos.py --automation file:../app-sskr-check/test/speculos/nanos-bip39-12-word.json ../app-sskr-check/build/nanos/bin/app.elf --model nanos --seed "fly mule excess resource treat plunge nose soda reflect adult ramp planet" +./speculos.py --automation file:../app-seed-tool/test/speculos/nanos-bip39-12-word.json ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "fly mule excess resource treat plunge nose soda reflect adult ramp planet" ``` ### 18 Word Tests #### API with curl ```bash -./speculos.py ../app-sskr-check/build/nanos/bin/app.elf --model nanos --seed "profit result tip galaxy hawk immune hockey series melody grape unusual prize nothing federal dad crew pact sad" +./speculos.py ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "profit result tip galaxy hawk immune hockey series melody grape unusual prize nothing federal dad crew pact sad" ``` ```bash while read -a LINE @@ -37,12 +37,12 @@ done < ./test/speculos/nanos-bip39-18-word.test > /dev/null 2>&1 & ``` #### Speculos automation ```bash -./speculos.py --automation file:../app-sskr-check/test/speculos/nanos-bip39-18-word.json ../app-sskr-check/build/nanos/bin/app.elf --model nanos --seed "profit result tip galaxy hawk immune hockey series melody grape unusual prize nothing federal dad crew pact sad" +./speculos.py --automation file:../app-seed-tool/test/speculos/nanos-bip39-18-word.json ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "profit result tip galaxy hawk immune hockey series melody grape unusual prize nothing federal dad crew pact sad" ``` ### 24 Word Tests #### API with curl ```bash -./speculos.py ../app-sskr-check/build/nanos/bin/app.elf --model nanos --seed "toe priority custom gauge jacket theme arrest bargain gloom wide ill fit eagle prepare capable fish limb cigar reform other priority speak rough imitate" +./speculos.py ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "toe priority custom gauge jacket theme arrest bargain gloom wide ill fit eagle prepare capable fish limb cigar reform other priority speak rough imitate" ``` ```bash while read -a LINE @@ -52,7 +52,7 @@ done < ./test/speculos/nanos-bip39-24-word.test > /dev/null 2>&1 & ``` #### Speculos automation ```bash -./speculos.py --automation file:../app-sskr-check/test/speculos/nanos-bip39-24-word.json ../app-sskr-check/build/nanos/bin/app.elf --model nanos --seed "toe priority custom gauge jacket theme arrest bargain gloom wide ill fit eagle prepare capable fish limb cigar reform other priority speak rough imitate" +./speculos.py --automation file:../app-seed-tool/test/speculos/nanos-bip39-24-word.json ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "toe priority custom gauge jacket theme arrest bargain gloom wide ill fit eagle prepare capable fish limb cigar reform other priority speak rough imitate" ``` ## SSKR ### 128-bit seed @@ -60,7 +60,7 @@ Tests taken from the [SSKR Example & Test Vector]( https://github.com/Blockchain #### API with curl ```bash -./speculos.py ../app-sskr-check/build/nanos/bin/app.elf --model nanos --seed "fly mule excess resource treat plunge nose soda reflect adult ramp planet" +./speculos.py ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "fly mule excess resource treat plunge nose soda reflect adult ramp planet" ``` ```bash while read -a LINE @@ -70,13 +70,13 @@ done < ./test/speculos/nanos-sskr-128bit.test > /dev/null 2>&1 & ``` #### Speculos automation ```bash -./speculos.py --automation file:../app-sskr-check/test/speculos/nanos-sskr-128bit.json ../app-sskr-check/build/nanos/bin/app.elf --model nanos --seed "fly mule excess resource treat plunge nose soda reflect adult ramp planet" +./speculos.py --automation file:../app-seed-tool/test/speculos/nanos-sskr-128bit.json ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "fly mule excess resource treat plunge nose soda reflect adult ramp planet" ``` ### 256-bit seed Tests taken from the [SSKR Example & Test Vector]( https://github.com/BlockchainCommons/crypto-commons/blob/master/Docs/sskr-test-vector.md#256-bit-seed) page. #### API with curl ```bash -./speculos.py ../app-sskr-check/build/nanos/bin/app.elf --model nanos --seed "toe priority custom gauge jacket theme arrest bargain gloom wide ill fit eagle prepare capable fish limb cigar reform other priority speak rough imitate" +./speculos.py ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "toe priority custom gauge jacket theme arrest bargain gloom wide ill fit eagle prepare capable fish limb cigar reform other priority speak rough imitate" ``` ```bash while read -a LINE @@ -86,5 +86,5 @@ done < ./test/speculos/nanos-sskr-256bit.test > /dev/null 2>&1 & ``` #### Speculos automation ```bash -./speculos.py --automation file:../app-sskr-check/test/speculos/nanos-sskr-256bit.json ../app-sskr-check/build/nanos/bin/app.elf --model nanos --seed "toe priority custom gauge jacket theme arrest bargain gloom wide ill fit eagle prepare capable fish limb cigar reform other priority speak rough imitate" +./speculos.py --automation file:../app-seed-tool/test/speculos/nanos-sskr-256bit.json ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "toe priority custom gauge jacket theme arrest bargain gloom wide ill fit eagle prepare capable fish limb cigar reform other priority speak rough imitate" ```