Internet-Draft | CoMETRE | March 2023 |
Steele, et al. | Expires 15 September 2023 | [Page] |
This specification describes three CBOR data structures for primary use in COSE envelopes. A format for Merkle Tree Root Signatures with metadata, a format for Inclusions Paths, and a format for disclosure of a single hadh tree leaf payload (Merkle Tree Proofs).¶
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.¶
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.¶
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."¶
This Internet-Draft will expire on 15 September 2023.¶
Copyright (c) 2023 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.¶
Merkle proofs are verifiable data structures that support secure data storage, through their ability to protect the integrity of batches of documents or collections of statements.¶
Merkle proofs can be used to prove a document is in a database (proof of existence), or that a smaller set of statements are contained in a large set of statements (proof of disclosure).¶
A merkle proof is a path from a leaf to a root in a merkle tree.¶
Merkle trees are constructed from simple operations such as concatenation and digest via a cryptographic hash function.¶
The simple design and valuable cryptographic properties of merkle trees have been leveraged in many network and database applications.¶
Differences in the representation of a merkle tree, merkle leaf and merkle inclusion proof can increase the burden for implementers, and create interoperability challenges.¶
This document describes the three data structures necessary to use merkle proofs with COSE envelopes.¶
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.¶
A merkle tree leaf is labelled with the cryptographic hash of a sequence of bytes. These bytes may be structured as a combination of Payload and Extra Data.¶
A Merkle tree is a tree where every leaf is labelled with the cryptographic hash of a sequence of bytes and every node that is not a leaf is labeled with the cryptographic hash of the labels of its child nodes.¶
A Merkle tree root is the root node of a tree which represents the cryptographic hash that commits to all leaves in the tree.¶
A Merkle tree algorithm specifies how nodes in the tree must be hashed to compute the root node.¶
A payload is data bound to in a Merkle tree leaf. The Merkle tree algorithm determines how a payload together with extra data is bound to a leaf. The simplest case is that the payload is the leaf itself without extra data.¶
An inclusion path confirms that a value is a leaf of a Merkle tree known only by its root hash (and tree size, possibly).¶
A signed Merkle tree proof is the combination of signed Merkle tree root hash, inclusion path, extra data, and payload.¶
This section describes representations of merkle tree structures in CBOR.¶
Some of the structures such as the construction of a merkle tree leaf, or an inclusion proof from a leaf to a merkle root, might have several different representations.¶
Some differences in representations are necessary to support efficient verification of proofs and compatibility with deployed tree algorithms used in specific implementations.¶
A Merkle tree root is signed with COSE_Sign1, creating a Signed Merkle Tree Root:¶
SMTR = THIS.COSE.profile .and COSE_Sign1_Tagged¶
Protected header parameters:¶
A COSE profile of this specification may add further header parameters, for example to identify the signer.¶
Payload: Merkle tree root hash bytes according to tree alg (i.e., header params tell you what the alg id is here)¶
Note: The payload is just a byte string representing the Merkle tree root hash (and not some wrapper structure) so that it can be detached (see defintion of payload in https://www.rfc-editor.org/rfc/rfc9052#section-4.1) and easily re-computed from an inclusion path and leaf bytes. This allows to design other structures that force re-computation and prevent faulty implementations (forgetting to match a computed root with one embedded in a signature).¶
One example of a Signed Merkle Tree Proof is a "transparent signed statement" or "claim" as defined in [I-D.ietf-scitt-architecture].¶
[RFC6962] defines a merkle audit path for a leaf in a merkle tree as the shortest list of additional nodes in the merkle tree required to compute the merkle root for that tree.¶
[RFC9162] changed the term from "merkle audit path" to "merkle inclusion proof".¶
We prefer to use the term "inclusion path" to avoid confusion with Signed Merkle Tree Proof.¶
If the tree size and leaf index is known, then a compact inclusion path variant can be used:¶
IndexAwareInclusionPath = #6.1234([ leaf_index: int hashes: [+ bstr] ])¶
Otherwise, the direction for each path step must be included:¶
FIXME bit vector: 0 right, 1 left, so no bit labels¶
IndexUnawareInclusionPath = #6.1235([ hashes: [+ bstr] left: uint ; bit vector ])¶
For some tree algorithms, the direction is derived from the hashes themselves and both the index and direction can be left out in the path:¶
; TODO: find a better name for this UndirectionalInclusionPath = #6.1236([+ bstr])¶
InclusionPath = IndexAwareInclusionPath / IndexUnawareInclusionPath / UndirectionalInclusionPath¶
Note: Including the tree size and leaf index may not be appropriate in certain privacy-focused applications as an attacker may be able to derive private information from them.¶
TODO: Should leaf index be part of inclusion path (IndexAwareInclusionPath) or outside?¶
TODO: Define root computation algorithm for each inclusion path type¶
TODO: Do we need both inclusion path types? what properties does each type have?¶
TODO: Should the inclusion path be opaque (bstr) and fixed by the tree algorithm? It seems this is orthogonal and the choice of inclusion path type should be application-specific.¶
A signed Merkle tree proof is a CBOR array containing a signed tree root, an inclusion path, extra data for the tree algorithm, and the payload.¶
SignedMerkleTreeProof = [ signed_tree_root: bstr .cbor SMTR ; payload of COSE_Sign1_Tagged is detached inclusion_path: bstr .cbor InclusionPath extra_data: bstr / nil payload: bstr ]¶
extra_data
is an additional input to the tree algorithm and is used together with the payload to compute the leaf hash. A use case for this field is to implement blinding.¶
TODO: maybe rename extra_data
¶
TODO: define a multi-leaf variant of a signed Merkle tree proof like in:¶
TODO: consider using sparse multiproofs, see https://medium.com/@jgm.orinoco/understanding-sparse-merkle-multiproofs-9b9f049e8f08 and https://arxiv.org/pdf/2002.07648.pdf¶
This document establishes a registry of Merkle tree algorithms with the following initial contents:¶
[FIXME] exploration table, what should go into -00?¶
Name | Label | Description |
---|---|---|
Reserved | 0 | |
RFC9162_SHA256 | 1 | RFC9162 with SHA-256 |
Each tree algorithm defines how to compute the root node from a sequence of leaves each represented by payload and extra data. Extra data is algorithm-specific and should be considered opaque.¶
The RFC9162_SHA256
tree algorithm uses the Merkle tree definition from [RFC9162] with SHA-256 hash algorithm.¶
For n > 1 inputs, let k be the largest power of two smaller than n.¶
MTH({d(0)}) = SHA-256(0x00 || d(0)) MTH(D[n]) = SHA-256(0x01 || MTH(D[0:k]) || MTH(D[k:n]))¶
where d(0)
is the payload. This algorithm takes no extra data.¶
IANA will be requested to register the new COSE Header parameters defined below in the "COSE Header Parameters" registry at some point.¶