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 challengesmain
parent
470a92264d
commit
512ecf13d6
|
@ -34,7 +34,7 @@
|
||||||
return null;
|
return null;
|
||||||
h += c.toString(16).padStart(2, "0");
|
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) {
|
function updateOutputValues(ev) {
|
||||||
|
|
Loading…
Reference in New Issue