Skip to content

Commit af5e3f4

Browse files
test: cover ECDSA scalar multiplication and infinity edge cases (TOB-25)
1 parent 1e0cc5c commit af5e3f4

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. The format
55
## Table of Contents
66

77
- [Unreleased](#unreleased)
8+
- [1.9.26 - 2025-12-10](#1926---2025-12-10)
89
- [1.9.25 - 2025-12-09](#1925---2025-12-09)
910
- [1.9.24 - 2025-12-09](#1924---2025-12-09)
1011
- [1.9.23 - 2025-12-08](#1923---2025-12-08)
@@ -198,6 +199,17 @@ All notable changes to this project will be documented in this file. The format
198199

199200
---
200201

202+
## [1.9.26] - 2025-12-10
203+
204+
### Security
205+
- Addressed TOB-25 by adding explicit ECDSA and elliptic-curve regression tests
206+
ensuring correct propagation and handling of the point at infinity during
207+
scalar multiplication and signature verification.
208+
These tests prevent regressions where invalid infinity points could be
209+
incorrectly treated as valid curve points.
210+
211+
---
212+
201213
## [1.9.25] - 2025-12-09
202214

203215
### Added

src/primitives/__tests/ECDSA.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as ECDSA from '../../primitives/ECDSA'
22
import BigNumber from '../../primitives/BigNumber'
33
import Curve from '../../primitives/Curve'
44
import Signature from '../../primitives/Signature'
5+
import Point from '../../primitives/Point'
56

67
const msg = new BigNumber('deadbeef', 16)
78
const key = new BigNumber(
@@ -90,4 +91,30 @@ describe('ECDSA', () => {
9091
ECDSA.sign(msg, key, undefined, n)
9192
).toThrow()
9293
})
94+
95+
it('k·G + (−k·G) results in point at infinity (TOB-25)', () => {
96+
const k = new BigNumber('123456789abcdef', 16)
97+
98+
const P = curve.g.mul(k)
99+
const negP = P.neg()
100+
const sum = P.add(negP)
101+
102+
expect(sum.isInfinity()).toBe(true)
103+
})
104+
105+
it('scalar multiplication by zero returns point at infinity (TOB-25)', () => {
106+
const zero = new BigNumber(0)
107+
const result = curve.g.mul(zero)
108+
109+
expect(result.isInfinity()).toBe(true)
110+
})
111+
112+
it('ECDSA verify rejects point-at-infinity public key (TOB-25)', () => {
113+
const signature = ECDSA.sign(msg, key)
114+
const infinityPub = new Point(null, null)
115+
116+
expect(() =>
117+
ECDSA.verify(msg, signature, infinityPub)
118+
).toThrow()
119+
})
93120
})

0 commit comments

Comments
 (0)