Skip to content

Commit 61fb158

Browse files
committed
Increase test timeout for CI
1 parent c218b4a commit 61fb158

File tree

6 files changed

+63
-69
lines changed

6 files changed

+63
-69
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
node: [22, 18]
17+
node: [22, 20]
1818
steps:
1919
- name: Checking out
2020
uses: actions/checkout@v4

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"homepage": "https://github.com/cloudflare/blindrsa-ts#readme",
2626
"repository": "github:cloudflare/blindrsa-ts",
2727
"engines": {
28-
"node": ">=18"
28+
"node": ">=22"
2929
},
3030
"scripts": {
3131
"build": "tsc -b && cp src/sjcl/index.d.ts lib/src/sjcl/index.d.ts",
@@ -42,7 +42,7 @@
4242
"devDependencies": {
4343
"@eslint/js": "9.11.1",
4444
"@types/benchmark": "2.1.5",
45-
"@vitest/coverage-v8": "^3.0.7",
45+
"@vitest/coverage-v8": "3.0.7",
4646
"benchmark": "2.1.4",
4747
"eslint": "9.11.1",
4848
"eslint-config-prettier": "9.1.0",

test/blindrsa.test.ts

+17-21
Original file line numberDiff line numberDiff line change
@@ -134,32 +134,28 @@ describe.each(vectors)('TestVectors', (v: Vector) => {
134134
const params = [undefined, { supportsRSARAW: true }];
135135

136136
describe.each(params)(`_${v.name}`, (params) => {
137-
test(
138-
`supportsRSARAW/${params ? params.supportsRSARAW : false}`,
139-
async () => {
140-
const blindRSA = getSuiteByName(BlindRSA, v.name, params);
141-
expect(blindRSA.toString()).toBe(v.name);
137+
test(`supportsRSARAW/${params ? params.supportsRSARAW : false}`, async () => {
138+
const blindRSA = getSuiteByName(BlindRSA, v.name, params);
139+
expect(blindRSA.toString()).toBe(v.name);
142140

143-
const msg = hexToUint8(v.msg);
144-
const inputMsg = blindRSA.prepare(msg);
145-
expect(uint8ToHex(inputMsg)).toBe(v.input_msg);
141+
const msg = hexToUint8(v.msg);
142+
const inputMsg = blindRSA.prepare(msg);
143+
expect(uint8ToHex(inputMsg)).toBe(v.input_msg);
146144

147-
const { publicKey, privateKey } = await keysFromVector(v, true);
145+
const { publicKey, privateKey } = await keysFromVector(v, true);
148146

149-
const { blindedMsg, inv } = await blindRSA.blind(publicKey, inputMsg);
150-
expect(uint8ToHex(blindedMsg)).toBe(v.blinded_msg);
151-
expect(uint8ToHex(inv)).toBe(v.inv.slice(2));
147+
const { blindedMsg, inv } = await blindRSA.blind(publicKey, inputMsg);
148+
expect(uint8ToHex(blindedMsg)).toBe(v.blinded_msg);
149+
expect(uint8ToHex(inv)).toBe(v.inv.slice(2));
152150

153-
const blindedSig = await blindRSA.blindSign(privateKey, blindedMsg);
154-
expect(uint8ToHex(blindedSig)).toBe(v.blind_sig);
151+
const blindedSig = await blindRSA.blindSign(privateKey, blindedMsg);
152+
expect(uint8ToHex(blindedSig)).toBe(v.blind_sig);
155153

156-
const signature = await blindRSA.finalize(publicKey, inputMsg, blindedSig, inv);
157-
expect(uint8ToHex(signature)).toBe(v.sig);
154+
const signature = await blindRSA.finalize(publicKey, inputMsg, blindedSig, inv);
155+
expect(uint8ToHex(signature)).toBe(v.sig);
158156

159-
const isValid = await blindRSA.verify(publicKey, signature, inputMsg);
160-
expect(isValid).toBe(true);
161-
},
162-
20 * 1000,
163-
);
157+
const isValid = await blindRSA.verify(publicKey, signature, inputMsg);
158+
expect(isValid).toBe(true);
159+
}, 300_000);
164160
});
165161
});

test/partially_blindrsa.test.ts

+31-37
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,15 @@ describe.each(vectors)('Errors-vec$#', (v: Vector) => {
124124
});
125125
});
126126

127-
test.each(vectors)('TestVector_$#/safePrimes', (v: Vector) => {
128-
prepare_sjcl_random_generator();
129-
expect(isSafePrime(new sjcl.bn(v.p))).toBe(true);
130-
expect(isSafePrime(new sjcl.bn(v.q))).toBe(true);
131-
});
127+
test.each(vectors)(
128+
'TestVector_$#/safePrimes',
129+
(v: Vector) => {
130+
prepare_sjcl_random_generator();
131+
expect(isSafePrime(new sjcl.bn(v.p))).toBe(true);
132+
expect(isSafePrime(new sjcl.bn(v.q))).toBe(true);
133+
},
134+
{ timeout: 30_000 },
135+
);
132136

133137
describe.each(vectors)('TestVector_$#', (v: Vector) => {
134138
beforeEach(() => {
@@ -146,37 +150,27 @@ describe.each(vectors)('TestVector_$#', (v: Vector) => {
146150
const all_params = [undefined, { supportsRSARAW: true }];
147151

148152
describe.each(all_params)(`_${v.name}`, (params) => {
149-
test(
150-
`supportsRSARAW/${params ? params.supportsRSARAW : false}`,
151-
async () => {
152-
const blindRSA = getSuiteByName(PartiallyBlindRSA, v.name, params);
153-
expect(blindRSA.toString()).toBe(v.name);
154-
155-
const msg = hexToUint8(v.msg);
156-
const info = hexToUint8(v.info);
157-
const inputMsg = blindRSA.prepare(msg);
158-
159-
const { publicKey, privateKey } = await keysFromVector(v, true);
160-
161-
const { blindedMsg, inv } = await blindRSA.blind(publicKey, inputMsg, info);
162-
expect(uint8ToHex(blindedMsg)).toBe(v.blind_msg);
163-
164-
const blindedSig = await blindRSA.blindSign(privateKey, blindedMsg, info);
165-
expect(uint8ToHex(blindedSig)).toBe(v.blind_sig);
166-
167-
const signature = await blindRSA.finalize(
168-
publicKey,
169-
inputMsg,
170-
info,
171-
blindedSig,
172-
inv,
173-
);
174-
expect(uint8ToHex(signature)).toBe(v.sig);
175-
176-
const isValid = await blindRSA.verify(publicKey, signature, inputMsg, info);
177-
expect(isValid).toBe(true);
178-
},
179-
20 * 1000,
180-
);
153+
test(`supportsRSARAW/${params ? params.supportsRSARAW : false}`, async () => {
154+
const blindRSA = getSuiteByName(PartiallyBlindRSA, v.name, params);
155+
expect(blindRSA.toString()).toBe(v.name);
156+
157+
const msg = hexToUint8(v.msg);
158+
const info = hexToUint8(v.info);
159+
const inputMsg = blindRSA.prepare(msg);
160+
161+
const { publicKey, privateKey } = await keysFromVector(v, true);
162+
163+
const { blindedMsg, inv } = await blindRSA.blind(publicKey, inputMsg, info);
164+
expect(uint8ToHex(blindedMsg)).toBe(v.blind_msg);
165+
166+
const blindedSig = await blindRSA.blindSign(privateKey, blindedMsg, info);
167+
expect(uint8ToHex(blindedSig)).toBe(v.blind_sig);
168+
169+
const signature = await blindRSA.finalize(publicKey, inputMsg, info, blindedSig, inv);
170+
expect(uint8ToHex(signature)).toBe(v.sig);
171+
172+
const isValid = await blindRSA.verify(publicKey, signature, inputMsg, info);
173+
expect(isValid).toBe(true);
174+
}, 300_000);
181175
});
182176
});

test/primes.test.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,16 @@ test.each([128, 256, 512, 1024])('generatePrime/%p', (bitLength) => {
8585
expect(isPrime(p)).toBe(true);
8686
});
8787

88-
test.each([128, 256])('generateSafePrime/%p', (bitLength) => {
89-
const p = generateSafePrime(bitLength);
88+
test.each([128, 256])(
89+
'generateSafePrime/%p',
90+
(bitLength) => {
91+
const p = generateSafePrime(bitLength);
9092

91-
expect(p.bitLength()).toBeGreaterThanOrEqual(bitLength);
92-
expect(isSafePrime(p)).toBe(true);
93-
});
93+
expect(p.bitLength()).toBeGreaterThanOrEqual(bitLength);
94+
expect(isSafePrime(p)).toBe(true);
95+
},
96+
300_000,
97+
);
9498

9599
describe('max_num_iterations', () => {
96100
test('generatePrime', () => {
@@ -100,5 +104,5 @@ describe('max_num_iterations', () => {
100104
expect(() => {
101105
generatePrime(8);
102106
}).toThrow(/MAX_NUM_TRIES/);
103-
});
107+
}, 60_000);
104108
});

vitest.config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { defineConfig } from 'vitest/config'
22

33
export default defineConfig({
44
test: {
5-
setupFiles: ["./test/vitest.setup-file.ts"],
5+
dir: './test',
6+
setupFiles: ['./test/vitest.setup-file.ts'],
67
coverage: { enabled: true },
7-
testTimeout: 60_000 // the performance of generating safe primes in JS (without node) are terrible
88
}
99
})

0 commit comments

Comments
 (0)