arrayDeterministic returns length of the CBOR array in bytes and checks that each item on it follows the deterministic principles.
(input []byte)
| 126 | |
| 127 | // arrayDeterministic returns length of the CBOR array in bytes and checks that each item on it follows the deterministic principles. |
| 128 | func arrayDeterministic(input []byte) (int, error) { |
| 129 | lenOfNumOfItems, numOfItems, err := unsignedIntegerDeterministic(input) |
| 130 | if err != nil { |
| 131 | return 0, err |
| 132 | } |
| 133 | |
| 134 | // Skip the starter byte and the bytes stating the amount of elements the array has. |
| 135 | startIndexOfNextElement := 1 + lenOfNumOfItems |
| 136 | |
| 137 | for arrElementIndex := 0; arrElementIndex < int(numOfItems); arrElementIndex++ { |
| 138 | if startIndexOfNextElement >= len(input) { |
| 139 | panic("Number of items on CBOR array is less than the number of items it claims.") |
| 140 | } |
| 141 | itemLength, err := deterministicRec(input[startIndexOfNextElement:]) |
| 142 | if err != nil { |
| 143 | return 0, err |
| 144 | } |
| 145 | startIndexOfNextElement += itemLength |
| 146 | } |
| 147 | |
| 148 | return startIndexOfNextElement, nil |
| 149 | } |
| 150 | |
| 151 | // mapDeterministic returns length of the CBOR map in bytes and checks that each item on it |
| 152 | // follows the deterministic principles. Additionally to ensure deterministicy of a map: |
no test coverage detected