File tree Expand file tree Collapse file tree 4 files changed +31
-7
lines changed Expand file tree Collapse file tree 4 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,11 @@ import { TinySecp256k1Interface } from './types';
55 * If `eccLib` is a new instance, it will be verified before setting it as the active library.
66 *
77 * @param eccLib The instance of the ECC library to initialize.
8- * @param skipVerification If the ecc verification should not be executed.
8+ * @param skipVerification Use {DANGER_DO_NOT_VERIFY_ECCLIB:true} if ecc verification should not be executed. Not recommended!
99 */
10- export declare function initEccLib ( eccLib : TinySecp256k1Interface | undefined , skipVerification ?: boolean ) : void ;
10+ export declare function initEccLib ( eccLib : TinySecp256k1Interface | undefined , skipVerification ?: {
11+ DANGER_DO_NOT_VERIFY_ECCLIB : boolean ;
12+ } ) : void ;
1113/**
1214 * Retrieves the ECC Library instance.
1315 * Throws an error if the ECC Library is not provided.
Original file line number Diff line number Diff line change @@ -8,14 +8,14 @@ const _ECCLIB_CACHE = {};
88 * If `eccLib` is a new instance, it will be verified before setting it as the active library.
99 *
1010 * @param eccLib The instance of the ECC library to initialize.
11- * @param skipVerification If the ecc verification should not be executed.
11+ * @param skipVerification Use {DANGER_DO_NOT_VERIFY_ECCLIB:true} if ecc verification should not be executed. Not recommended!
1212 */
1313function initEccLib ( eccLib , skipVerification ) {
1414 if ( ! eccLib ) {
1515 // allow clearing the library
1616 _ECCLIB_CACHE . eccLib = eccLib ;
1717 } else if ( eccLib !== _ECCLIB_CACHE . eccLib ) {
18- if ( ! skipVerification )
18+ if ( ! skipVerification ?. DANGER_DO_NOT_VERIFY_ECCLIB )
1919 // new instance, verify it
2020 verifyEcc ( eccLib ) ;
2121 _ECCLIB_CACHE . eccLib = eccLib ;
Original file line number Diff line number Diff line change 1+ import { initEccLib } from '../src' ;
2+ import { describe , test } from 'mocha' ;
3+ import * as assert from 'assert' ;
4+
5+ describe ( `initEccLib` , ( ) => {
6+ beforeEach ( ( ) => {
7+ initEccLib ( undefined ) ;
8+ } ) ;
9+
10+ test ( 'initEccLib should fail when invalid' , ( ) => {
11+ assert . throws ( ( ) => {
12+ initEccLib ( { isXOnlyPoint : ( ) => false } as any ) ;
13+ } , 'Error: ecc library invalid' ) ;
14+ } ) ;
15+
16+ test ( 'initEccLib should not fail when DANGER_DO_NOT_VERIFY_ECCLIB = true' , ( ) => {
17+ initEccLib ( { isXOnlyPoint : ( ) => false } as any , {
18+ DANGER_DO_NOT_VERIFY_ECCLIB : true ,
19+ } ) ;
20+ assert . ok ( 'it does not fail, verification is excluded' ) ;
21+ } ) ;
22+ } ) ;
Original file line number Diff line number Diff line change @@ -8,17 +8,17 @@ const _ECCLIB_CACHE: { eccLib?: TinySecp256k1Interface } = {};
88 * If `eccLib` is a new instance, it will be verified before setting it as the active library.
99 *
1010 * @param eccLib The instance of the ECC library to initialize.
11- * @param skipVerification If the ecc verification should not be executed.
11+ * @param skipVerification Use {DANGER_DO_NOT_VERIFY_ECCLIB:true} if ecc verification should not be executed. Not recommended!
1212 */
1313export function initEccLib (
1414 eccLib : TinySecp256k1Interface | undefined ,
15- skipVerification ?: boolean ,
15+ skipVerification ?: { DANGER_DO_NOT_VERIFY_ECCLIB : boolean } ,
1616) : void {
1717 if ( ! eccLib ) {
1818 // allow clearing the library
1919 _ECCLIB_CACHE . eccLib = eccLib ;
2020 } else if ( eccLib !== _ECCLIB_CACHE . eccLib ) {
21- if ( ! skipVerification )
21+ if ( ! skipVerification ?. DANGER_DO_NOT_VERIFY_ECCLIB )
2222 // new instance, verify it
2323 verifyEcc ( eccLib ! ) ;
2424 _ECCLIB_CACHE . eccLib = eccLib ;
You can’t perform that action at this time.
0 commit comments