dalek 4.0

This commit is contained in:
Luke Parker
2023-07-23 14:32:14 -04:00
parent 8e6e05ae2d
commit 23e1c9769c
34 changed files with 395 additions and 413 deletions

View File

@@ -261,10 +261,11 @@ impl ClassicSeed {
let (lang, entropy) = seed_to_bytes(&words)?;
// Make sure this is a valid scalar
let mut scalar = Scalar::from_canonical_bytes(*entropy);
if scalar.is_none() {
let scalar = Scalar::from_canonical_bytes(*entropy);
if scalar.is_none().into() {
Err(SeedError::InvalidSeed)?;
}
let mut scalar = scalar.unwrap();
scalar.zeroize();
// Call from_entropy so a trimmed seed becomes a full seed
@@ -272,7 +273,7 @@ impl ClassicSeed {
}
pub fn from_entropy(lang: Language, entropy: Zeroizing<[u8; 32]>) -> Option<ClassicSeed> {
Scalar::from_canonical_bytes(*entropy).map(|scalar| key_to_seed(lang, Zeroizing::new(scalar)))
Option::from(Scalar::from_canonical_bytes(*entropy)).map(|scalar| key_to_seed(lang, Zeroizing::new(scalar)))
}
pub(crate) fn to_string(&self) -> Zeroizing<String> {