Skip to content

Commit 51cbf32

Browse files
committed
feat: initEccLib skip verification
1 parent a59eecd commit 51cbf32

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/ecc_lib.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { TinySecp256k1Interface } from './types';
2-
export declare function initEccLib(eccLib: TinySecp256k1Interface | undefined): void;
2+
export declare function initEccLib(eccLib: TinySecp256k1Interface | undefined, skipVerification?: boolean): void;
33
export declare function getEccLib(): TinySecp256k1Interface;

src/ecc_lib.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
Object.defineProperty(exports, '__esModule', { value: true });
33
exports.getEccLib = exports.initEccLib = void 0;
44
const _ECCLIB_CACHE = {};
5-
function initEccLib(eccLib) {
5+
function initEccLib(eccLib, skipVerification) {
66
if (!eccLib) {
77
// allow clearing the library
88
_ECCLIB_CACHE.eccLib = eccLib;
99
} else if (eccLib !== _ECCLIB_CACHE.eccLib) {
10-
// new instance, verify it
11-
verifyEcc(eccLib);
10+
if (!skipVerification)
11+
// new instance, verify it
12+
verifyEcc(eccLib);
1213
_ECCLIB_CACHE.eccLib = eccLib;
1314
}
1415
}

ts_src/ecc_lib.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ import { TinySecp256k1Interface } from './types';
22

33
const _ECCLIB_CACHE: { eccLib?: TinySecp256k1Interface } = {};
44

5-
export function initEccLib(eccLib: TinySecp256k1Interface | undefined): void {
5+
export function initEccLib(
6+
eccLib: TinySecp256k1Interface | undefined,
7+
skipVerification?: boolean,
8+
): void {
69
if (!eccLib) {
710
// allow clearing the library
811
_ECCLIB_CACHE.eccLib = eccLib;
912
} else if (eccLib !== _ECCLIB_CACHE.eccLib) {
10-
// new instance, verify it
11-
verifyEcc(eccLib!);
13+
if (!skipVerification)
14+
// new instance, verify it
15+
verifyEcc(eccLib!);
1216
_ECCLIB_CACHE.eccLib = eccLib;
1317
}
1418
}

0 commit comments

Comments
 (0)