File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed
src/lib/vm/instruction-sets/common Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,10 @@ export const useSixStackItems = <
165
165
) ,
166
166
) ;
167
167
168
- const typicalMaximumVmNumberByteLength = 8 ;
168
+ /**
169
+ * Zero means any maximum length checks on VM numbers are disabled.
170
+ */
171
+ const typicalMaximumVmNumberByteLength = 0 ;
169
172
170
173
export const useOneVmNumber = <
171
174
State extends AuthenticationProgramStateError &
@@ -356,7 +359,7 @@ export const pushToStackVmNumberChecked = <
356
359
} = { } ,
357
360
) => {
358
361
const encoded = bigIntToVmNumber ( vmNumber ) ;
359
- if ( encoded . length > maximumVmNumberByteLength ) {
362
+ if ( maximumVmNumberByteLength && encoded . length > maximumVmNumberByteLength ) {
360
363
return applyError (
361
364
state ,
362
365
AuthenticationErrorCommon . overflowsVmNumberRange ,
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ export const createOpBin2Num =
143
143
state ,
144
144
( nextState , [ target ] ) => {
145
145
const minimallyEncoded = bigIntToVmNumber ( target ) ;
146
- return minimallyEncoded . length > maximumVmNumberByteLength
146
+ return maximumVmNumberByteLength && minimallyEncoded . length > maximumVmNumberByteLength
147
147
? applyError (
148
148
nextState ,
149
149
AuthenticationErrorCommon . exceededMaximumVmNumberByteLength ,
Original file line number Diff line number Diff line change @@ -482,7 +482,10 @@ export const isVmNumberError = (
482
482
) : value is VmNumberError =>
483
483
value === VmNumberError . outOfRange || value === VmNumberError . requiresMinimal ;
484
484
485
- const typicalMaximumVmNumberByteLength = 8 ;
485
+ /**
486
+ * Zero means any maximum length checks on VM numbers are disabled.
487
+ */
488
+ const typicalMaximumVmNumberByteLength = 0 ;
486
489
487
490
/**
488
491
* This method attempts to decode a VM Number, a format in which numeric values
@@ -512,7 +515,8 @@ export const vmNumberToBigInt = (
512
515
requireMinimalEncoding = true ,
513
516
} : {
514
517
/**
515
- * The maximum valid number of bytes in a VM Number.
518
+ * The maximum valid number of bytes in a VM Number. Set to `0` to disable
519
+ * this check.
516
520
*/
517
521
maximumVmNumberByteLength ?: number ;
518
522
/**
@@ -528,7 +532,7 @@ export const vmNumberToBigInt = (
528
532
if ( bytes . length === 0 ) {
529
533
return 0n ;
530
534
}
531
- if ( bytes . length > maximumVmNumberByteLength ) {
535
+ if ( maximumVmNumberByteLength && bytes . length > maximumVmNumberByteLength ) {
532
536
return VmNumberError . outOfRange ;
533
537
}
534
538
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
You can’t perform that action at this time.
0 commit comments