fix: remove intermittently failing ecdsa mul test #20095
+45
−30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
I had added a test that checked if$x$ defined as:
secp256k1_ecdsa_mulcorrectly returned point at infinity when we have private keywhich would mean the scalar multiplication$(u_1 \cdot G + u_2 \cdot Q) = \mathcal{O}$ would result in a point at infinity. However, since the Montgomery ladder does not handle points at infinity (for efficiency purposes, we use incomplete addition formulae in the ladder computation), the circuit can fail by hitting a point at infinity during the ladder computation. Thus, this test was hitting intermittent failure (crash) once in a while. It is best to remove this test as we do not intend for Montgomery ladder to handle intermediate points at infinity.
As a side note, the test should not have been crashing and should gracefully fail at an assertion (with circuit failure). I've fixed this minor issue in
bigfieldand added a test in biggroup to catch the circuit failure.Point at Infinity in Montgomery Ladder
At round$i$ of the iterative wNAF-style MSM, the partial accumulator has the form
Grouping terms, this is always expressible as
where
Writing the public key as$Q=xG$ , we get
Therefore an intermediate infinity occurs exactly when
Since the wNAF slice digits$u_{1,lo},u_{1,hi},u_{2,lo},u_{2,hi} \in [ \pm1,\pm3,\pm5,\pm7 ]$ are signed, partial sums may cancel, so intermediate iterates $R_i$ may legitimately equal the point at infinity even if the final result is nonzero.