<?xml version='1.0'?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd'>
<rfc ipr="trust200902" docName="draft-hallambaker-jbcd-container-01" category="info">
<?rfc toc="yes"?>  
<?rfc symrefs="yes"?>  
<?rfc sortrefs="yes"?>  
<?rfc compact="yes"?>  
<?rfc subcompact="no"?>  
<front>
<title abbrev="JBCD Data Container">JBCD Container</title>
<author fullname="Phillip Hallam-Baker" initials="P. M." surname="Hallam-Baker">
<organization>Comodo Group Inc.</organization>
<address>
<email>philliph@comodo.com</email>
</address>
</author>
<date day="10" month="April" year="2018"/>
<area/>
<workgroup/>
<abstract>
<t>
This document is also available online at <eref target="http://prismproof.org/Documents/draft-hallambaker-jbcd-container.html">
http://prismproof.org/Documents/draft-hallambaker-jbcd-container.html</eref>
.</t>
</abstract>
</front>
<middle>
<section title="Abstract" anchor="s-1">
<t>
This document describes JBCD Container, a message and file syntax that allows a sequence of data frames to be represented with cryptographic integrity, signature and encryption enhancements to be constructed in an append only format. The format supports data integrity checks using digest chains and Merkle trees. The simplest supports efficient append only write operations and efficient read operations in either the forward or reverse direction. Support for efficient random-access reads may be provided through the use of binary trees or index records appended to the end of the file.</t>
</section>
<section title="Introduction" anchor="s-2">
<t>
JBCD Container is a message and file syntax that allows a sequence of data frames to be represented with cryptographic integrity, signature, and encryption enhancements to be constructed in an append only format. JBCD Container was developed in response to needs that arose out of the design of the Mathematical Mesh <xref target="draft-hallambaker-jsonbcd">
</xref>
. It is built on the binary encodings of JSON data objects, JSON-B and JSON-C <xref target="draft-hallambaker-jsonbcd">
</xref>
. These requirements include:</t>
<t><list style="symbols">
<t>
Recording Mesh transactions in persistent storage.</t>
<t>
Synchronizing transaction logs between hosts.</t>
<t>
Representing message archives (aka mail spool)</t>
<t>
Signing and encrypting single data items.</t>
</list></t>
<t>
The features supported by JBCD Container include:</t>
<t><list style="symbols">
<t>
The format is append only, thus providing for rapid write operations and enabling the use of technologies that provide atomic transactions.</t>
<t>
All length and index values support the use of integers of at least 64 bits. </t>
<t>
Data frames may be of variable length.</t>
<t>
Data frames may be read in either direction. This allows the last n frames to be read as efficiently as the first n frames.</t>
<t>
Appending a data frame to an existing file is efficient taking no more than log2 (n) operations.</t>
<t>
A binary tree index MAY be constructed on an incremental basis, allowing random access to the nth record in the file in log2 (n) operations.</t>
<t>
An index MAY be appended to an existing container to allow random access to the nth record in the file in log2 (n) operations</t>
<t>
Permits the use of modern data encodings (e.g. JSON <xref target="RFC7159">
</xref>
).</t>
<t>
Supports digital signature and public key operations on the payloads of individual data frames.</t>
<t>
Data frame content (i.e. payload data) may be overwritten without invalidating the integrity of any other frame. This allows content to be expunged in exigent circumstances (court order, regulatory, confidentiality breach, etc.) without compromising the integrity of the rest of the data in the container. </t>
</list></t>
<t>
Many file proprietary formats are in use that support some or all of these capabilities but only a handful have public, let alone open, standards. JBCD Container is designed to provide a superset of the capabilities of existing message and file syntaxes, including:</t>
<t><list style="symbols">
<t>
Cryptographic Message Syntax <xref target="RFC5652">
</xref>
 defines a syntax used to digitally sign, digest, authenticate, or encrypt arbitrary message content.</t>
<t>
The.ZIP File Format specification <xref target="ZIPFILE">
</xref>
 developed by Phil Katz. </t>
<t>
The BitCoin Block chain <xref target="BLOCKCHAIN">
</xref>
.</t>
<t>
JSON Web Encryption and JSON Web Signature</t>
</list></t>
<t>
Attempting to make use of these specifications in a layered fashion would require at least three separate encoders and introduce unnecessary complexity. </t>
<t>
Every data format represents a compromise between different concerns, in particular:</t>
<t><list style="hanging">
<t hangText="Data Storage">
The space required to record data in the encoding.</t>
<t hangText="Memory Overhead">
The additional volatile storage (RAM) required to maintain indexes etc. to support efficient retrieval operations.</t>
<t hangText="Number of Operations">
The number of operations required to retrieve data from or append data to an existing encoded sequence.</t>
</list></t>
<t>
While the cost of storage of all types has declined rapidly over the past decades, so has the amount of data to be stored. JBCD Container represents a pragmatic balance of these considerations for current technology. In particular, since payload volumes are likely to be very large, memory and operational efficiency are considered higher priorities than data volume.</t>
</section>
<section title="Definitions" anchor="s-3">
<section title="Related Specifications" anchor="s-3_1">
<t>
JBCD Container makes use of the following related standards and specifications.</t>
<t><list style="hanging">
<t hangText="Encoding">
Content frame headers are encoded using JavaScript Object Notation (JSON) <xref target="RFC7159">
</xref>
, JSON-B or JSON-C <xref target="draft-hallambaker-jsonbcd">
</xref>
.</t>
<t hangText="Cryptography">
The encryption and signature schemes used are based on JSON Web Signature <xref target="RFC7515">
</xref>
 and JSON Web Encryption <xref target="RFC7516">
</xref>
.</t>
</list></t>
</section>
<section title="Requirements Language" anchor="s-3_2">
<t>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 <xref target="RFC2119">
</xref>
.</t>
</section>
</section>
<section title="Container Format" anchor="s-4">
<t>
A JBCD Container consists of a series of JBCD Frames. Each Frame consists of a non-empty sequence of  JBCD records.</t>
<t>
A JBCD frame consists of a forward length indicator, the framed data and a reverse length indicator. The reverse length indicator is written out backwards to allow the frame to be read in the reverse direction:</t>
<figure>
<preamble>
[[This figure is not viewable in this format. The figure is available at <eref target="http://prismproof.org/Documents/draft-hallambaker-jbcd-container.html">http://prismproof.org/Documents/draft-hallambaker-jbcd-container.html</eref>.]]</preamble>
<artwork>
</artwork>
<postamble>
JBCD Bidirectional Frame</postamble>
</figure>
<t>
When first reading an existing file, an application will typically read the first frame and the last frame (if the container has more than one frame). This allows the reader to quickly determine the format(s) used by the container, the number of frames in the container and the location of any index frames (if present).</t>
<t>
The container format is designed to support creation of write-once and append-only file formats. Each frame SHOULD be written as an atomic operation.</t>
<t>
The first frame in a container and the first record in a frame have special roles that are described in this document.</t>
<t><list style="symbols">
<t>
Container data MUST NOT occur in any place other than the first frame in the container or the first record in a frame.</t>
<t>
The first frame in a container describes the container format options. These include the range of encoding options for frame metadata supported and the container profiles to which the container conforms.</t>
<t>
The first record in a frame MUST NOT contain payload data</t>
</list></t>
<section title="Container Profile" anchor="s-4_1">
<t>
A key objective of the JBCD Container format is that the simplest possible reader be capable of reading any container file albeit with possibly reduced performance. </t>
<t>
A Container MAY conform to one or more profiles. Conforming to a profile typically requires a writer to provide additional information when writing a file but does not require a reader to interpret it unless use of a feature (e.g. authentication) that depends on the additional information is required.</t>
<section title="Index Profiles" anchor="s-4_1_1">
<t>
The following profiles are currently defined:</t>
<t><list style="hanging">
<t hangText="Tree">
Frame headers contain IndexPosition entries that specify the start position of previous frames. This enables efficient random access to any frame in the file.</t>
<t hangText="Digest">
Frame headers contain PayloadDigest entries that specify the digest value of the corresponding payload data in that frame.</t>
<t hangText="Chain">
Frame headers contain ChainDigest entries that link each frame to the preceding frame.</t>
<t hangText="Merkle">
Frame headers contain TreeDigestPartial and TreeDigestFinal entries linking all the frames in the container in a binary Merkle Tree.</t>
</list></t>
<t>
The use of Chain and Merkle Trees for integrity checks is described below.</t>
<t>
The use of Tree and Index frames is described below.</t>
</section>
<section title="Content Profiles" anchor="s-4_1_2">
<t>
The following profiles are currently defined:</t>
<t><list style="hanging">
<t hangText="Singleton">
A container with exactly one content frame. A container declared as a singleton frame cannot have additional content frames appended (but metadata frames may be) </t>
<t hangText="Multi">
A container whose payload data is limited to content frames. A container declared as a multi container may contain 0, 1 or more content frames.</t>
<t hangText="Archive">
A multi-container whose payload data is limited to content frames whose last frame contains a metadata index for the content frames in the container.</t>
<t hangText="Unitary">
A multi-container in which each frame represents exactly one payload object.</t>
<t hangText="Serial">
A multi-container in which payload objects MAY be split across multiple consecutive frames.</t>
<t hangText="Interleaved">
A multi-container in which payload objects MAY be split across multiple frames which may in turn be interleaved with frames containing other payload objects in complete or partial form.</t>
</list></t>
</section>
</section>
</section>
<section title="Data Types" anchor="s-5">
<section title="Container Metadata" anchor="s-5_1">
<t>
Header Encoding format</t>
</section>
<section title="Container Data" anchor="s-5_2">
<t>
Archive Index</t>
<t>
</t>
</section>
<section title="Content Metadata" anchor="s-5_3">
<t>
Frame headers MAY contain content metadata parameters.</t>
<t><list style="hanging">
<t hangText="ContentType">
The IANA content type for the payload data</t>
<t hangText="Paths">
One or more file or URI paths at which the payload data is to be located. Paths MAY be relative or global.</t>
<t hangText="Labels">
One or more labels applied to the frame to be used for filtering purposes.</t>
<t hangText="KeyValues">
One or more key value pairs providing index terms for the frame.</t>
</list></t>
<section title="Payload Signature" anchor="s-5_3_1">
<t>
Payload data MAY be signed JSON Web Signature <xref target="RFC7515">
</xref>
.</t>
<t>
Signatures are specified by the Signatures parameter in the content header. The data that the signature is calculated over is defined by the typ parameter of the Signature as follows.</t>
<t><list style="hanging">
<t hangText="Payload">
The frame payload data.</t>
<t hangText="PayloadDigest">
The value of the PayloadDigest parameter</t>
<t hangText="ChainDigest">
The value of the ChainDigest parameter</t>
<t hangText="TreeDigestFinal">
The value of the TreeDigestFinal parameter</t>
</list></t>
<t>
If the typ parameter is absent, the value Payload is implied.</t>
<t>
A frame MAY contain multiple signatures created with the same signing key and different typ values.</t>
<t>
The use of signatures over chain and tree digest values permit multiple frames to be validated using a single signature verification operation.</t>
</section>
<section title="Payload Encryption" anchor="s-5_3_2">
<t>
Payload data MAY be encrypted using JSON Web Encryption <xref target="RFC7516">
</xref>
.</t>
<t>
The payload data is encrypted under a session key whose encrypted value is specified by the EncryptedKey entry. The encryption key for the EncryptedKey is in turn specified by key exchange information provided in a JWE Recipients object that is placed in the frame header of either the frame that contains the encrypted payload data or an earlier frame whose file position is specified by a ExchangePosition entry.</t>
<t>
Use of EncryptedKey entries allows a container to contain multiple data segments encrypted using the same key agreement parameters. </t>
</section>
</section>
<section title="Content Payload" anchor="s-5_4">
<t>
Complete</t>
<t>
Incremental</t>
</section>
</section>
<section title="Index Mechanisms" anchor="s-6">
<t>
An index may be appended to an existing file at any time. Since the use of bidirectional frames makes reading the last record is as efficient as reading the first, the last record in an indexed file is usually either the index itself or a pointer to the last index.</t>
<t>
An index frame consists of a frame header</t>
<t>
Use of index frames provides read access to any record in the file in O(1) operations but attempting to compiling a complete index with every write incurs an O(n) penalty on write for both operations and storage. Accordingly, random read access to a file while it is being written is better supported using an index tree.</t>
<section title="Tree" anchor="s-6_1">
<t>
Binary search is supported by means of the TreePosition parameter specified in the FrameHeader. This parameter specifies the value of the immediately preceding apex.</t>
<t>
Calculation of the immediately preceding apex is most easily described by representing the array index in binary with base of 1 (rather than 0). An array index that is a power of 2 (2, 4, 8, 16, etc.) will be the apex of a complete tree. Every other array index has the value of the sum of a set of powers of 2 and the immediately preceding apex will be the value of the next smallest power of 2 in the sum.</t>
<t>
For example, to find the immediately preceding apex for frame 5, we add 1 to get 6. 6 = 4 + 2, so we ignore the 2 and the preceding frame is 4.</t>
<t>
The values of Tree Position are shown for the first 8 frames in figure xx below:</t>
<figure>
<preamble>
[[This figure is not viewable in this format. The figure is available at <eref target="http://prismproof.org/Documents/draft-hallambaker-jbcd-container.html">http://prismproof.org/Documents/draft-hallambaker-jbcd-container.html</eref>.]]</preamble>
<artwork>
</artwork>
<postamble>
Merkle Tree Integrity check</postamble>
</figure>
<t>
An algorithm for efficiently calculating the immediately preceding apex is provided in Appendix C.</t>
</section>
<section title="Position Index" anchor="s-6_2">
<t>
Contains a table of index, position pairs pointing to prior locations in the file.</t>
</section>
<section title="Metadata Index" anchor="s-6_3">
<t>
Contains a list of IndexMeta entries. Each entry contains a metadata description and a list of frame indexes (not positions) of frames that match the description.</t>
</section>
</section>
<section title="Integrity Mechanisms" anchor="s-7">
<t>
Frame sequences in a JWC container MAY be protected against a frame insertion attack by means of a digest chain, a binary Merkle tree or both.</t>
<section title="Digest Chain calculation" anchor="s-7_1">
<t>
A digest chain is simple to implement but can only be verified if the full chain of values is known. Appending a frame to the chain has O(1) complexity but verification has O(n) complexity:</t>
<figure>
<preamble>
[[This figure is not viewable in this format. The figure is available at <eref target="http://prismproof.org/Documents/draft-hallambaker-jbcd-container.html">http://prismproof.org/Documents/draft-hallambaker-jbcd-container.html</eref>.]]</preamble>
<artwork>
</artwork>
<postamble>
Hash chain integrity check</postamble>
</figure>
<t>
The value of the chain digest for the the first frame (frame 0) is H(IV+H(Payload0)), where IV is an initialization vector consisting of a string of zero bytes and payloadn is the sequence of payload data bytes for frame n</t>
<t>
The value of the chain digest for frame n is H(H(Payloadn-1 +H(Payloadn)), where A+B stands for concatenation of the byte sequences A and B.</t>
</section>
<section title="Binary Merkle tree calculation" anchor="s-7_2">
<t>
The tree index mechanism describe earlier may be used to implement a binary Merkle tree. The value TreeDigest specifies the apex value of the tree for that node.</t>
<t>
Appending a frame to the chain has O(log2n) complexity provided that the container format supports at least the binary tree index. Verifying a chain has O(log2 n) complexity, provided that the set of necessary digest inputs is known.</t>
<t>
To calculate the value of the tree digest for a node, we first calculate the values of all the sub trees that have their apex at that node and then calculate the digest of that value and the immediately preceding local apex.</t>
</section>
</section>
<section title="Cryptographic Enhancement" anchor="s-8">
<section title="Content Frame" anchor="s-8_1">
<t><list style="hanging">
<t hangText="Record 0">
The key exchange keys under which the successive records are encrypted.</t>
<t hangText="Record 1">
The encrypted content metadata. This frame MAY be empty</t>
<t hangText="Record 2">
The encrypted payload data.</t>
<t hangText="Record 3">
The encrypted signature data. This frame MAY be empty or omitted.</t>
</list></t>
<t>
</t>
</section>
<section title="Cryptographic Singleton Container" anchor="s-8_2">
<t>
</t>
<t><list style="hanging">
<t hangText="Frame 0">
Describes the format of the container.</t>
<t hangText="Frame 1">
The content frame</t>
<t hangText=""></t>
</list></t>
<t>
</t>
</section>
<section title="Cryptographic Multi-Frame, Unitary content" anchor="s-8_3">
<t>
This format is as for the singleton container except that Frame 0 may be followed by any number of content frames </t>
<t><list style="hanging">
<t hangText="Frame 0">
Describes the format of the container.</t>
<t hangText="Frame 1">
The first content frame</t>
<t hangText="Frame 2">
The second content frame</t>
<t hangText="?">
</t>
<t hangText="?"></t>
<t hangText="Frame n">
The nth content frame.</t>
</list></t>
<t>
</t>
</section>
<section title="Cryptographic Multi-Frame, Serial content" anchor="s-8_4">
<t>
</t>
</section>
</section>
<section title="Further Work" anchor="s-9">
<t>
The container format is intended to be the basis of future work to support:</t>
<t><list style="symbols">
<t>
Very large container sizes (larger than the size of the host's memory).</t>
<t>
Partitioning of very large data sets across multiple hosts with parallel append.</t>
<t>
Fault tolerance</t>
</list></t>
<section title="Fast open with random access" anchor="s-9_1">
<t>
The container format is designed to be capable of supporting efficient random access to frames in containers considerably larger than the processing memory of the host computer without the need to pre-load indexes. </t>
<t>
A combination of the following strategies is being considered:</t>
<t><list style="symbols">
<t>
Use memory mapped file views to container data to optimize random access times while controlling memory use and time taken to construct memory views.</t>
<t>
When the container is first bound, use the binary tree index data in TreePosition parameters to support random access operations until index building is complete.</t>
<t>
Perform Index building operations as a non-blocking background task.</t>
</list></t>
</section>
<section title="Partitioning of very large data sets across hosts" anchor="s-9_2">
<t>
While storage devices capable of storing tends of Tb of data with RAID redundancy are commonplace, it is generally desirable that there be at least as many CPU cores as disks. Thus, partitioning of data sets across multiple hosts becomes desirable for throughput even if a single host could handle the storage requirement.</t>
</section>
<section title="Filtering and redaction" anchor="s-9_3">
<t>
In the types of applications envisaged in the Mesh, almost every data set may be reduced to collections that are bound to a single account. While it is obviously desirable that a user's mail messages (for example) be replicated across multiple machines to provide fault tolerance, fragmenting the copies of this data set across multiple machines should be avoided unless the data volumes are so large as to require it.</t>
</section>
<section title="Encryption of large data blocks" anchor="s-9_4">
<t>
The encoding scheme is 64-bit clean throughout and thus supports containers and frames as large as 18 petabytes. Larger data volumes could be supported through use of 128-bit integer pointers but even if the technology to support such data volumes were developed, it is highly unlikely anyone would want to represent data sets anywhere near this size in a serial format.</t>
<t>
Due to limitations in the design of the encryption schemes that may be used (e.g. AES-GCM), the maximum encrypted frame size is 64GB. While this is not currently a major concern for encryption of individual data files, it is easy to see situations in which an archive of encrypted files could exceed that amount. One possibility would be to define a modification to AES -GCM which caused the encryption key to be incremented by a fixed amount after encrypting a certain amount of data, though this might well present implementation challenges unless the maximum data block size was chosen to be deliberately small so as to force code paths to be exercised. Another possibility would be to limit the size of encrypted data frames by requiring the frame pointer to be no larger than 32 bits and require larger data items to be represented as a sequence of frames.</t>
</section>
<section title="Concurrent Writes" anchor="s-9_5">
<t>
The container format deliberately avoids support for concurrent write operations. Should this be desirable, some mechanism must be provided to cache write fragments to an intermediate file and then consolidate them for writing to the master log.</t>
</section>
</section>
<section title="Security Considerations" anchor="s-10">
</section>
<section title="IANA Considerations" anchor="s-11">
</section>
<section title="Acknowledgements" anchor="s-12">
</section>
<section title="Appendix A: Examples and Test Vectors" anchor="s-13">
<t>
The data payloads in all the following examples are identical, only the authentication and/or encryption is different.  </t>
<t><list style="symbols">
<t>
 Frame 1..n consists of 300 bytes being the byte sequence 00, 01, 02, etc.  repeating after 256 bytes. </t>
</list></t>
<t>
For conciseness, the wire format is omitted for examples after the first, except where the data payload has been transformed, (i.e. encrypted). </t>
<section title="Simple container" anchor="s-13_1">
<t>
Here the simple container: </t>
<figure anchor="s-13_1-2">
<artwork>
<![CDATA[f4 2c 
f0 2a 
  7b 0a 20 20 22 49 6e 64   65 78 22 3a 20 30 2c 0a 
  20 20 22 43 6f 6e 74 61   69 6e 65 72 54 79 70 65 
  22 3a 20 22 4c 69 73 74   22 7d 
2c f4 
f5 01 40 
f0 0f 
  7b 0a 20 20 22 49 6e 64   65 78 22 3a 20 31 7d 
f1 01 2c 
  00 01 02 03 04 05 06 07   08 09 0a 0b 0c 0d 0e 0f 
  10 11 12 13 14 15 16 17   18 19 1a 1b 
  ...
  10 11 12 13 14 15 16 17   18 19 1a 1b 1c 1d 1e 1f 
  20 21 22 23 24 25 26 27   28 29 2a 2b 
40 01 f5 
[EOF] 

]]></artwork>
</figure>
<t>
The header values are: </t>
<t>
Frame 0 </t>
<figure anchor="s-13_1-5">
<artwork>
<![CDATA[{
  "ContainerHeader": {
    "Index": 0,
    "ContainerType": "List"}}]]></artwork>
</figure>
<t>
Frame 1 </t>
<figure anchor="s-13_1-7">
<artwork>
<![CDATA[{
  "ContainerHeader": {
    "Index": 1}}]]></artwork>
</figure>
</section>
<section title="Payload and chain digests" anchor="s-13_2">
<t>
Frame 0 </t>
<figure anchor="s-13_2-2">
<artwork>
<![CDATA[{
  "ContainerHeader": {
    "Index": 0,
    "PayloadDigest": "
z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg_SpIdNs6c5H0NE8XYXysP-DGNKHfuwv
Y7kxvUdBeoGlODJ6-SfaPg",
    "ChainDigest": "
FEHy24Y6cLModDXWH31kVc2a3TdhjXPooKHpLAb2JbsO1YQnJolmowXAYHhkOGY0
kg3jrKNTjds0myf4Dw1sdg"}}]]></artwork>
</figure>
<t>
Frame 1 </t>
<figure anchor="s-13_2-4">
<artwork>
<![CDATA[{
  "ContainerHeader": {
    "Index": 1,
    "PayloadDigest": "
8dyi62d7MDJlsLm6_w4GEgKBjzXBRwppu6qbtmAl6UjZDlZeaWQlBsYhOu88-ekp
NXpZ2iY96zTRI229zaJ5sw",
    "ChainDigest": "
7JaijhBvQUOjBiO1_Zt6NtJil8iB0rW9HeM_4iYooc_AaAfutlF0LLVY6PO7INB-
eztypyEqVzgMil9JkjtRGQ"}}]]></artwork>
</figure>
<t>
Frame 2 </t>
<figure anchor="s-13_2-6">
<artwork>
<![CDATA[{
  "ContainerHeader": {
    "Index": 2,
    "PayloadDigest": "
8dyi62d7MDJlsLm6_w4GEgKBjzXBRwppu6qbtmAl6UjZDlZeaWQlBsYhOu88-ekp
NXpZ2iY96zTRI229zaJ5sw",
    "ChainDigest": "
wJZFYd61nntCJ0Bv80l6-Cn-sR2u3iD0zCRjOLxje8dsKIuUnP4X1mgeNenNDBdX
ysrFs3vVAqkC-hfSAPF0Aw"}}]]></artwork>
</figure>
<t>
Frame 3 </t>
<figure anchor="s-13_2-8">
<artwork>
<![CDATA[{
  "ContainerHeader": {
    "Index": 3,
    "PayloadDigest": "
8dyi62d7MDJlsLm6_w4GEgKBjzXBRwppu6qbtmAl6UjZDlZeaWQlBsYhOu88-ekp
NXpZ2iY96zTRI229zaJ5sw",
    "ChainDigest": "
RORNZxIcM23cZtXPh9vuHhkgiGa_O4a0ZiU0ku2OK4dB974clvh5F0VZsX7IwVBa
yAG2nDTdqhyZ-qOnTRiumA"}}]]></artwork>
</figure>
</section>
<section title="Merkle Tree" anchor="s-13_3">
<t>
Frame 0 </t>
<figure anchor="s-13_3-2">
<artwork>
<![CDATA[{
  "ContainerHeader": {
    "Index": 0,
    "TreePosition": 0,
    "PayloadDigest": "
z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg_SpIdNs6c5H0NE8XYXysP-DGNKHfuwv
Y7kxvUdBeoGlODJ6-SfaPg",
    "TreeDigest": "
FEHy24Y6cLModDXWH31kVc2a3TdhjXPooKHpLAb2JbsO1YQnJolmowXAYHhkOGY0
kg3jrKNTjds0myf4Dw1sdg"}}]]></artwork>
</figure>
<t>
Frame 1 </t>
<figure anchor="s-13_3-4">
<artwork>
<![CDATA[{
  "ContainerHeader": {
    "Index": 1,
    "TreePosition": 0,
    "PayloadDigest": "
8dyi62d7MDJlsLm6_w4GEgKBjzXBRwppu6qbtmAl6UjZDlZeaWQlBsYhOu88-ekp
NXpZ2iY96zTRI229zaJ5sw",
    "TreeDigest": "
fPTYagAvSDP_755jpFUs-Wq6cgvtr5vrFwW-E12vsrbq1ReNsGzp-V2XqzFPiWaU
ckACPjegD7ioe1bGzxoWQQ"}}]]></artwork>
</figure>
<t>
Frame 2 </t>
<figure anchor="s-13_3-6">
<artwork>
<![CDATA[{
  "ContainerHeader": {
    "Index": 2,
    "TreePosition": 263,
    "PayloadDigest": "
8dyi62d7MDJlsLm6_w4GEgKBjzXBRwppu6qbtmAl6UjZDlZeaWQlBsYhOu88-ekp
NXpZ2iY96zTRI229zaJ5sw",
    "TreeDigest": "
7fyKKQNLGEeHX1oCsV8NtOdPm615SkDnM1vkcexx2tOuVd5kkZIdLdsWRCLic9lu
TSsUN6D6_-c-8ftbhL9dJg"}}]]></artwork>
</figure>
<t>
Frame 3 </t>
<figure anchor="s-13_3-8">
<artwork>
<![CDATA[{
  "ContainerHeader": {
    "Index": 3,
    "TreePosition": 263,
    "PayloadDigest": "
8dyi62d7MDJlsLm6_w4GEgKBjzXBRwppu6qbtmAl6UjZDlZeaWQlBsYhOu88-ekp
NXpZ2iY96zTRI229zaJ5sw",
    "TreeDigest": "
b9ca9Pv-6fxUg-V3ulOhhRngxebkZCxyDmWhQUYeADmSvvPbjMcNTUJxdDpKlMPr
DBInSWMChinsc5s9Tv4byw"}}]]></artwork>
</figure>
<t>
Frame 4 </t>
<figure anchor="s-13_3-10">
<artwork>
<![CDATA[{
  "ContainerHeader": {
    "Index": 4,
    "TreePosition": 1398,
    "PayloadDigest": "
8dyi62d7MDJlsLm6_w4GEgKBjzXBRwppu6qbtmAl6UjZDlZeaWQlBsYhOu88-ekp
NXpZ2iY96zTRI229zaJ5sw",
    "TreeDigest": "
g1hQeWJgDlNoTSGfMb6NhQk5-p6iaAI2_GiAhBM-F2Cp3UvJ7AR_bC2Drp5YElGX
AzC2K5qZ30l7j2D-jqykFw"}}]]></artwork>
</figure>
<t>
Frame 5 </t>
<figure anchor="s-13_3-12">
<artwork>
<![CDATA[{
  "ContainerHeader": {
    "Index": 5,
    "TreePosition": 1398,
    "PayloadDigest": "
8dyi62d7MDJlsLm6_w4GEgKBjzXBRwppu6qbtmAl6UjZDlZeaWQlBsYhOu88-ekp
NXpZ2iY96zTRI229zaJ5sw",
    "TreeDigest": "
p89BhjJAgMMoSrOmot6oaBGa6Dgz-zogZjZ9mm1Iz4yLHxm97nWAIBaZFiC1XkuC
oP-tr3tag_rHoZhgQV8_PQ"}}]]></artwork>
</figure>
<t>
Frame 6 </t>
<figure anchor="s-13_3-14">
<artwork>
<![CDATA[{
  "ContainerHeader": {
    "Index": 6,
    "TreePosition": 2537,
    "PayloadDigest": "
8dyi62d7MDJlsLm6_w4GEgKBjzXBRwppu6qbtmAl6UjZDlZeaWQlBsYhOu88-ekp
NXpZ2iY96zTRI229zaJ5sw",
    "TreeDigest": "
HEA7EeUGfSjZqjmN3PDp0FVbnixBBXfSQAYm_rNPHVWJVMDu3SfmxKvN_yBTtMXk
-Jad9cyXDKsecLNHLyoQWg"}}]]></artwork>
</figure>
</section>
<section title="Signed container" anchor="s-13_4">
</section>
<section title="Encrypted container" anchor="s-13_5">
</section>
</section>
<section title="Appendix C" anchor="s-14">
</section>
<section title="Appendix B" anchor="s-15">
<figure anchor="s-15-1">
<artwork>
<![CDATA[public long PreviousFrame (long Frame) {]]></artwork>
</figure>
<figure anchor="s-15-2">
<artwork>
<![CDATA[
    long x2 = Frame + 1;]]></artwork>
</figure>
<figure anchor="s-15-3">
<artwork>
<![CDATA[
    long d = 1;]]></artwork>
</figure>
<figure anchor="s-15-4">
<artwork>
<![CDATA[
]]></artwork>
</figure>
<figure anchor="s-15-5">
<artwork>
<![CDATA[
    while (x2 > 0) {]]></artwork>
</figure>
<figure anchor="s-15-6">
<artwork>
<![CDATA[
        if ((x2 & 1) == 1) {]]></artwork>
</figure>
<figure anchor="s-15-7">
<artwork>
<![CDATA[
            return x2 == 1 ? (d / 2) - 1 : Frame - d;]]></artwork>
</figure>
<figure anchor="s-15-8">
<artwork>
<![CDATA[
            }]]></artwork>
</figure>
<figure anchor="s-15-9">
<artwork>
<![CDATA[
        d = d * 2;]]></artwork>
</figure>
<figure anchor="s-15-10">
<artwork>
<![CDATA[
        x2 = x2 / 2;]]></artwork>
</figure>
<figure anchor="s-15-11">
<artwork>
<![CDATA[
        }]]></artwork>
</figure>
<figure anchor="s-15-12">
<artwork>
<![CDATA[
    return 0;]]></artwork>
</figure>
<figure anchor="s-15-13">
<artwork>
<![CDATA[
    }]]></artwork>
</figure>
</section>
</middle>
<back>
<references title="Normative References">
<reference anchor="RFC7159">
<front>
<title>The JavaScript Object Notation (JSON) Data Interchange Format</title>
<author fullname="T. Bray" initials="T." surname="Bray">
<organization/>
<address>
</address>
</author>
<date month="March" year="2014"/>
</front>
<seriesInfo name="RFC" value="7159"/>
<seriesInfo name="DOI" value="10.17487/RFC7159"/>
</reference>
<reference anchor="RFC7516">
<front>
<title>JSON Web Encryption (JWE)</title>
<author fullname="M. Jones" initials="M." surname="Jones">
<organization/>
<address>
</address>
</author>
<author fullname="J. Hildebrand" initials="J." surname="Hildebrand">
<organization/>
<address>
</address>
</author>
<date month="May" year="2015"/>
</front>
<seriesInfo name="RFC" value="7516"/>
<seriesInfo name="DOI" value="10.17487/RFC7516"/>
</reference>
<reference anchor="RFC2119">
<front>
<title>Key words for use in RFCs to Indicate Requirement Levels</title>
<author fullname="S. Bradner" initials="S." surname="Bradner">
<organization/>
<address>
</address>
</author>
<date month="March" year="1997"/>
</front>
<seriesInfo name="BCP" value="14"/>
<seriesInfo name="RFC" value="2119"/>
<seriesInfo name="DOI" value="10.17487/RFC2119"/>
</reference>
<reference anchor="draft-hallambaker-jsonbcd">
<front>
<title>Binary Encodings for JavaScript Object Notation: JSON-B, JSON-C, JSON-D</title>
<author fullname="Phillip Hallam-Baker" initials="P" surname="Hallam-Baker">
<organization/>
<address>
</address>
</author>
<date day="18" month="September" year="2017"/>
</front>
<seriesInfo name="Internet-Draft" value="draft-hallambaker-jsonbcd-09"/>
<format type="TXT" target="http://www.ietf.org/internet-drafts/draft-hallambaker-jsonbcd-09.txt"/>
</reference>
<reference anchor="RFC7515">
<front>
<title>[Reference Not Found!]</title>
<author initials="" surname="">
<organization/>
<address>
</address>
</author>
<date/>
</front>
</reference>
</references>
<references title="Informative References">
<reference anchor="ZIPFILE">
<front>
<title>APPNOTE.TXT - .ZIP File Format Specification</title>
<author>
<organization>PKWARE Inc</organization>
<address>
</address>
</author>
<date month="October" year="2014"/>
</front>
<format type="txt" target="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
</reference>
<reference anchor="BLOCKCHAIN">
<front>
<title>Blockchain Specification</title>
<author>
<organization>Chain.com</organization>
<address>
</address>
</author>
<date/>
</front>
<format type="html" target="https://chain.com/docs/1.2/protocol/specifications/blockchain"/>
</reference>
<reference anchor="RFC5652">
<front>
<title>Cryptographic Message Syntax (CMS)</title>
<author fullname="R. Housley" initials="R." surname="Housley">
<organization/>
<address>
</address>
</author>
<date month="September" year="2009"/>
</front>
<seriesInfo name="STD" value="70"/>
<seriesInfo name="RFC" value="5652"/>
<seriesInfo name="DOI" value="10.17487/RFC5652"/>
</reference>
</references>
</back>
</rfc>
