keyfork-mnemonic-generate: passes first test (pre rewrite)

This commit is contained in:
Ryan Heywood 2023-08-16 15:32:23 -05:00
parent 7467a30c40
commit 7eff9531bc
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 7 additions and 2 deletions

View File

@ -180,7 +180,11 @@ mod tests {
};
let hex = hex::decode(hex_.as_str().unwrap()).unwrap();
let hash = generate_slice_hash(&hex);
let checksum = u8_to_bitslice(&hash.iter().next().unwrap());
let checksum = {
let mut bits = u8_to_bitslice(&hash.iter().next().unwrap());
bits.reverse();
bits
};
let mut seed_bits = hex.iter().flat_map(u8_to_bitslice).collect::<Vec<_>>();
seed_bits.extend(if hex.len() == 256 / 8 {
&checksum[..8]
@ -194,7 +198,8 @@ mod tests {
wordlist[bitslice_to_usize(chunk.try_into().expect("11 bit chunks"))].clone()
})
.collect::<Vec<_>>();
panic!("{}", words.join(" "));
assert_eq!(words.join(" "), seed.as_str().unwrap());
}
Ok(())
}