diff --git a/src/bls/bls.cpp b/src/bls/bls.cpp index bf71b40ff50c..49981ee9190f 100644 --- a/src/bls/bls.cpp +++ b/src/bls/bls.cpp @@ -66,6 +66,9 @@ void CBLSSecretKey::MakeNewKey() GetStrongRandBytes({buf, sizeof(buf)}); try { impl = bls::PrivateKey::FromBytes(bls::Bytes(reinterpret_cast(buf), SerSize)); + if (impl == bls::PrivateKey()) { + continue; + } break; } catch (...) { } diff --git a/src/bls/bls.h b/src/bls/bls.h index 6c3a7f2010e9..19dd5ae7611c 100644 --- a/src/bls/bls.h +++ b/src/bls/bls.h @@ -111,6 +111,11 @@ class CBLSWrapper } else { try { impl = ImplType::FromBytes(bls::Bytes(vecBytes.data(), vecBytes.size()), specificLegacyScheme); + if (impl == ImplType()) { + Reset(); + cachedHash.SetNull(); + return; + } fValid = true; } catch (...) { Reset();