Skip to content

Commit 11d4fed

Browse files
authored
Improve error message for deprecated hash-to-curve strategy (#592)
1 parent 92aa4c6 commit 11d4fed

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

yacl/crypto/ecc/openssl/openssl_group.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,13 @@ EcPoint OpensslGroup::HashToCurve(HashToCurveStrategy strategy,
297297
HashAlgorithm hash_algorithm;
298298
switch (strategy) {
299299
case HashToCurveStrategy::TryAndRehash_SHA2:
300-
YACL_THROW("HashToCurveStrategy::TryAndRehash_SHA2 has been deprecated.");
300+
YACL_THROW(
301+
"HashToCurveStrategy::TryAndRehash_SHA2 has been deprecated.\n"
302+
"It is recommended to use curve-specific, standard-compliant "
303+
"strategies for better security and interoperability.\n\n"
304+
"For example:\n"
305+
" - For NIST curves like P-256: Use SHA256_SSWU_RO_.\n"
306+
" - For the SM2 curve: Use TryAndRehash_SM.");
301307
break;
302308
case HashToCurveStrategy::TryAndRehash_SHA3:
303309
if (bits <= 256) {

yacl/crypto/ecc/openssl/openssl_test.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,8 @@ TEST(OpensslTest, HashToCurveWorks) {
8484
};
8585

8686
for (int i = 0; i < 1000; ++i) {
87-
// is_unique(curve->HashToCurve(HashToCurveStrategy::TryAndRehash_SHA2,
88-
// fmt::format("id{}", i)));
8987
is_unique(curve->HashToCurve(HashToCurveStrategy::TryAndRehash_SM,
9088
fmt::format("id{}", i)));
91-
// is_unique(curve->HashToCurve(HashToCurveStrategy::TryAndRehash_BLAKE3,
92-
// fmt::format("id{}", i)));
93-
// Same strategy as above TryAndRehash_BLAKE3
94-
// is_unique(curve->HashToCurve(fmt::format("id{}", i)));
9589
}
9690
}
9791

0 commit comments

Comments
 (0)