File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,12 @@ exports.LEAF_VERSION_TAPSCRIPT = 0xc0;
10
10
exports . MAX_TAPTREE_DEPTH = 128 ;
11
11
const isHashBranch = ht => 'left' in ht && 'right' in ht ;
12
12
function rootHashFromPath ( controlBlock , leafHash ) {
13
+ if ( controlBlock . length < 33 )
14
+ throw new TypeError (
15
+ `The control-block length is too small. Got ${
16
+ controlBlock . length
17
+ } , expected min 33.`,
18
+ ) ;
13
19
const m = ( controlBlock . length - 33 ) / 32 ;
14
20
let kj = leafHash ;
15
21
for ( let j = 0 ; j < m ; j ++ ) {
Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ export function rootHashFromPath(
38
38
controlBlock : Buffer ,
39
39
leafHash : Buffer ,
40
40
) : Buffer {
41
+ if ( controlBlock . length < 33 )
42
+ throw new TypeError (
43
+ `The control-block length is too small. Got ${
44
+ controlBlock . length
45
+ } , expected min 33.`,
46
+ ) ;
41
47
const m = ( controlBlock . length - 33 ) / 32 ;
42
48
43
49
let kj = leafHash ;
You can’t perform that action at this time.
0 commit comments