Skip to content

Commit 6aef23b

Browse files
committed
merge
2 parents 180c597 + 6048ed2 commit 6aef23b

File tree

8 files changed

+257
-89
lines changed

8 files changed

+257
-89
lines changed

CHANGELOG.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ 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-09](#1926---2025-12-09)
8+
- [1.9.28 - 2025-12-11](#1928---2025-12-11)
9+
- [1.9.27 - 2025-12-11](#1927---2025-12-11)
10+
- [1.9.26 - 2025-12-10](#1926---2025-12-10)
911
- [1.9.25 - 2025-12-09](#1925---2025-12-09)
1012
- [1.9.24 - 2025-12-09](#1924---2025-12-09)
1113
- [1.9.23 - 2025-12-08](#1923---2025-12-08)
@@ -199,16 +201,42 @@ All notable changes to this project will be documented in this file. The format
199201

200202
---
201203

202-
## [1.9.26] - 2025-12-09
204+
## [1.9.28] - 2025-12-11
203205

204206
### Added
205207
- Add getBytes64 helper for 64-bit length fields.
208+
- Added long ciphertext test case.
209+
210+
### Changed
211+
- Changed AESGCM to use Uint8Arrays instead of number[] for all inputs and outputs for optimization.
206212

207213
### Fixed
208214
- Use 64-bit length encoding for GHASH inputs.
209215

210216
---
211217

218+
## [1.9.27] - 2025-12-11
219+
220+
### Fixed
221+
- Addressed TOB-24: hardened elliptic-curve point validation across `fromDER`, `fromX`, and `fromJSON`.
222+
- Added bigint-secure curve equation checking to `Point.validate()`.
223+
- Fixed modular sqrt and pow logic (`biModSqrt`, `biModPow`) to correctly detect invalid X coordinates.
224+
- Ensured consistent `Invalid point` errors for malformed input.
225+
- Added negative tests and roundtrip validation tests.
226+
227+
---
228+
229+
## [1.9.26] - 2025-12-10
230+
231+
### Security
232+
- Addressed TOB-25 by adding explicit ECDSA and elliptic-curve regression tests
233+
ensuring correct propagation and handling of the point at infinity during
234+
scalar multiplication and signature verification.
235+
These tests prevent regressions where invalid infinity points could be
236+
incorrectly treated as valid curve points.
237+
238+
---
239+
212240
## [1.9.25] - 2025-12-09
213241

214242
### Added

docs/reference/primitives.md

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,7 @@ export default class Point extends BasePoint {
17561756
x: BigNumber | null;
17571757
y: BigNumber | null;
17581758
inf: boolean;
1759+
static _assertOnCurve(p: Point): Point
17591760
static fromDER(bytes: number[]): Point
17601761
static fromString(str: string): Point
17611762
static fromX(x: BigNumber | number | number[] | string, odd: boolean): Point
@@ -5031,9 +5032,9 @@ encoding, and changing it would render previously encrypted data
50315032
undecryptable by newer versions of the library.
50325033

50335034
```ts
5034-
export function AESGCM(plainText: number[], initializationVector: number[], key: number[]): {
5035-
result: number[];
5036-
authenticationTag: number[];
5035+
export function AESGCM(plainText: Bytes, initializationVector: Bytes, key: Bytes): {
5036+
result: Bytes;
5037+
authenticationTag: Bytes;
50375038
}
50385039
```
50395040

@@ -5043,7 +5044,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
50435044
### Function: AESGCMDecrypt
50445045

50455046
```ts
5046-
export function AESGCMDecrypt(cipherText: number[], initializationVector: number[], authenticationTag: number[], key: number[]): number[] | null
5047+
export function AESGCMDecrypt(cipherText: Bytes, initializationVector: Bytes, authenticationTag: Bytes, key: Bytes): Bytes | null
50475048
```
50485049

50495050
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
@@ -5070,7 +5071,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
50705071
### Function: ghash
50715072

50725073
```ts
5073-
export function ghash(input: number[], hashSubKey: number[]): number[]
5074+
export function ghash(input: Bytes, hashSubKey: Bytes): Bytes
50745075
```
50755076

50765077
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
@@ -5491,20 +5492,20 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
54915492
54925493
```ts
54935494
biModPow = (base: bigint, exp: bigint): bigint => {
5494-
let result = BI_ONE;
5495+
let result = 1n;
54955496
base = biMod(base);
5496-
let e = exp;
5497-
while (e > BI_ZERO) {
5498-
if ((e & BI_ONE) === BI_ONE)
5497+
while (exp > 0n) {
5498+
if ((exp & 1n) !== 0n) {
54995499
result = biModMul(result, base);
5500+
}
55005501
base = biModMul(base, base);
5501-
e >>= BI_ONE;
5502+
exp >>= 1n;
55025503
}
55035504
return result;
55045505
}
55055506
```
55065507
5507-
See also: [BI_ONE](./primitives.md#variable-bi_one), [BI_ZERO](./primitives.md#variable-bi_zero), [biMod](./primitives.md#variable-bimod), [biModMul](./primitives.md#variable-bimodmul)
5508+
See also: [biMod](./primitives.md#variable-bimod), [biModMul](./primitives.md#variable-bimodmul)
55085509
55095510
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
55105511
@@ -5525,7 +5526,10 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
55255526
```ts
55265527
biModSqrt = (a: bigint): bigint | null => {
55275528
const r = biModPow(a, P_PLUS1_DIV4);
5528-
return biModMul(r, r) === biMod(a) ? r : null;
5529+
if (biModMul(r, r) !== biMod(a)) {
5530+
return null;
5531+
}
5532+
return r;
55295533
}
55305534
```
55315535
@@ -5579,11 +5583,11 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
55795583
### Variable: exclusiveOR
55805584
55815585
```ts
5582-
exclusiveOR = function (block0: number[], block1: number[]): number[] {
5586+
exclusiveOR = function (block0: Bytes, block1: Bytes): Bytes {
55835587
const len = block0.length;
5584-
const result = new Array(len);
5588+
const result = new Uint8Array(len);
55855589
for (let i = 0; i < len; i++) {
5586-
result[i] = block0[i] ^ block1[i];
5590+
result[i] = block0[i] ^ (block1[i] ?? 0);
55875591
}
55885592
return result;
55895593
}
@@ -5730,15 +5734,11 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
57305734
### Variable: incrementLeastSignificantThirtyTwoBits
57315735
57325736
```ts
5733-
incrementLeastSignificantThirtyTwoBits = function (block: number[]): number[] {
5734-
let i;
5737+
incrementLeastSignificantThirtyTwoBits = function (block: Bytes): Bytes {
57355738
const result = block.slice();
5736-
for (i = 15; i !== 11; i--) {
5737-
result[i] = result[i] + 1;
5738-
if (result[i] === 256) {
5739-
result[i] = 0;
5740-
}
5741-
else {
5739+
for (let i = 15; i !== 11; i--) {
5740+
result[i] = (result[i] + 1) & 255;
5741+
if (result[i] !== 0) {
57425742
break;
57435743
}
57445744
}
@@ -5910,7 +5910,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
59105910
### Variable: multiply
59115911
59125912
```ts
5913-
multiply = function (block0: number[], block1: number[]): number[] {
5913+
multiply = function (block0: Bytes, block1: Bytes): Bytes {
59145914
const v = block1.slice();
59155915
const z = createZeroBlock(16);
59165916
for (let i = 0; i < 16; i++) {
@@ -5939,11 +5939,10 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
59395939
### Variable: rightShift
59405940
59415941
```ts
5942-
rightShift = function (block: number[]): number[] {
5943-
let i: number;
5942+
rightShift = function (block: Bytes): Bytes {
59445943
let carry = 0;
59455944
let oldCarry = 0;
5946-
for (i = 0; i < block.length; i++) {
5945+
for (let i = 0; i < block.length; i++) {
59475946
oldCarry = carry;
59485947
carry = block[i] & 1;
59495948
block[i] = block[i] >> 1;

0 commit comments

Comments
 (0)