<liclass="toctree-l1"><aclass="reference internal"href="oracles.html#implementing-an-oracle-with-continuously-varying-data">Implementing an oracle with continuously varying data</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="oracles.html#using-an-oracle">Using an oracle</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="setting-up-a-corda-network.html">Introduction - What is a corda network?</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="setting-up-a-corda-network.html#setting-up-your-own-network">Setting up your own network</a></li>
<h1>Consensus model<aclass="headerlink"href="#consensus-model"title="Permalink to this headline">¶</a></h1>
<p>The fundamental unit of consensus in Corda is the <strong>state</strong>. The concept of consensus can be divided into two parts:</p>
<olclass="arabic simple">
<li>Consensus over state <strong>validity</strong>– parties can reach certainty that a transaction defining output states is accepted by the contracts pointed to by the states and has all the required signatures. This is achieved by parties independently running the same contract code and validation logic (as described in <aclass="reference internal"href="data-model.html"><spanclass="doc">data model</span></a>)</li>
<li>Consensus over state <strong>uniqueness</strong>– parties can reach certainty the output states created in a transaction are the unique successors to the input states consumed by that transaction (in other words – a state has not been used as an input by more than one transaction)</li>
</ol>
<p>This article presents an initial model for addressing the <strong>uniqueness</strong> problem.</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">The current model is still a <strong>work in progress</strong> and everything described in this article can and is likely to change</p>
</div>
<divclass="section"id="notary">
<h2>Notary<aclass="headerlink"href="#notary"title="Permalink to this headline">¶</a></h2>
<p>We introduce the concept of a <strong>notary</strong>, which is an authority responsible for attesting that for a given transaction, it had not signed another transaction consuming any of its input states.
The data model is extended so that every <strong>state</strong> has an appointed notary:</p>
<p>All transactions have to be signed by their input state notary for the output states to be <strong>valid</strong> (apart from <em>issue</em> transactions, containing no input states).</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">The notary is a logical concept and can itself be a distributed entity, potentially a cluster maintained by mutually distrusting parties</p>
</div>
<p>When the notary is requested to sign a transaction, it either signs over it, attesting that the outputs are the <strong>unique</strong> successors of the inputs,
or provides conflict information for any input state that had been consumed by another transaction it had signed before.
In doing so, the notary provides the point of finality in the system. Until the notary signature is obtained, parties cannot be sure that an equally valid, but conflicting transaction,
will not be regarded as confirmed. After the signature is obtained, the parties know that the inputs to this transaction have been uniquely consumed by this transaction.
Hence it is the point at which we can say finality has occurred.</p>
<divclass="section"id="multiple-notaries">
<h3>Multiple notaries<aclass="headerlink"href="#multiple-notaries"title="Permalink to this headline">¶</a></h3>
<p>More than one notary can exist in the network. This gives the following benefits:</p>
<ulclass="simple">
<li><strong>Custom behaviour</strong>. We can have both validating and privacy preserving Notaries – parties can make a choice based on their specific requirements</li>
<li><strong>Load balancing</strong>. Spreading the transaction load over multiple Notaries will allow higher transaction throughput in the platform overall</li>
<li><strong>Low latency</strong>. Latency could be minimised by choosing a notary physically closer the transacting parties</li>
</ul>
<p>A transaction should only be signed by a notary if all of its input states point to it.
In cases where a transaction involves states controlled by multiple notaries, the states first have to be repointed to the same notary.
This is achieved by using a special type of transaction that doesn’t modify anything but the notary pointer of the state.
Ensuring that all input states point to the same notary is the responsibility of each involved party
(it is another condition for an output state of the transaction to be <strong>valid</strong>)</p>
</div>
<divclass="section"id="changing-notaries">
<h3>Changing notaries<aclass="headerlink"href="#changing-notaries"title="Permalink to this headline">¶</a></h3>
<li>Construct a transaction with the old state as the input and the new state as the output</li>
<li>Obtain signatures from all <em>participants</em> (a participant is any party that is able to consume this state in a valid transaction, as defined by the state itself)</li>
<li>Obtain the <em>old</em> notary signature</li>
<li>Record and distribute the final transaction to the participants so that everyone possesses the new state</li>
</ol>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">Eventually this will be handled automatically on demand.</p>
</div>
</div>
</div>
<divclass="section"id="validation">
<h2>Validation<aclass="headerlink"href="#validation"title="Permalink to this headline">¶</a></h2>
<p>One of the design decisions for a notary is whether or not to <strong>validate</strong> a transaction before committing its input states.</p>
<p>If a transaction is not checked for validity, it opens the platform to “denial of state” attacks, where anyone can build an invalid transaction consuming someone else’s states and submit it to the notary to get the states “blocked”.
However, validation of a transaction requires the notary to be able to see the full contents of the transaction in question and its dependencies.
This is an obvious privacy leak.</p>
<p>Our platform is flexible and we currently support both validating and non-validating notary implementations – a party can select which one to use based on its own privacy requirements.</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">In the non-validating model the “denial of state” attack is partially alleviated by requiring the calling
party to authenticate and storing its identity for the request. The conflict information returned by the notary
specifies the consuming transaction ID along with the identity of the party that had requested the commit. If the
of the conflicting invalid transaction are “un-committed” (to be covered by legal process).</p>
</div>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">At present all notaries can see the entire contents of a transaction, but we have a separate piece of work to
replace the parts of the transaction it does not require knowing about with hashes (only input references, timestamp
information, overall transaction ID and the necessary digests of the rest of the transaction to prove that the
referenced inputs/timestamps really do form part of the stated transaction ID should be visible).</p>
</div>
</div>
<divclass="section"id="timestamping">
<h2>Timestamping<aclass="headerlink"href="#timestamping"title="Permalink to this headline">¶</a></h2>
<p>In this model the notary also acts as a <em>timestamping authority</em>, verifying the transaction timestamp command.</p>
<p>For a timestamp to be meaningful, its implications must be binding on the party requesting it.
A party can obtain a timestamp signature in order to prove that some event happened before/on/or after a particular point in time.
However, if the party is not also compelled to commit to the associated transaction, it has a choice of whether or not to reveal this fact until some point in the future.
As a result, we need to ensure that the notary either has to also sign the transaction within some time tolerance,
or perform timestamping <em>and</em> notarisation at the same time, which is the chosen behaviour for this model.</p>
<p>There will never be exact clock synchronisation between the party creating the transaction and the notary.
This is not only due to physics, network latencies etc but because between inserting the command and getting the
notary to sign there may be many other steps, like sending the transaction to other parties involved in the trade
as well, or even requesting human signoff. Thus the time observed by the notary may be quite different to the
time observed in step 1.</p>
<p>For this reason, times in transactions are specified as time <em>windows</em>, not absolute times. Time windows can be
open-ended, i.e. specify only one of “before” and “after” or they can be fully bounded. If a time window needs to
be converted to an absolute time for e.g. display purposes, there is a utility method on <codeclass="docutils literal"><spanclass="pre">Timestamp</span></code> to
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.