diff --git a/src/bls/bls.h b/src/bls/bls.h index a74158f6e9..b74efd33fd 100644 --- a/src/bls/bls.h +++ b/src/bls/bls.h @@ -190,7 +190,17 @@ public: SetByteVector(vecBytes, specificLegacyScheme); if (checkMalleable && !CheckMalleable(vecBytes, specificLegacyScheme)) { - throw std::ios_base::failure("malleable BLS object"); + // If CheckMalleable failed with specificLegacyScheme, we need to try again with the opposite scheme. + // Probably we received the BLS object sent with legacy scheme, but in the meanwhile the fork activated. + SetByteVector(vecBytes, !specificLegacyScheme); + if (!CheckMalleable(vecBytes, !specificLegacyScheme)) { + // Both attempts failed + throw std::ios_base::failure("malleable BLS object"); + } else { + // Indeed the received vecBytes was in opposite scheme. But we can't keep it (mixing with the new scheme will lead to undefined behavior) + // Therefore, resetting current object (basically marking it as invalid). + Reset(); + } } }