From 512ecf13d6faaaefbabf98a209e6160480ad8a10 Mon Sep 17 00:00:00 2001 From: SI Date: Fri, 5 Apr 2024 01:40:07 +0200 Subject: [PATCH] use "1 + (h mod (n - 1))" instead of "mod n" to cast a hash to a private key a private key must be in range [1, n - 1] this change neatly eliminates the scenario where the private key value ends up being 0, though it was extremely unlikely to occur in the first place (and could not even be easily forced) this changes the encoding -- players need to use the same encoding for submissions as the one used to post challenges --- flag_encoder/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flag_encoder/index.html b/flag_encoder/index.html index 3f52701..1070c07 100644 --- a/flag_encoder/index.html +++ b/flag_encoder/index.html @@ -34,7 +34,7 @@ return null; h += c.toString(16).padStart(2, "0"); } - return "0x" + new BN(keccak256(h).slice(2), 16).mod(secp256k1n).toString(16).padStart(64, 0); + return "0x" + new BN(keccak256(h).slice(2), 16).mod(secp256k1n.sub(new BN(1))).add(new BN(1)).toString(16).padStart(64, 0); } function updateOutputValues(ev) {