From 9f419b31086845774a2b93856ad34613a8202e61 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 23 Jun 2024 14:06:13 +0200 Subject: [PATCH] improve new key generation performance --- src/ed25519.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ed25519.rs b/src/ed25519.rs index 7713d13..b7185e6 100644 --- a/src/ed25519.rs +++ b/src/ed25519.rs @@ -58,12 +58,14 @@ impl Ed25519Secret { let pair = KeyPair::from_seed(Seed::generate()); let pk = pair.pk; + if pk[30] != u8::from(Algo::Ed25519) || pk[31] != u8::from(chain) { + continue; + } + let sig = pair.sk.sign("test", Some(Noise::generate())); pk.verify("test", &sig).expect("unable to create key"); - if pk[30] == u8::from(Algo::Ed25519) && pk[31] == u8::from(chain) { - return Self(pair.sk); - } + return Self(pair.sk); } }