CBOR is a compact binary data serialization and messaging format. This specification defines CBOR-LD 1.0, a CBOR-based format to serialize Linked Data. The encoding is designed to leverage the existing JSON-LD ecosystem, which is deployed on hundreds of millions of systems today, to provide a compact serialization format for those seeking efficient encoding schemes for Linked Data. By utilizing semantic compression schemes, compression ratios in excess of 60% better than generalized compression schemes are possible. This format is primarily intended to be a way to use Linked Data in storage and bandwidth constrained programming environments, to build interoperable semantic wire-level protocols, and to efficiently store Linked Data in CBOR-based storage engines.
This document is experimental.
There is a reference implementation that is capable of demonstrating the features described in this document.
CBOR is a compact binary data serialization and messaging format. This specification defines CBOR-LD 1.0, a CBOR-based format to serialize Linked Data. The encoding is designed to leverage the existing JSON-LD ecosystem, which is deployed on hundreds of millions of systems today, to provide a compact serialization format for those seeking efficient encoding schemes for Linked Data. By utilizing semantic compression schemes, compression ratios in excess of 60% better than generalized compression schemes are possible. This format is primarily intended to be a way to use Linked Data in storage and bandwidth constrained programming environments, to build interoperable semantic wire-level protocols, and to efficiently store Linked Data in CBOR-based storage engines.
This document is a detailed specification for a serialization of Linked Data in CBOR. The document is primarily intended for the following audiences:
There are a number of ways that one may participate in the development of this specification:
CBOR-LD satisfies the following design goals:
Similarly, the following are non-goals.
The following minefields have been identified while working on this specification:
At a high level, CBOR-LD is a compact, binary serialization for JSON-LD that allows the following mechanisms for additional compression:
Codecs are the basic primitive for compressing typed values in a generic way. Semantic compression is for compressing JSON-LD terms. Registry dictionaries are for compressing typed values in a use-case-specific way. Each of these is optional — CBOR-LD can be used with any, all, or none of these compression strategies. Taken together, the set of these strategies that is used for a particular use case is known as a processing model.
Semantic compression is a powerful tool for creating compact CBOR-LD payloads. The core idea is to use the information content of external JSON-LD context objects to compress JSON-LD terms. These external context objects are available to both the creator and the consumer of the payload, so this is done in an invertible way.
The general semantic compression process is to take a JSON-LD Document and do the following:
CBOR-LD payloads need to be identifiable as such at the binary level. CBOR natively supports this via its "tag" feature — a header value in the binary data that describes the rest of the payload via a global registry.
The CBOR tag `0xCB1D` (tag value `51997`) has been registered in the IANA CBOR tag registry to be used for CBOR-LD. The data that immediately follows this tag value identifies the registry entry that was used to create the compressed payload.
CBOR-LD payloads MUST be structured such that the item tagged with tag `0xCB1D` is a two-element array, and the first element MUST be a major type 0 integer. This integer is a CBOR-LD Registry Entry ID. The binary structure is `tag([registryEntryId, payload])`.
The value of the CBOR-LD Registry Entry ID is then used to look up a CBOR-LD Registry Entry in the CBOR-LD Registry.
To enable unbounded extension of possible use cases for CBOR-LD that require different compression table material for consumption while working with a single CBOR tag value, we define the following.
The CBOR-LD Registry is a global list that provides consumers of CBOR-LD payloads the information they need to reconstruct the term-codec map required for decompression. A CBOR-LD Registry Entry contains the following:
The string "callerProvidedTable", may appear in `typeTables`, denoting that for this use case, a `Type Table` is required which is not globally defined.
The current CBOR-LD Registry can be found here.
To register an entry, follow the instructions in the README. The registry is owned by the W3C JSON-LD Community Group.
This algorithm takes a map `typeTable`, an integer `registryEntryId`, and a JSON-LD document `jsonldDocument` as inputs, and returns a hexadecimal string `cborldBytes`.
This algorithm takes a CBOR-LD payload `cborldBytes`, and returns a JSON-LD document `jsonldDocument`.
The algorithms in this section describe the behavior of a "converter" for abstractly converting inputs between data forms. When used in conjunction with a "strategy", such as the "compression" and "decompression" strategies defined later in this section, these algorithms can be instantiated to convert between concrete data forms. The "compression" strategy converts from JSON-LD to CBOR-LD, while the "decompression" strategy converts from CBOR-LD to JSON-LD.
This algorithm takes and returns a map `state`.
This algorithm takes a map `state` and a map or array of maps `inputDocuments`, and returns a map containing a map `state` and a map or array of maps `outputMaps`.
This algorithm takes maps `input`, `output`, `state`, and `activeContext` as inputs, and returns a map containing maps `state` and `output`.
This algorithm takes maps `state`, `activeContext`, `termInfo`, and values `value` and `termType`. It returns a `result` object containing maps `state` and `output`.
The algorithms in this section define the "compression" strategy to be used with the "conversion" algorithms defined previously to convert JSON-LD to CBOR-LD.
This algorithm takes maps `state`, `activeContext`, `input`, and `output`, and returns a map `result` containing maps `output`, `state`, and `activeContext`.
This algorithm takes maps `state` and `termInfo`, and values `valueToEncode` and `termType`, and returns a map `encoderData`.
This algorithm takes maps `state`, `activeContext`, and `input`, and returns a map `state` and an array `entries`.
This algorithm takes maps `activeContext` and `input`, and returns a set `objectTypes`.
The algorithms in this section define the "decompression" strategy to be used with the "conversion" algorithms defined previously to convert CBOR-LD to JSON-LD.
This algorithm takes maps `state`, `activeContext`, `input`, and `output`, and returns a map `result` containing maps `output`, `state`, and `activeContext`.
This algorithm takes maps `state` and `termInfo`, and values `termType` and `valueToDecode`, and returns a value `decodedValue`.
This algorithm takes maps `state`, `activeContext`, and `input`, and returns a map `state` and an array `entries`.
This algorithm takes maps `state`, `activeContext`, `input` as inputs, and returns a map `state` and a set `objectTypes`.
The algorithms in this section describe how to determine what components of the context documents associated with a JSON-LD document are in use at any point during compression or decompression. These algorithms include how to apply embedded, type-scoped, and property-scoped contexts with CBOR-LD. This is in contrast to the Context Loading algorithms defined later in this specification, which describe how to construct the mappings from terms to integers that are the core CBOR-LD compression technique. Together, the Active Context Processing and Context Loading algorithms specify how JSON-LD context documents should be processed when converting to and from CBOR-LD.
This algorithm takes maps `previousActiveContext` and `termMap`, and returns a map `activeContext`. It updates the active context in use and finds all aliases for `'@type'`.
This algorithm takes maps `state`, `activeContext`, and `input` as inputs, and returns a map `result` containing maps `state` and `activeContext`.
This algorithm takes maps `state`, `activeContext`, and a string `term` as inputs and returns a map `result` containing maps `state` and `activeContext`.
This algorithm takes maps `state`, `activeContext` ,and a set `objectTypes` as inputs, and returns a map `result` containing maps `state` and `activeContext`.
This algorithm takes maps `state`, `activeTermMap`, and map or array `contexts` as well as booleans `typeScope` and `propertyScope`, both of which default to `false` if not provided, as inputs. It returns maps `state` and `activeTermMap`.
This algorithm takes as input a map `activeContext`, and returns a map `newTermMap`.
The algorithms in this section define how to construct the mappings between terms and integers that are used as the core CBOR-LD compression technique.
This algorithm takes and returns a map `state`.
{
'@context' => 0,
'@type' => 2,
'@id' => 4,
'@value' => 6,
'@direction' => 8,
'@graph' => 10,
'@included' => 12,
'@index' => 14,
'@json' => 16,
'@language' => 18,
'@list' => 20,
'@nest' => 22,
'@reverse' => 24,
'@base' => 26,
'@container' => 28,
'@default' => 30,
'@embed' => 32,
'@explicit' => 34,
'@none' => 36,
'@omitDefault' => 38,
'@prefix' => 40,
'@preserve' => 42,
'@protected' => 44,
'@requireAll' => 46,
'@set' => 48,
'@version' => 50,
'@vocab' => 52,
'@propagate' => 54
}
This algorithm takes a map `state` and a context map or URL `contextIdentifier`, and returns `result`, a map containing maps `state` and `entry`.
This algorithm takes a map `state`, a context object `context`, and a context URL `contextUrl`, and returns `result`, a map containing maps `state` and `entry`.
The codecs in this section specify exactly how individual values in JSON-LD should be converted to CBOR and vice versa. They are used by the algorithms in the previous section, and allow CBOR-LD to efficiently encode both primitive and non-primitive types as CBOR.
This algorithm takes a map `typeTable` and a value `contextValue` and returns a map `encoderData`.
This algorithm takes a map `encoderData`, and returns CBOR binary data.
This algorithm takes a map `reverseTypeTable`, and returns a map `encoderData`.
This algorithm takes a map `decoderData` and a value `value`, and returns a value.
This algorithm takes maps `state` and `termInfo`, and values `termType` and `valueToEncode`, and returns a map `encoderData` or `valueToEncode`.
This algorithm takes a map `encoderData`, and returns CBOR binary data.
This algorithm takes maps `state` and `termInfo`, and values `termType` and `valueToDecode`, and returns a map `decoderData`.
This algorithm takes a map `decoderData`, and returns a value.
The URL Codec compresses URL values based on the prefix of the value, where the prefix is the longest matching entry in the URL Prefix Table. URLs are encoded as arrays, where the first integer identifies the prefix of the URL. The codec first checks whether the value matches a known JSON-LD term identifier, encoding it as a simple integer if so. Otherwise, it delegates to one of the following prefix-specific sub-codecs, based on the prefix of the value.
The URL Prefix Table maps URL prefixes to their associated compressed integer identifiers. Implementations that use the URL codec MUST use the table below. The URL Prefix Reverse Table is the inversion of this table (i.e., a map from integers to URL prefix strings).
| URL Prefix | Integer Identifier |
|---|---|
http:// | 1 |
https:// | 2 |
urn:uuid: | 3 |
data: | 4 |
did:v1:nym: | 1024 |
did:key: | 1025 |
This algorithm takes a map state, a map termInfo,
and a string valueToEncode, and returns either an encoder object
or undefined.
valueToEncode is not a string, throw an
ERR_UNSUPPORTED_JSON_TYPE error.
termId to the result of looking up
valueToEncode in state.termToId.
termId is an integer, return an encoder that, when
invoked via , encodes termId as
a Major Type 0 (unsigned integer) CBOR item.
valueToEncode as a URL.
If parsing fails (i.e., the value is not a valid URL), return
undefined.
prefix to the entry in the URL Prefix Table
such that valueToEncode starts with prefix and
the remainder of valueToEncode following prefix
does not contain a ":" (U+003A COLON) character. If no such
entry exists, return undefined (meaning, no compression is
possible for this URL).
prefix is "https://" or
"http://", return the result of
passing
valueToEncode.
prefix is "urn:uuid:", return the result of
passing
valueToEncode.
prefix is "data:", return the result of
passing
valueToEncode.
prefix is "did:v1:nym:" or
"did:key:", return the result of
passing
valueToEncode.
undefined (meaning, no compression is possible for this URL).
This algorithm takes an encoder object produced by , and returns CBOR binary data.
This algorithm takes a map state, a map termInfo,
and a value valueToDecode, and returns a decoder object or
undefined.
valueToDecode is a string, return undefined
(meaning, value is already an uncompressed URL string; pass through).
valueToDecode is an array:
prefixId to the first element of
valueToDecode.
prefix to the value corresponding to prefixId
in the URL Prefix Reverse Table.
prefix is "http://" or
"https://", set decoder to the result of
passing
valueToDecode.
prefix is "urn:uuid:", set
decoder to the result of
passing
valueToDecode.
prefix is "data:", set
decoder to the result of
passing
valueToDecode.
prefix is "did:v1:nym:" or
"did:key:", set decoder to the result of
passing
valueToDecode.
prefix did not match any of the above (including when
prefixId has no entry in the
URL Prefix Reverse Table), or if decoder is
undefined (meaning, the sub-decoder rejected the shape of
valueToDecode), throw an
ERR_UNKNOWN_COMPRESSED_VALUE error.
decoder.
valueToDecode is an integer, set term to the
result of looking up valueToDecode in
state.idToTerm and return a decoder whose
invocation returns term.
undefined.
This algorithm takes a decoder object produced by , and returns a string value.
The HTTP URL Codec handles values whose prefix is
http:// or https://. An encoded HTTP URL is
represented as a two-element CBOR array
[prefixId, remainder] where prefixId is the
integer from the URL Prefix Table and remainder is
the prefix-stripped portion of the URL as a text string.
This algorithm takes a string value, and returns an
encoder object or undefined.
value starts with "https://", set
prefix to "https://".
value starts with "http://", set
prefix to "http://".
undefined.
value and
prefix.
This algorithm takes an encoder object from , and returns CBOR binary data.
prefixId to the value of encoderData.prefix
in the URL Prefix Table.
rest to the substring of encoderData.value
beginning after encoderData.prefix.
[prefixId, rest]: Major Type 4 (array) containing a
Major Type 0 (unsigned integer) item followed by a Major Type 3
(text string) item.
This algorithm takes a CBOR array valueToDecode, and
returns a decoder object or undefined.
valueToDecode has exactly two elements and the second
element is a text string:
prefix to the value of valueToDecode[0]
in the URL Prefix Reverse Table.
prefix.
undefined.
This algorithm takes a decoder object from
and a CBOR array
valueToDecode, and returns a string.
decoderData.prefix and
valueToDecode[1].
The UUID URN Codec handles values whose prefix is
urn:uuid:. An encoded UUID URN is a two-element CBOR array
[3, uuidValue] where uuidValue is either a
16-byte Major Type 2 (byte string) representing the UUID in binary form
(when the UUID string is all lowercase), or a Major Type 3 (text string)
containing the UUID value verbatim (when the casing cannot be
round-tripped through binary form).
This algorithm takes a string value, and returns an encoder
object or undefined.
value does not start with "urn:uuid:",
return undefined.
value.
This algorithm takes an encoder object, and returns CBOR binary data.
prefixId to 3 (the entry for
"urn:uuid:" in the URL Prefix Table).
rest to the substring of encoderData.value
beginning after "urn:uuid:".
rest contains no uppercase characters (i.e., it is
equal to its lowercase form):
uuidBytes to the 16-byte binary representation of the
UUID obtained by parsing rest according to
[[RFC4122]]. If rest cannot be parsed as a valid UUID, an
error is thrown and encoding fails.
[3, uuidBytes]: Major Type 4 (array) containing a
Major Type 0 (unsigned integer) item followed by a Major Type 2
(byte string) item of length 16.
[3, rest]: Major Type 4 (array) containing a
Major Type 0 (unsigned integer) item followed by a Major Type 3
(text string) item.
This algorithm takes a CBOR array valueToDecode, and returns
a decoder object or undefined.
valueToDecode has exactly two elements, and the second
element is either a byte string or a text string, return a decoder object.
undefined.
This algorithm takes a decoder object and a CBOR array
valueToDecode, and returns a string.
valueToDecode[1] is a text string, set uuid
to valueToDecode[1].
uuid to the UUID string representation of the
16-byte binary value valueToDecode[1] per [[RFC4122]]
(lowercase, hyphen-delimited form).
"urn:uuid:" and
uuid.
The Data URL Codec handles values whose prefix is
data: (data URLs, as defined in [[RFC2397]]). Base64-encoded data URLs
(matching data:<mediatype>;base64,<data>) are
encoded as a three-element CBOR array
[4, mediatype, dataBytes]. Non-base64 data URLs are encoded
as a two-element CBOR array [4, rest] where
rest is the portion of the URL after "data:".
This algorithm takes a string value, and returns an encoder
object or undefined.
value does not start with "data:", return
undefined.
value against the regular expression
^data:(?<mediatype>.*);base64,(?<data>.*)$,
where each .* is greedy (i.e., if the string
";base64," occurs more than once, the
mediatype group extends to the last occurrence).
data to the value of the data capture
group.
data from base64 and
re-encode to base64. If the result equals data, return an
encoder object with value and base64 set to
true.
value and base64
set to false.
This algorithm takes an encoder object from , and returns CBOR binary data.
prefixId to 4 (the entry for
"data:" in the URL Prefix Table).
encoderData.base64 is true:
encoderData.value to extract mediatype
(the substring between "data:" and ";base64,")
and dataBytes (the binary decoding of the base64 data
portion).
[prefixId, mediatype, dataBytes]: Major Type 4 (array)
containing a Major Type 0 integer, a Major Type 3 text string, and a
Major Type 2 byte string.
rest to the substring of encoderData.value
beginning after "data:".
[prefixId, rest]: Major Type 4 (array) containing a
Major Type 0 integer and a Major Type 3 text string.
This algorithm takes a CBOR array valueToDecode, and returns
a decoder object or undefined.
valueToDecode has exactly three elements, the second
element is a text string, and the third element is a byte string, return
a decoder object (base64 mode).
valueToDecode has exactly two elements and
the second element is a text string, return a decoder object
(non-base64 mode).
undefined.
This algorithm takes a decoder object and a CBOR array
valueToDecode, and returns a string.
valueToDecode has three elements (base64 mode):
mediatype to valueToDecode[1].
encodedData to the base64 encoding of the byte string
valueToDecode[2].
"data:",
mediatype, ";base64,", and
encodedData.
"data:" and valueToDecode[1].
The Base58 DID URL Codec handles DID URLs whose prefix is
did:v1:nym: or did:key:, and whose
authority (and optional fragment) components are typically multibase
base58btc-encoded strings (those starting with the character
'z'). A compressed DID URL is encoded as a two- or
three-element CBOR array [prefixId, authority] or
[prefixId, authority, fragment]. When a component starts
with 'z' and is valid base58btc, it is stored as a raw byte
string; otherwise it is stored as a text string.
This algorithm takes a string value, and returns an
encoder object or undefined.
[prefix, prefixId] pair in the
URL Prefix Table where the prefix starts with
"did:":
value starts with prefix, return an encoder
object containing value, prefix, and
prefixId.
undefined.
This algorithm takes an encoder object from , and returns CBOR binary data.
suffix to the substring of encoderData.value
beginning after encoderData.prefix.
suffix on the first occurrence of '#'
to produce authority and, if present,
fragment.
authorityEncoded to the result of applying the
Multibase Base58 to CBOR Token algorithm to
authority.
entries to
[encoderData.prefixId, authorityEncoded].
fragment is defined:
fragmentEncoded to the result of applying the
Multibase Base58 to CBOR Token algorithm to
fragment.
fragmentEncoded to entries.
entries as a Major Type 4
(array).
The Multibase Base58 to CBOR Token algorithm takes a string
str and returns either a Major Type 2 (byte string) CBOR
token (if the value is a base58btc multibase string) or a Major Type 3
(text string) CBOR token.
str starts with 'z':
decoded to the result of decoding the base58btc content
of str (i.e. str[1:]).
decoded.
str.
This algorithm takes a CBOR array valueToDecode, and returns
a decoder object or undefined.
valueToDecode has exactly two or three elements:
prefix to the value of valueToDecode[0]
in the URL Prefix Reverse Table.
prefix.
undefined.
This algorithm takes a decoder object from
and a CBOR array
valueToDecode, and returns a string.
url to decoderData.prefix.
valueToDecode[1] is a byte string, append
'z' followed by the base58btc encoding of
valueToDecode[1] to url.
valueToDecode[1] to url.
valueToDecode has more than two elements:
valueToDecode[2] is a byte string, append
"#z" followed by the base58btc encoding of
valueToDecode[2] to url.
"#" followed by
valueToDecode[2] to url.
url.
The XSD Date Codec compresses values whose type is
http://www.w3.org/2001/XMLSchema#date. A date value is
represented as an integer count of seconds since the Unix epoch
(1970-01-01T00:00:00Z), encoded as a CBOR Major Type 0 (unsigned
integer) for non-negative values or Major Type 1 (negative integer) for
dates before the epoch. The codec only compresses date strings that
exactly round-trip through this representation; otherwise the original
string is retained verbatim.
This algorithm takes a string value, and returns an encoder
object or undefined.
value contains the character 'T' (indicating
a time component), return undefined (this value is
compressed instead by the XSD DateTime
Codec).
parsed to the result of parsing value as
an ISO 8601 date string, expressed as the number of milliseconds since
the Unix epoch.
parsed is not a valid number, return
undefined.
value and
parsed.
This algorithm takes an encoder object from , and returns CBOR binary data.
secondsSinceEpoch to
floor(encoderData.parsed / 1000).
reconstituted to the ISO 8601 string for the instant
secondsSinceEpoch × 1000 milliseconds since the Unix
epoch.
expectedDate to the substring of
reconstituted preceding the first occurrence of
'T'.
encoderData.value is not equal to
expectedDate, the compression would be lossy. Return a CBOR
encoding of encoderData.value as a Major Type 3 (text
string) object.
secondsSinceEpoch is greater than or equal to
0, return a CBOR encoding of
secondsSinceEpoch as a Major Type 0 (unsigned integer)
object.
secondsSinceEpoch
as a Major Type 1 (negative integer) object.
This algorithm takes a value valueToDecode, and returns a
decoder object or undefined.
valueToDecode is an integer (positive, negative, or
zero), return a decoder object.
undefined.
This algorithm takes a decoder object and an integer value
value, and returns a string.
dateString to the ISO 8601 string for the instant
value * 1000 milliseconds since the Unix epoch.
dateString preceding the first
occurrence of 'T'.
The XSD DateTime Codec compresses values whose type is
http://www.w3.org/2001/XMLSchema#dateTime. Second-precision
datetime values are encoded as a single integer count of seconds since
the Unix epoch (Major Type 0 or 1). Sub-second-precision datetime values
are encoded as a two-element CBOR array [seconds,
milliseconds], both as Major Type 0 integers. As with the XSD
Date Codec, the value is only compressed if the compression is lossless
(the original string round-trips through the encoding exactly).
This algorithm takes a string value, and returns an encoder
object or undefined.
value does not contain the character 'T',
return undefined (this value is compressed instead by the
XSD Date Codec).
parsed to the result of parsing value as an
ISO 8601 datetime string, expressed as the number of milliseconds since
the Unix epoch.
parsed is not a valid number, return
undefined.
value and
parsed.
This algorithm takes an encoder object from , and returns CBOR binary data.
secondsSinceEpoch to
floor(encoderData.parsed / 1000).
encoderData.value does not contain the character
'.' (no millisecond component):
expectedDate to the ISO 8601 string for the instant
secondsSinceEpoch * 1000 milliseconds since the Unix
epoch, with the substring ".000Z" replaced by
"Z".
encoderData.value is not equal to
expectedDate, the compression would be lossy. Return a
CBOR encoding of encoderData.value as a Major Type 3
(text string) object.
secondsSinceEpoch is greater than or equal to
0, return a CBOR encoding of
secondsSinceEpoch as a Major Type 0 (unsigned integer)
object.
secondsSinceEpoch as
a Major Type 1 (negative integer) object.
millisecondIndex to the index of the first
'.' in encoderData.value.
milliseconds to the integer value of the digits of
encoderData.value beginning at position
millisecondIndex + 1.
expectedDate to the ISO 8601 string for the instant
secondsSinceEpoch * 1000 + milliseconds milliseconds
since the Unix epoch.
encoderData.value is not equal to
expectedDate, the compression would be lossy. Return a
CBOR encoding of encoderData.value as a Major Type 3
(text string) object.
[secondsSinceEpoch, milliseconds]: Major Type 4 (array)
containing two Major Type 0 (unsigned integer) items.
This algorithm takes a value valueToDecode, and returns a
decoder object or undefined.
valueToDecode is an integer, return a decoder object.
valueToDecode is an array of exactly two elements where
both elements are numbers, return a decoder object.
undefined.
This algorithm takes a decoder object and a value value
(either an integer or a two-element array of integers), and returns a
string.
value is an integer:
instantMs to value * 1000.
dateString to the ISO 8601 string for the instant
instantMs milliseconds since the Unix epoch.
dateString with the substring ".000Z"
replaced by "Z".
value is a two-element array):
instantMs to
value[0] * 1000 + value[1].
instantMs.
The Multibase Codec compresses values whose type is
https://w3id.org/security#multibase. A multibase-encoded
string is converted to a raw byte string whose first byte is the
Multibase Prefix Byte and whose remaining bytes are the decoded
binary payload. This allows the binary payload to be stored compactly
without the overhead of the base-encoding characters.
The following multibase encodings are supported:
| Multibase Prefix Character | Multibase Prefix Byte | Encoding |
|---|---|---|
z |
0x7a |
Base58btc |
u |
0x75 |
Base64url (no padding) |
M |
0x4d |
Base64pad |
This algorithm takes a value value, and returns an encoder
object or undefined.
value is not a string, return undefined.
value is 'z',
'u', or 'M', return an encoder object
containing value.
undefined (unsupported multibase
encoding).
This algorithm takes an encoder object from , and returns CBOR binary data.
prefixChar to the first character of
encoderData.value.
prefixByte to the Multibase Prefix Byte
corresponding to prefixChar.
content to the substring of
encoderData.value beginning after the first character.
prefixChar is 'z', set
suffixBytes to the base58btc decoding of
content.
prefixChar is 'u', set
suffixBytes to the base64url decoding of
content.
prefixChar is 'M'), set
suffixBytes to the base64pad decoding of
content.
bytes to a byte array of length
1 + length(suffixBytes), with the first byte set to
prefixByte and the remaining bytes set to
suffixBytes.
bytes as a Major Type 2 (byte
string) object.
This algorithm takes a value valueToDecode, and returns a
decoder object or undefined.
valueToDecode is not a byte string, return
undefined.
valueToDecode is 0x7a,
0x75, or 0x4d, return a decoder object.
undefined (unsupported multibase
prefix byte).
This algorithm takes a decoder object and a byte string
value, and returns a string.
prefixByte to the first byte of value.
suffix to the remaining bytes of value
(i.e., all bytes after the first).
prefixByte is 0x7a ('z'):
"z" and the base58btc encoding
of suffix.
prefixByte is 0x75 ('u'):
"u" and the base64url encoding
(no padding) of suffix.
prefixByte is 0x4d ('M'):
"M" and the base64pad encoding
of suffix.
value.
This algorithm takes an encoded CBOR-LD payload `cborldBytes` as input, and returns `suffix`, the main data to be decoded, as well as the `registryEntryId` value that should be used to decompress `suffix`.
This specification registers a CBOR tag to allow consumers to identify CBOR-LD payloads. The following is provisional, and has not yet been ratified by IANA.
Tag: 51997
Registry: https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml
Data item: array
Semantics: a tag value of 51997 indicates that the payload is CBOR-LD.
Description of semantics: https://w3c.github.io/cbor-ld/#cbor-tags-for-cbor-ld
Point of contact: Wesley Smith (wsmith@digitalbazaar.com)