keyfork-mnemonic-generate: properly slice entropy
This commit is contained in:
parent
d0eead5eb3
commit
bf0468e405
|
@ -172,7 +172,7 @@ fn bitslice_to_usize(bitslice: [bool; 11]) -> usize {
|
||||||
index
|
index
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<()> {
|
||||||
if !env::vars()
|
if !env::vars()
|
||||||
.any(|(name, _)| name == "SHOOT_SELF_IN_FOOT" || name == "INSECURE_HARDWARE_ALLOWED")
|
.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];
|
let entropy = &mut [0u8; 256 / 8];
|
||||||
random_handle.read_exact(&mut entropy[..])?;
|
random_handle.read_exact(&mut entropy[..])?;
|
||||||
|
|
||||||
let mnemonic = Mnemonic::from_entropy(entropy)?;
|
let mnemonic = Mnemonic::from_entropy(&entropy[..bit_size / 8])?;
|
||||||
|
|
||||||
println!("{mnemonic}");
|
println!("{mnemonic}");
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn loads_mnemonics() -> Result<(), Box<dyn super::Error>> {
|
fn loads_mnemonics() -> Result<()> {
|
||||||
let content = include_str!("test/vectors.json");
|
let content = include_str!("test/vectors.json");
|
||||||
let jsonobj: serde_json::Value = serde_json::from_str(content)?;
|
let jsonobj: serde_json::Value = serde_json::from_str(content)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue