keyfork-mnemonic-generate: add correct amount of bits to bitvec
This commit is contained in:
parent
4feb2b6bce
commit
0d768a6eef
|
@ -130,10 +130,17 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
let mut hasher = Sha256::new();
|
||||
hasher.update(&entropy);
|
||||
let hash = hasher.finalize();
|
||||
let checksum = &hash[..bit_size / 32 / 8];
|
||||
let checksum = u8_to_bitslice(&hash[1]);
|
||||
|
||||
let seed = [&entropy[..bit_size / 8], checksum].concat();
|
||||
let seed_bits = seed.iter().flat_map(u8_to_bitslice).collect::<Vec<_>>();
|
||||
let mut seed_bits = entropy[..bit_size / 8]
|
||||
.iter()
|
||||
.flat_map(u8_to_bitslice)
|
||||
.collect::<Vec<_>>();
|
||||
seed_bits.extend(if bit_size == 256 {
|
||||
&checksum[..8]
|
||||
} else {
|
||||
&checksum[..4]
|
||||
});
|
||||
let words = seed_bits
|
||||
.chunks_exact(11)
|
||||
.map(|chunk| wordlist[bitslice_to_usize(chunk.try_into().expect("11 bit chunks"))].clone())
|
||||
|
|
Loading…
Reference in New Issue