File tree Expand file tree Collapse file tree 6 files changed +48
-10
lines changed Expand file tree Collapse file tree 6 files changed +48
-10
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
+
1
5
# 6.1.6
2
6
__ fixed__
3
7
- 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,16 @@ const _ECCLIB_CACHE = {};
54
54
* If `eccLib` is a new instance, it will be verified before setting it as the active library.
55
55
*
56
56
* @param eccLib The instance of the ECC library to initialize.
57
+ * @param opts Extra initialization options. Use {DANGER_DO_NOT_VERIFY_ECCLIB:true} if ecc verification should not be executed. Not recommended!
57
58
*/
58
- function initEccLib ( eccLib ) {
59
+ function initEccLib ( eccLib , opts ) {
59
60
if ( ! eccLib ) {
60
61
// allow clearing the library
61
62
_ECCLIB_CACHE . eccLib = eccLib ;
62
63
} else if ( eccLib !== _ECCLIB_CACHE . eccLib ) {
63
- // new instance, verify it
64
- verifyEcc ( eccLib ) ;
64
+ if ( ! opts ?. DANGER_DO_NOT_VERIFY_ECCLIB )
65
+ // new instance, verify it
66
+ verifyEcc ( eccLib ) ;
65
67
_ECCLIB_CACHE . eccLib = eccLib ;
66
68
}
67
69
}
Original file line number Diff line number Diff line change @@ -5,8 +5,11 @@ import { TinySecp256k1Interface } from './types.js';
5
5
* If `eccLib` is a new instance, it will be verified before setting it as the active library.
6
6
*
7
7
* @param eccLib The instance of the ECC library to initialize.
8
+ * @param opts Extra initialization options. Use {DANGER_DO_NOT_VERIFY_ECCLIB:true} if ecc verification should not be executed. Not recommended!
8
9
*/
9
- export declare function initEccLib ( eccLib : TinySecp256k1Interface | undefined ) : void ;
10
+ export declare function initEccLib ( eccLib : TinySecp256k1Interface | undefined , opts ?: {
11
+ DANGER_DO_NOT_VERIFY_ECCLIB : boolean ;
12
+ } ) : void ;
10
13
/**
11
14
* Retrieves the ECC Library instance.
12
15
* Throws an error if the ECC Library is not provided.
Original file line number Diff line number Diff line change @@ -6,14 +6,16 @@ const _ECCLIB_CACHE = {};
6
6
* If `eccLib` is a new instance, it will be verified before setting it as the active library.
7
7
*
8
8
* @param eccLib The instance of the ECC library to initialize.
9
+ * @param opts Extra initialization options. Use {DANGER_DO_NOT_VERIFY_ECCLIB:true} if ecc verification should not be executed. Not recommended!
9
10
*/
10
- export function initEccLib ( eccLib ) {
11
+ export function initEccLib ( eccLib , opts ) {
11
12
if ( ! eccLib ) {
12
13
// allow clearing the library
13
14
_ECCLIB_CACHE . eccLib = eccLib ;
14
15
} else if ( eccLib !== _ECCLIB_CACHE . eccLib ) {
15
- // new instance, verify it
16
- verifyEcc ( eccLib ) ;
16
+ if ( ! opts ?. DANGER_DO_NOT_VERIFY_ECCLIB )
17
+ // new instance, verify it
18
+ verifyEcc ( eccLib ) ;
17
19
_ECCLIB_CACHE . eccLib = eccLib ;
18
20
}
19
21
}
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,14 +9,19 @@ const _ECCLIB_CACHE: { eccLib?: TinySecp256k1Interface } = {};
9
9
* If `eccLib` is a new instance, it will be verified before setting it as the active library.
10
10
*
11
11
* @param eccLib The instance of the ECC library to initialize.
12
+ * @param opts Extra initialization options. Use {DANGER_DO_NOT_VERIFY_ECCLIB:true} if ecc verification should not be executed. Not recommended!
12
13
*/
13
- export function initEccLib ( eccLib : TinySecp256k1Interface | undefined ) : void {
14
+ export function initEccLib (
15
+ eccLib : TinySecp256k1Interface | undefined ,
16
+ opts ?: { DANGER_DO_NOT_VERIFY_ECCLIB : boolean } ,
17
+ ) : void {
14
18
if ( ! eccLib ) {
15
19
// allow clearing the library
16
20
_ECCLIB_CACHE . eccLib = eccLib ;
17
21
} else if ( eccLib !== _ECCLIB_CACHE . eccLib ) {
18
- // new instance, verify it
19
- verifyEcc ( eccLib ! ) ;
22
+ if ( ! opts ?. DANGER_DO_NOT_VERIFY_ECCLIB )
23
+ // new instance, verify it
24
+ verifyEcc ( eccLib ! ) ;
20
25
_ECCLIB_CACHE . eccLib = eccLib ;
21
26
}
22
27
}
You can’t perform that action at this time.
0 commit comments