MCPcopy Create free account
hub / github.com/WICG/webpackage / textOrByteStringDeterministic

Function textOrByteStringDeterministic

go/internal/cbor/deterministic.go:113–125  ·  view source on GitHub ↗

textOrByteStringDeterministic returns length of the text or byte string element in bytes for which its deterministicy has been ensured

(input []byte)

Source from the content-addressed store, hash-verified

111
112// textOrByteStringDeterministic returns length of the text or byte string element in bytes for which its deterministicy has been ensured
113func textOrByteStringDeterministic(input []byte) (int, error) {
114 // uintLen is the length of the number representing the length of the text/byte string.
115 uintLen, stringLen, err := unsignedIntegerDeterministic(input)
116 if err != nil {
117 return 0, err
118 }
119
120 if (uintLen + int(stringLen)) >= len(input) {
121 panic("Text or byte string's length cannot exceed the length of the input byte array.")
122 }
123
124 return uintLen + int(stringLen), nil
125}
126
127// arrayDeterministic returns length of the CBOR array in bytes and checks that each item on it follows the deterministic principles.
128func arrayDeterministic(input []byte) (int, error) {

Callers 2

deterministicRecFunction · 0.70

Calls 1

Tested by 1