keyfork-mnemonic-generate: properly slice entropy

This commit is contained in:
Ryan Heywood 2023-08-16 16:38:10 -05:00
parent d0eead5eb3
commit bf0468e405
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 3 additions and 3 deletions

View File

@ -172,7 +172,7 @@ fn bitslice_to_usize(bitslice: [bool; 11]) -> usize {
index
}
fn main() -> Result<(), Box<dyn Error>> {
fn main() -> Result<()> {
if !env::vars()
.any(|(name, _)| name == "SHOOT_SELF_IN_FOOT" || name == "INSECURE_HARDWARE_ALLOWED")
{
@ -194,7 +194,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let entropy = &mut [0u8; 256 / 8];
random_handle.read_exact(&mut entropy[..])?;
let mnemonic = Mnemonic::from_entropy(entropy)?;
let mnemonic = Mnemonic::from_entropy(&entropy[..bit_size / 8])?;
println!("{mnemonic}");
@ -216,7 +216,7 @@ mod tests {
}
#[test]
fn loads_mnemonics() -> Result<(), Box<dyn super::Error>> {
fn loads_mnemonics() -> Result<()> {
let content = include_str!("test/vectors.json");
let jsonobj: serde_json::Value = serde_json::from_str(content)?;