You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add hamming weight checks
* Rework to deal with whole shares, not word-wise
* Fix logging
* Revert "Rework to deal with whole shares, not word-wise"
This reverts commit 65245f8.
* Switch to checking half-words, and add fixed number of attempts (100,000) before failing
* Switch to checking numbers are within middle ranges, rather than checking deltas
DEBUG_LOG("Generated share %d word %d half %d has hamming weights out of range %d -> %d - regenerating attempt %d\n", j, i, half, min_weight, max_weight, attempt);
5222
+
pass = false;
5223
+
break;
5224
+
}
5225
+
combined_weight += weight;
5226
+
}
5227
+
if (!pass) break;
5228
+
if (combined_weight < min_combined_weight || combined_weight > max_combined_weight) {
5229
+
DEBUG_LOG("Generated share word %d half %d has hamming weights out of range %d -> %d - regenerating attempt %d\n", i, half, min_combined_weight, max_combined_weight, attempt);
5230
+
pass = false;
5231
+
break;
5232
+
}
5233
+
}
5234
+
if (pass) {
5235
+
num_attempts.push_back(attempt);
5236
+
break;
5237
+
}
5238
+
}
5239
+
if (!pass) {
5240
+
fail(ERROR_INCOMPATIBLE, "Failed to generate a share word with hamming weights within %d -> %d", min_weight, max_weight);
5241
+
}
5242
+
}
5243
+
5244
+
DEBUG_LOG("Average number of attempts: %d\n", std::accumulate(num_attempts.begin(), num_attempts.end(), 0) / num_attempts.size());
5245
+
DEBUG_LOG("Max number of attempts: %d\n", *std::max_element(num_attempts.begin(), num_attempts.end()));
5246
+
DEBUG_LOG("Min number of attempts: %d\n", *std::min_element(num_attempts.begin(), num_attempts.end()));
5247
+
} else {
5248
+
// Check the share word hamming weights are close to each other
std::cout << "WARNING: Key Share " << j << " Word " << i << " half " << half << " has hamming weights out of range " << min_weight << " -> " << max_weight << " - this may leak information about the key\n";
5257
+
}
5258
+
combined_weight += weight;
5259
+
}
5260
+
if (combined_weight < min_combined_weight || combined_weight > max_combined_weight) {
5261
+
std::cout << "WARNING: Key Share Word " << i << " half " << half << " has hamming weights out of range " << min_combined_weight << " -> " << max_combined_weight << " - this may leak information about the key\n";
0 commit comments