This specification describes the Merkle Proof Signature Suite created in 2017 for the Linked Data Signatures specification.

This is an experimental specification and is undergoing regular revisions. It is not fit for production deployment.

Introduction

This specification describes the Merkle Proof Signature Suite created in 2017 for the Linked Data Signatures [[LD-SIGNATURES]] specification. It uses the RDF Dataset CANONICALIZATION Algorithm [[RDF-DATASET-CANONICALIZATION]] to transform the input document into its canonical form. It uses SHA-256 [[RFC6234]] as the message digest algorithm and the RS256 algorithm defined in JSON Web Signatures [[RFC7515]] as the signature algorithm.

Terminology

The following terms are used to describe concepts involved in the generation and verification of the Linked Data Signature 2017 signature suite.

signature suite
A specified set of cryptographic primitives typically consisting of a canonicalization algorithm, a message digest algorithm, and a signature algorithm that are bundled together by cryptographers for developers for the purposes of safety and convenience.
canonicalization algorithm
An algorithm that takes an input document that has more than one possible representation and always transforms it into a canonical form. This process is sometimes also called CANONICALIZATION.
message digest algorithm
An algorithm that takes an input message and produces a cryptographic output message that is often many orders of magnitude smaller than the input message. These algorithms are often 1) very fast, 2) non-reversible, 3) cause the output to change significantly when even one bit of the input message changes, and 4) make it infeasible to find two different inputs for the same output.
signature algorithm
An algorithm that takes an input message and produces an output value where the receiver of the message can mathematically verify that the message has not been modified in transit and came from someone possessing a particular secret.

The 2017 Merkle Proof Signature Suite

The 2017 Merkle Proof signature suite MUST be used in conjunction with the signing and verification algorithms in the Linked Data Signatures [[LD-SIGNATURES]] specification. The suite consists of the following algorithms:

Parameter Value Specification
canonicalizationAlgorithm https://w3id.org/security#GCA2015 [[RDF-DATASET-CANONICALIZATION]]
digestAlgorithm https://registry.ietf.org/ietf-digest-algorithms#SHA256 [[RFC6234]]
signatureAlgorithm https://w3c-dvcg.github.io/lds-koblitz2016/ [[LDS-KOBLITZ2016]]

Modification to Algorithms

This signature suite uses the [[LDS-KOBLITZ2016]]. The signature algorithm uses the Koblitz Elliptic Curve, also known as secp256k1, used by Bitcoin and Ethereum.

Modifications to Signature Algorithm

The digital signature algorithm defined in Section 7.1: Signature Algorithm takes an array of tbs, a privateKey, and options as inputs and produces a signatureValue as output.

  1. Take an array of tbs, which is an array of the data to be signed, as input and generate a Merkle Tree.
  2. Include the root of the Merkle Tree ("Merkle Root") in the data field of the Blockchain transaction. For Bitcoin this is the OP_RETURN field.
  3. Sign the transaction with encoding of privateKey appropriate for the blockchain. For Bitcoin this is a WIF encoding. Per the signature suite definition, this is using [[LDS-KOBLITZ2016]].
  4. For each tbs, create the signature element, which includes:
    • The hash of the element as targetHash
    • The merkle root as merkleRoot
    • The Merkle Proof for tbs, which is the path from targetHash to merkleRoot in the Merkle Tree, as proof. The should not include the endpoints of the path (targetHash and merkleRoot)
    • The blockchain anchor(s) as anchors. This describes how to look up the blockchain transaction. Its fields include the type of blockchain transaction as type and the transaction id as sourceId.
  5. Return the result as signatureValue.
List all blockchain type values. Note that we should call out testnet explicitly

Modifications to Signature Verification Algorithm

The digital signature algorithm defined in Section 7.2: Signature Verification Algorithm takes the value to be verified, a tbv, the public key to the signature algorithm and returns a boolean value.

  1. Validate the values targetHash, proof, and merkleRoot form a valid Merkle Path.
  2. Verify that targetHash matches the JSON-LD canonicalized, SHA256 Hash of tbv.
  3. Verify merkleRoot matches what is stored in the transaction at sourceId on blockchain type.
  4. If all of the above checks pass, return true, otherwise return false.
Add references and more pointers to merkle tree operations.
Should we use tx ref encoding instead of txids?

Security Considerations

The following section describes security considerations that developers implementing this specification should be aware of in order to create secure software.

TODO: We need to add a complete list of security considerations.

Examples

A simple example of an RSA 2017 signature:


  "signature": {
    "@context": ["http://schema.org/", "https://w3id.org/security/v1"],
    "type": "MerkleProof2017",
    "targetHash": "637ec732fa4b7b56f4c15a6a12680519a17a9e9eade09f5b424a48eb0e6f5ad0",
    "merkleRoot": "f029b45bb1a7b1f0b970f6de35344b73cccd16177b4c037acbc2541c7fc27078",
    "anchors": [
      {
        "sourceId": "d75b7a5bdb3d5244b753e6b84e987267cfa4ffa7a532a2ed49ad3848be1d82f8",
        "type": "BTCOpReturn"
      }
    ],
    "proof": [
      {
        "right": "11174e220fe74de907d1107e2a357e41434123f2948fc6b946fbfd7e3e3eecd1"
      }
    ]
  }