File tree Expand file tree Collapse file tree 6 files changed +39
-11
lines changed Expand file tree Collapse file tree 6 files changed +39
-11
lines changed Original file line number Diff line number Diff line change 1+ # 6.1.7
2+ __ added__
3+ - skip ecc library verification via DANGER_DO_NOT_VERIFY_ECCLIB flag
4+
15# 6.1.6
26__ fixed__
37- Fix sighash treatment when signing taproot script sign scripts using Psbt (#2104 )
Original file line number Diff line number Diff line change @@ -54,14 +54,14 @@ const _ECCLIB_CACHE = {};
5454 * If `eccLib` is a new instance, it will be verified before setting it as the active library.
5555 *
5656 * @param eccLib The instance of the ECC library to initialize.
57- * @param skipVerification If the ecc verification should not be executed.
57+ * @param opts Extra initialization options. Use {DANGER_DO_NOT_VERIFY_ECCLIB:true} if ecc verification should not be executed. Not recommended!
5858 */
59- function initEccLib ( eccLib , skipVerification ) {
59+ function initEccLib ( eccLib , opts ) {
6060 if ( ! eccLib ) {
6161 // allow clearing the library
6262 _ECCLIB_CACHE . eccLib = eccLib ;
6363 } else if ( eccLib !== _ECCLIB_CACHE . eccLib ) {
64- if ( ! skipVerification )
64+ if ( ! opts ?. DANGER_DO_NOT_VERIFY_ECCLIB )
6565 // new instance, verify it
6666 verifyEcc ( eccLib ) ;
6767 _ECCLIB_CACHE . eccLib = eccLib ;
Original file line number Diff line number Diff line change @@ -5,9 +5,11 @@ import { TinySecp256k1Interface } from './types.js';
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 opts Extra initialization options. 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 , opts ?: {
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 @@ -6,14 +6,14 @@ const _ECCLIB_CACHE = {};
66 * If `eccLib` is a new instance, it will be verified before setting it as the active library.
77 *
88 * @param eccLib The instance of the ECC library to initialize.
9- * @param skipVerification If the ecc verification should not be executed.
9+ * @param opts Extra initialization options. Use {DANGER_DO_NOT_VERIFY_ECCLIB:true} if ecc verification should not be executed. Not recommended!
1010 */
11- export function initEccLib ( eccLib , skipVerification ) {
11+ export function initEccLib ( eccLib , opts ) {
1212 if ( ! eccLib ) {
1313 // allow clearing the library
1414 _ECCLIB_CACHE . eccLib = eccLib ;
1515 } else if ( eccLib !== _ECCLIB_CACHE . eccLib ) {
16- if ( ! skipVerification )
16+ if ( ! opts ?. DANGER_DO_NOT_VERIFY_ECCLIB )
1717 // new instance, verify it
1818 verifyEcc ( eccLib ) ;
1919 _ECCLIB_CACHE . eccLib = eccLib ;
Original file line number Diff line number Diff line change 1+ import { initEccLib } from 'bitcoinjs-lib' ;
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 @@ -9,17 +9,17 @@ const _ECCLIB_CACHE: { eccLib?: TinySecp256k1Interface } = {};
99 * If `eccLib` is a new instance, it will be verified before setting it as the active library.
1010 *
1111 * @param eccLib The instance of the ECC library to initialize.
12- * @param skipVerification If the ecc verification should not be executed.
12+ * @param opts Extra initialization options. Use {DANGER_DO_NOT_VERIFY_ECCLIB:true} if ecc verification should not be executed. Not recommended!
1313 */
1414export function initEccLib (
1515 eccLib : TinySecp256k1Interface | undefined ,
16- skipVerification ?: boolean ,
16+ opts ?: { DANGER_DO_NOT_VERIFY_ECCLIB : boolean } ,
1717) : void {
1818 if ( ! eccLib ) {
1919 // allow clearing the library
2020 _ECCLIB_CACHE . eccLib = eccLib ;
2121 } else if ( eccLib !== _ECCLIB_CACHE . eccLib ) {
22- if ( ! skipVerification )
22+ if ( ! opts ?. DANGER_DO_NOT_VERIFY_ECCLIB )
2323 // new instance, verify it
2424 verifyEcc ( eccLib ! ) ;
2525 _ECCLIB_CACHE . eccLib = eccLib ;
You can’t perform that action at this time.
0 commit comments