Deterministic function loops through the given byte array containing CBOR sequence and checks that they follow the deterministic principles described here: https://www.rfc-editor.org/rfc/rfc8949.html#name-deterministically-encoded-c.
(input []byte)
| 11 | // and checks that they follow the deterministic principles described here: |
| 12 | // https://www.rfc-editor.org/rfc/rfc8949.html#name-deterministically-encoded-c. |
| 13 | func Deterministic(input []byte) error { |
| 14 | index := 0 |
| 15 | |
| 16 | for index < len(input) { |
| 17 | length, err := deterministicRec(input[index:]) |
| 18 | if err != nil { |
| 19 | return err |
| 20 | } |
| 21 | index += length |
| 22 | } |
| 23 | return nil |
| 24 | } |
| 25 | |
| 26 | // deterministicRec is a recursively called helper function to check the deterministicy of a bytes array. |
| 27 | // TODO(sonkkeli): Recursively called parts will be the maps and arrays, which contain other types, meaning |