Skip to content

Commit 11c2565

Browse files
Merge #7193: fix: reject identity elements in deserialization and key generation
42b707b fix: reject identity elements in deserialization and key generation (UdjinM6) Pull request description: ## Issue being fixed or feature implemented Identity elements are mathematically valid curve points but have no legitimate use in the protocol. ## What was done? Reject BLS identity elements (point at infinity for G1/G2) at the deserialization boundary in SetBytes(). Also reject zero private keys in MakeNewKey(). Identity elements would not pass further validation anyway, reject them early. ## How Has This Been Tested? Run tests ## Breaking Changes n/a ## Checklist: - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone ACKs for top commit: PastaPastaPasta: utACK 42b707b Tree-SHA512: 047b098fd56b5da07099fde9b03ada7dd4b42698f47cdc84d3c855c11b0122d46a74765fcaaad5d73465abd0d19605445c9e4b6ab6182cf2b318bfe695d2ef0a
2 parents 358cca5 + 42b707b commit 11c2565

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/bls/bls.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ void CBLSSecretKey::MakeNewKey()
6666
GetStrongRandBytes({buf, sizeof(buf)});
6767
try {
6868
impl = bls::PrivateKey::FromBytes(bls::Bytes(reinterpret_cast<const uint8_t*>(buf), SerSize));
69+
if (impl == bls::PrivateKey()) {
70+
continue;
71+
}
6972
break;
7073
} catch (...) {
7174
}

src/bls/bls.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ class CBLSWrapper
111111
} else {
112112
try {
113113
impl = ImplType::FromBytes(bls::Bytes(vecBytes.data(), vecBytes.size()), specificLegacyScheme);
114+
if (impl == ImplType()) {
115+
Reset();
116+
cachedHash.SetNull();
117+
return;
118+
}
114119
fValid = true;
115120
} catch (...) {
116121
Reset();

0 commit comments

Comments
 (0)