@@ -29,6 +29,9 @@ use sha2::{Digest, Sha256};
29
29
30
30
const NUM_RANDOM_WORDS : u8 = 5 ;
31
31
32
+ /// Number of words in the BIP-39 wordlist.
33
+ const BIP39_WORDLIST_LEN : u16 = 2048 ;
34
+
32
35
fn as_str_vec ( v : & [ zeroize:: Zeroizing < String > ] ) -> Vec < & str > {
33
36
v. iter ( ) . map ( |s| s. as_str ( ) ) . collect ( )
34
37
}
@@ -56,7 +59,7 @@ fn create_random_unique_words(word: &str, length: u8) -> (u8, Vec<zeroize::Zeroi
56
59
// A random word everywhere else.
57
60
// Loop until we get a unique word, we don't want repeated words in the list.
58
61
loop {
59
- let idx = rand16 ( ) % bitbox02 :: keystore :: BIP39_WORDLIST_LEN ;
62
+ let idx = rand16 ( ) % BIP39_WORDLIST_LEN ;
60
63
if picked_indices. contains ( & idx) {
61
64
continue ;
62
65
} ;
@@ -319,7 +322,7 @@ pub async fn get(
319
322
. await ;
320
323
321
324
// Provide all bip39 words to restrict the keyboard entry.
322
- let bip39_wordlist: Vec < u16 > = ( 0 ..bitbox02 :: keystore :: BIP39_WORDLIST_LEN ) . collect ( ) ;
325
+ let bip39_wordlist: Vec < u16 > = ( 0 ..BIP39_WORDLIST_LEN ) . collect ( ) ;
323
326
324
327
let mut word_idx: usize = 0 ;
325
328
let mut entered_words = vec ! [ zeroize:: Zeroizing :: new( String :: new( ) ) ; num_words] ;
@@ -430,7 +433,7 @@ mod tests {
430
433
431
434
fn bruteforce_lastword ( mnemonic : & [ & str ] ) -> Vec < zeroize:: Zeroizing < String > > {
432
435
let mut result = Vec :: new ( ) ;
433
- for i in 0 ..bitbox02 :: keystore :: BIP39_WORDLIST_LEN {
436
+ for i in 0 ..BIP39_WORDLIST_LEN {
434
437
let word = bitbox02:: keystore:: get_bip39_word ( i) . unwrap ( ) ;
435
438
let mut m = mnemonic. to_vec ( ) ;
436
439
m. push ( & word) ;
0 commit comments