1 of 24

Hello CBOR-LD

An introduction to the Concise Binary Object Representation for Linked Data

1

2 of 24

The Problem

2

VCs and DID Docs are too damn big!*

* For a few important Verifiable Credential (VC) and Decentralized Identifier (DID) use cases - QR Codes, efficient storage, offline interactions.

3 of 24

3

Use

Case:

Present

Verifiable

Credential

4 of 24

Example of the Problem

4

JSON-LD Document

1,217 bytes

LoFi QR Code Display Limit

400 bytes

5 of 24

Goal

5

Compress JSON-LD* Documents using a general algorithm.

* This mechanism will not work for JSON-only documents for reasons explained later in the presentation

6 of 24

CBOR-LD Results*

6

CBOR-LD with Semantic Compression

7 of 24

Verifiable Credentials

on Low Fidelity Displays

7

CBOR-LD Verifiable Credential

325 bytes

JSON-LD Verifiable Credential

1,217 bytes

8 of 24

How does it work?

8

9 of 24

How Compression Works

9

Reduce data duplication

aka: Don't Repeat Yourself (DRY)

VERY_LONG_VALUE_A

ANOTHER_BIG_VALUE_B

ANOTHER_BIG_VALUE_B

VERY_LONG_VALUE_A

Compression Dictionary

VERY_LONG_VALUE_A

1

ANOTHER_BIG_VALUE_B

2

1221

Compression Dictionary

VERY_LONG_VALUE_A

1

ANOTHER_BIG_VALUE_B

2

The key to good compression

10 of 24

CBOR-LD (no compression)

10

No dictionary. Just convert directly to CBOR.

d9 // CBOR Tag - next 2 bytes

0500 // CBOR Tag #1280 (Raw CBOR-LD)

a4 // Map, 4 pairs

68 // String, length: 8

40636f6e74657874 // {Key:0}, "@context"

78 // String, length next 1 byte

25 // String, length: 37

687474….616d73 // {Val:0}, "https://www.w3.org/ns/activitystreams"

67 // String, length: 7

73756d6d617279 // {Key:2}, "summary"

66 // String, length: 6

41206e6f7465 // {Val:2}, "A note"

67 // String, length: 7

...

{

"@context": "https://www.w3.org/ns/activitystreams",

"type": "Note",

"summary": "A note",

"content": "This is an example note.",

}

JSON-LD Document

140 bytes

Raw CBOR-LD Document

111 bytes

(20% smaller)

11 of 24

CBOR-LD Semantic Compression

11

Build compression dictionary using @context.

CBOR-LD Compression Dictionary for

https://www.w3.org/2018/credentials/v1

@context

0x01

issuanceDate

0x02

issuer

0x03

VerifiableCredential

0x04

… and so on...

No need to include the dictionary in data!

Globally linkable, industry-standard dictionary

12 of 24

CBOR-LD Semantic Compression

12

Semantic compression better than binary compression.

01 // {Key:0}, 1 - @context

10 // {Val:0}, 16 - https://www.w3.org/ns/activitystreams

{

"@context": "https://www.w3.org/ns/activitystreams",

...

}

53 bytes

2 bytes

This is the key innovation for getting compression ratios

that are far better than pure binary compression.

13 of 24

Term Compression

13

Compress known JSON-LD terms.

18 // Positive number, next 1 byte

2b // {Key:2}, 43 - type

0e // {Val:2}, 14 - VerifiablePresentation

{

"type": "VerifiablePresentation",

...

}

34 bytes

3 bytes

14 of 24

DateTime Compression

14

Compress xsd:dateTime values.

18 // Positive number, next 1 byte

1e // {Key:3}, 30 - issuanceDate

1a // Positive number, next 4 bytes

5f0e062c // {Val:3}, 1594754604 - 2020-07-14T19:23:24Z

{

"issuanceDate": "2020-07-14T19:23:24Z",

...

}

39 bytes

7 bytes

15 of 24

Binary Compression

15

Compress Multibase-encoded fields to raw bytes.

18 // Positive number, next 1 byte

26 // {Key:2}, 38 - proofValue

58 // Bytes, length next 1 byte

40 // Bytes, length: 64

e794357b...14258 // {Val:2} - EdDSA signature

{

"proofValue": "M55Q1ewxSHq5kS...Ui23IFCWA==",

...

}

107 bytes

68 bytes

16 of 24

URL Compression

16

Convert well-known URL patterns to binary.

18 // Positive number, next 1 byte

20 // {Key:2}, 32 - issuer

82 // {Val:2}, Array, 2 items

19 // Positive number, next 2 bytes

0400 // [0], 1024 - did:key

58 // Bytes, length next 1 byte

22 // Bytes, length: 34

ed012b5f69...1cb9fa628 // [1] - (Ed25519 public key)

{

"issuer": "did:key:z6MkhNZxXHvf4YMbtZkEkgA9QAz6gN8f9ZtP47EdCEJMF5Hh",

...

}

73 bytes

41 bytes

17 of 24

CBOR-LD Extensibility

17

Extensible encoders and decoders (codecs):

  • Global URL/Datatype codecs (base64url DIDs?)
  • Application-specific @context URLs
  • Application-specific URL/Datatype codecs

18 of 24

Benefits of CBOR-LD

18

  • Compression ratios up to 40% better than gzip/zlib.
  • Works on any compacted JSON-LD Document.
  • Data Integrity signatures do not need to change.
  • Extensible registry-based codec model.
  • Application-specific codecs.
  • "Practical" set of design trade-offs.

19 of 24

Drawbacks of CBOR-LD

19

  • As of July 2020 - it's new, expect bugs.
  • Doesn't work for JSON-only data.
  • Only works on compacted JSON-LD.
  • Processing overhead on top of JSON-LD.
  • Codecs are "more complex than necessary".
  • Not as compact as Artisanal CBOR.

20 of 24

CBOR-LD Results

20

CBOR-LD with Semantic Compression

21 of 24

The Vision for CBOR-LD

21

  • Eventually, byte-level semantic processing
  • Go to CBOR-LD and stay there
  • Semantic processing over fixed data structures
  • Smaller data means faster calculations
  • Push ability to reason (AI) to CPU register level

22 of 24

Questions?

22

23 of 24

Appendix

23

24 of 24

Links to Projects

  • Implementation
  • CBOR-LD Specification

24