|
|
@ -11,6 +11,8 @@ |
|
|
|
// extern crate slice_as_array;
|
|
|
|
// extern crate slice_as_array;
|
|
|
|
#[macro_use] |
|
|
|
#[macro_use] |
|
|
|
extern crate p2p_net; |
|
|
|
extern crate p2p_net; |
|
|
|
|
|
|
|
#[macro_use] |
|
|
|
|
|
|
|
extern crate lazy_static; |
|
|
|
|
|
|
|
|
|
|
|
use p2p_net::log; |
|
|
|
use p2p_net::log; |
|
|
|
|
|
|
|
|
|
|
@ -18,6 +20,8 @@ pub mod types; |
|
|
|
|
|
|
|
|
|
|
|
pub mod bip39; |
|
|
|
pub mod bip39; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub mod emojis; |
|
|
|
|
|
|
|
|
|
|
|
use std::io::Cursor; |
|
|
|
use std::io::Cursor; |
|
|
|
|
|
|
|
|
|
|
|
use crate::bip39::bip39_wordlist; |
|
|
|
use crate::bip39::bip39_wordlist; |
|
|
@ -261,13 +265,23 @@ pub fn display_mnemonic(mnemonic: &[u16; 12]) -> Vec<String> { |
|
|
|
res |
|
|
|
res |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn display_pazzle(pazzle: Vec<u8>) -> Vec<String> { |
|
|
|
use crate::emojis::{EMOJIS, EMOJI_CAT}; |
|
|
|
// let res: Vec<String> = pazzle
|
|
|
|
|
|
|
|
// .into_iter()
|
|
|
|
pub fn display_pazzle(pazzle: &Vec<u8>) -> Vec<String> { |
|
|
|
// .map(|i| String::from(bip39_wordlist[*i as usize]))
|
|
|
|
let res: Vec<String> = pazzle |
|
|
|
// .collect();
|
|
|
|
.into_iter() |
|
|
|
// res
|
|
|
|
.map(|i| { |
|
|
|
unimplemented!(); |
|
|
|
let cat = i >> 4; |
|
|
|
|
|
|
|
let idx = i & 15; |
|
|
|
|
|
|
|
let cat_str = EMOJI_CAT[cat as usize]; |
|
|
|
|
|
|
|
String::from(format!( |
|
|
|
|
|
|
|
"{}:{}", |
|
|
|
|
|
|
|
cat_str, |
|
|
|
|
|
|
|
EMOJIS.get(cat_str).unwrap()[idx as usize].code |
|
|
|
|
|
|
|
)) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.collect(); |
|
|
|
|
|
|
|
res |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn gen_shuffle_for_pazzle_opening(pazzle_length: u8) -> ShuffledPazzle { |
|
|
|
pub fn gen_shuffle_for_pazzle_opening(pazzle_length: u8) -> ShuffledPazzle { |
|
|
@ -584,7 +598,7 @@ mod tests { |
|
|
|
"wallet id: {:?}", |
|
|
|
"wallet id: {:?}", |
|
|
|
base64_url::encode(&res.wallet.id().slice()) |
|
|
|
base64_url::encode(&res.wallet.id().slice()) |
|
|
|
); |
|
|
|
); |
|
|
|
log!("pazzle {:?}", res.pazzle); |
|
|
|
log!("pazzle {:?}", display_pazzle(&res.pazzle)); |
|
|
|
log!("mnemonic {:?}", display_mnemonic(&res.mnemonic)); |
|
|
|
log!("mnemonic {:?}", display_mnemonic(&res.mnemonic)); |
|
|
|
log!("pin {:?}", pin); |
|
|
|
log!("pin {:?}", pin); |
|
|
|
|
|
|
|
|
|
|
|