(input: Uint8Array, index: number)
| 125 | // Returns length of the CBOR array in bytes and checks that each item on it |
| 126 | // follows the deterministic principles. |
| 127 | function arrayDeterministic(input: Uint8Array, index: number): number { |
| 128 | const { lengthInBytes, value } = unsignedIntegerDeterministic(input, index); |
| 129 | |
| 130 | // Skip the starter byte and the bytes stating the number of elements the array has. |
| 131 | let startIndexOfNextElement = index + 1 + lengthInBytes; |
| 132 | |
| 133 | for (let /*element on the array*/ i = 0; i < Number(value); i++) { |
| 134 | if (startIndexOfNextElement >= input.length) { |
| 135 | throw new Error( |
| 136 | 'Number of items on CBOR array is less than the number of items it claims.' |
| 137 | ); |
| 138 | } |
| 139 | startIndexOfNextElement += deterministicRec(input, startIndexOfNextElement); |
| 140 | } |
| 141 | |
| 142 | return startIndexOfNextElement - index; |
| 143 | } |
| 144 | |
| 145 | // Returns the length of the CBOR map in bytes and checks that each item on it |
| 146 | // follows the deterministic principles. Additionally to ensure deterministicity |
no test coverage detected