You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: car.html
+16-21Lines changed: 16 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -46,16 +46,17 @@ <h2>Introduction</h2>
46
46
<section>
47
47
<h2>Parsing CAR</h2>
48
48
<p>
49
-
The CAR format comprises a sequence of length-prefixed block data, where the first
50
-
block in the CAR is the Header encoded as [<ahref="#ref-drisl" class="ref">drisl</a>], and the remaining blocks form
51
-
the Data component of the CAR and are each additionally prefixed with their CIDs ([<ahref="#ref-drisl" class="ref">drisl</a>], [<ahref="#ref-cid" class="ref">cid</a>]).
49
+
The CAR format is made of a Header followed by a Body. The Header is a length-prefixed
50
+
chunk of DRISL ([<ahref="#ref-drisl" class="ref">drisl</a>]) and the Body is a sequence of zero or more length-prefixed
51
+
blocks that contain a tuple of a DASL CID ([<ahref="#ref-cid" class="ref">cid</a>]) which is always 36 bytes long and
52
+
the data addressed by that CID.
52
53
The length prefix of each block in a CAR is encoded as an unsigned variable-length
53
54
integer ([<ahref="#ref-varint" class="ref">varint</a>], a variant of <ahref="https://en.wikipedia.org/wiki/LEB128">LEB128</a>).
54
55
This integer specifies the number of remaining bytes for that block entry, excluding
55
-
the bytes used to encode the integer, but including the CID for non-header blocks.
56
+
the bytes used to encode the integer, but including the CID for non-Header blocks.
56
57
</p>
57
-
<pre><code>|------- Header -------| |------------------- Data -------------------|
58
-
[ int | DAG-CBOR block ] [ int | CID | block ] [ int | CID | block ] …
58
+
<pre><code>|------- Header -------| |------------------- Body -------------------|
59
+
[ int | DAG-CBOR block ] [ int | CID | data ] [ int | CID | data ] …
59
60
</code></pre>
60
61
<p>
61
62
The steps to <dfnid="dfn-parse-a-car">parse a CAR</dfn> are:
@@ -75,15 +76,15 @@ <h2>Parsing CAR</h2>
75
76
<li>If <var>bytes</var> is empty, terminate these substeps.</li>
76
77
<li>
77
78
Run the steps to <ahref="#dfn-parse-a-car-block-header" class="dfn-ref">parse a CAR block header</a> with <var>bytes</var>
78
-
to obtain <var>cid</var> and <var>block size</var>.
79
+
to obtain <var>cid</var> and <var>data size</var>.
79
80
</li>
80
81
<li>
81
-
Read <var>block size</var> bytes from <var>bytes</var> and store the
82
-
result in <var>block</var>.
82
+
Read <var>data size</var> bytes from <var>bytes</var> and store the
83
+
result in <var>data</var>.
83
84
</li>
84
85
<li>
85
86
Push an entry onto <var>blocks</var> containing <var>cid</var>,
86
-
<var>block size</var>, and <var>block</var>.
87
+
<var>data size</var>, and <var>data</var>.
87
88
</li>
88
89
<li>Return to the beginning of these substeps.</li>
89
90
</ol>
@@ -100,7 +101,7 @@ <h2>Parsing CAR</h2>
100
101
<ul>
101
102
<li>
102
103
The object MUST contain a <code>version</code> map entry, the value of which
103
-
is always integer-type <code>1</code>. Version numbers is data formats are
104
+
is always integer-type <code>1</code>. Version numbers in data formats are
104
105
an anti-pattern, and as a result this number is guaranteed never to change.
105
106
</li>
106
107
<li>
@@ -161,17 +162,11 @@ <h2>Parsing CAR</h2>
161
162
<li>If <var>length</var> is 0, throw an error.</li>
162
163
<li>
163
164
Read a CID ([<ahref="#ref-cid" class="ref">cid</a>]) from <var>bytes</var> and store it in <var>cid</var>.
164
-
Note: the length of the CID can be inferred by reading its metadata
165
-
step by step until the <code>hash size</code> part, which is then used
166
-
to consume that many bytes from <var>bytes</var>.
165
+
Note: the length of the CID is always 36 bytes.
167
166
</li>
167
+
<li>Set <var>data size</var> to <var>length</var> minus 36 (the CID length).</li>
168
168
<li>
169
-
Set <var>CID length</var> to the number of bytes that were required to
170
-
read the CID.
171
-
</li>
172
-
<li>Set <var>block size</var> to <var>length</var> minus <var>CID length</var>.</li>
173
-
<li>
174
-
Return <var>block size</var> and <var>cid</var>.
169
+
Return <var>data size</var> and <var>cid</var>.
175
170
</li>
176
171
</ol>
177
172
</section>
@@ -214,7 +209,7 @@ <h3>Determinism</h3>
214
209
<section>
215
210
<h3>Security & Verifiability</h3>
216
211
<p>
217
-
The <code>roots</code> specified by the Header of a CAR is expected to appear somewhere in its Data section,
212
+
The <code>roots</code> specified by the Header of a CAR is expected to appear somewhere in its Body section,
218
213
however there is no requirement that the roots define entire DAGs, nor that all blocks
219
214
in a CAR must be part of DAGs described by the root CIDs in the Header. Therefore, the
220
215
<code>roots</code> must not be used alone to determine or differentiate the contents of a CAR.
0 commit comments