Skip to content

Commit 51fe985

Browse files
committed
correct checksum for paranoid entropy
1 parent c822608 commit 51fe985

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/mnemonic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ impl Mnemonic {
7272
}
7373
}
7474
writer.flush().unwrap();
75-
let (payload, checksum) = data.split_at(data.len() - std::cmp::max(1,data.len()/32));
75+
let l = data.len();
76+
let (payload, checksum) = data.split_at(l - if l > 33 {2} else {1});
7677
if Self::checksum(payload).as_slice() != checksum {
7778
return Err(Error::Mnemonic("Checksum failed"));
7879
}
@@ -149,7 +150,6 @@ mod test {
149150
let values = tests[t].as_array().unwrap();
150151
let data = decode(values[0].as_str().unwrap()).unwrap();
151152
let m = values[1].as_str().unwrap();
152-
println!("{}", m);
153153
let mnemonic = Mnemonic::from_str(m).unwrap();
154154
let seed = mnemonic.to_seed(Some("TREZOR"));
155155
assert_eq!(

0 commit comments

Comments
 (0)