File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 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;
1010exports . MAX_TAPTREE_DEPTH = 128 ;
1111const isHashBranch = ht => 'left' in ht && 'right' in ht ;
1212function 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+ ) ;
1319 const m = ( controlBlock . length - 33 ) / 32 ;
1420 let kj = leafHash ;
1521 for ( let j = 0 ; j < m ; j ++ ) {
Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ export function rootHashFromPath(
3838 controlBlock : Buffer ,
3939 leafHash : Buffer ,
4040) : 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+ ) ;
4147 const m = ( controlBlock . length - 33 ) / 32 ;
4248
4349 let kj = leafHash ;
You can’t perform that action at this time.
0 commit comments