Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Commit

Permalink
change recovery logic
Browse files Browse the repository at this point in the history
  • Loading branch information
prusnak committed Jul 10, 2014
1 parent 35d0aef commit ea4d99c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions firmware/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static bool enforce_wordlist;
static char fake_word[12];
static uint32_t word_pos;
static uint32_t word_index;
static char word_order[36];
static char word_order[24];
static char words[24][12];

void next_word(void) {
Expand Down Expand Up @@ -94,12 +94,12 @@ void recovery_init(uint32_t _word_count, bool passphrase_protection, bool pin_pr
for (i = 0; i < word_count; i++) {
word_order[i] = i + 1;
}
for (i = word_count; i < word_count + word_count / 2; i++) {
for (i = word_count; i < 24; i++) {
word_order[i] = 0;
}
for (i = 0; i < 10000; i++) {
j = random32() % (word_count + word_count / 2);
k = random32() % (word_count + word_count / 2);
j = random32() % 24;
k = random32() % 24;
t = word_order[j];
word_order[j] = word_order[k];
word_order[k] = t;
Expand Down Expand Up @@ -145,7 +145,7 @@ void recovery_word(const char *word)
strlcpy(words[word_pos - 1], word, sizeof(words[word_pos - 1]));
}

if (word_index + 1 == word_count + word_count / 2) { // last one
if (word_index + 1 == 24) { // last one
uint32_t i;
strlcpy(storage.mnemonic, words[0], sizeof(storage.mnemonic));
for (i = 1; i < word_count; i++) {
Expand Down

1 comment on commit ea4d99c

@aussiehash
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this as an improvement, it should be a rare occurrence to restore from a mnemonic, but for the same reasons that 24 words became the default mnemonic length, I don't see why removing 50% fake words is beneficial.

Please sign in to comment.