Skip to content

Commit dc41075

Browse files
committed
secp256k1/ecdsa: Add test for order wraparound.
Since it is impossible to calculate the necessary values without breaking the ECDLP, this adds an invented signature to exercise the branch of the RecoverCompact function that involves the case when the original X coordinate of the random point is greater than the group order and therefore has the overflow bit set. The result is raising the test coverage from 99.2% to 99.6%.
1 parent 9754217 commit dc41075

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

dcrec/secp256k1/ecdsa/signature_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,17 @@ func TestRecoverCompactErrors(t *testing.T) {
962962
"44b9bc4620afa158b7efdfea5234ff2d5f2f78b42886f02cf581827ee55318ea",
963963
hash: "c301ba9de5d6053caad9f5eb46523f007702add2c62fa39de03146a36b8026b7",
964964
err: ErrSigOverflowsPrime,
965+
}, {
966+
// Signature invented since finding a private key needed to create a
967+
// valid signature with an r value that is > group order prior to the
968+
// modular reduction is not possible without breaking the underlying
969+
// crypto.
970+
name: "R > group order with overflow bit",
971+
sig: "21" +
972+
"000000000000000000000000000000014551231950b75fc4402da1722fc9baed" +
973+
"44b9bc4620afa158b7efdfea5234ff2d5f2f78b42886f02cf581827ee55318ea",
974+
hash: "c301ba9de5d6053caad9f5eb46523f007702add2c62fa39de03146a36b8026b7",
975+
err: ErrPointNotOnCurve,
965976
}, {
966977
// Signature created from private key 0x01, blake256(0x0102030407) over
967978
// the secp256r1 curve (note the r1 instead of k1).

0 commit comments

Comments
 (0)