Skip to content

Conversation

@suyash67
Copy link
Contributor

@suyash67 suyash67 commented Feb 1, 2026

Overview

I had added a test that checked if secp256k1_ecdsa_mul correctly returned point at infinity when we have private key $x$ defined as:

$$x = - u_1 \cdot u_2^{-1}$$

which 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 bigfield and 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

$R_i = \sum_{k<i} 2^{e_k} \Big(u_{2,lo}[k] \cdot Q + u_{2,hi}[k] \cdot (\lambda Q)\Big) + \sum_{k<i} 2^{f_k}\Big(u_{1,lo}[k] \cdot G + u_{1,hi}[k] \cdot (\lambda G)\Big)$

Grouping terms, this is always expressible as

$$ R_i = U_i Q + V_i G, $$

where

$U_i=\sum_{k<i}2^{e_k}(u_{2,lo,k} + \lambda \cdot u_{2,hi,k})$

$V_i=\sum_{k<i}2^{f_k}(u_{1,lo,k} + \lambda \cdot u_{1,hi,k}).$

Writing the public key as $Q=xG$, we get

$$ R_i=(U_i x + V_i)G. $$

Therefore an intermediate infinity occurs exactly when

$$ R_i=\mathcal{O} \iff U_i x + V_i \equiv 0 \pmod n. $$

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.

Copy link
Contributor

@federicobarbacovi federicobarbacovi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for doing this!

@ludamad ludamad changed the base branch from merge-train/barretenberg to next February 4, 2026 02:27
@ludamad ludamad enabled auto-merge February 4, 2026 02:27
@ludamad ludamad added this pull request to the merge queue Feb 4, 2026
@ludamad ludamad removed this pull request from the merge queue due to a manual request Feb 4, 2026
@ludamad ludamad changed the base branch from next to merge-train/barretenberg February 4, 2026 02:28
@ludamad ludamad merged commit b6cd97b into merge-train/barretenberg Feb 4, 2026
13 checks passed
@ludamad ludamad deleted the sb/secp-flake branch February 4, 2026 02:28
github-merge-queue bot pushed a commit that referenced this pull request Feb 4, 2026
BEGIN_COMMIT_OVERRIDE
fix: remove intermittently failing ecdsa mul test (#20095)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants