Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JCS Context Injection #79

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
203 changes: 156 additions & 47 deletions index.html
Expand Up @@ -577,9 +577,11 @@ <h4>Verify Proof (eddsa-rdfc-2022)</h4>
href="#transformation-eddsa-rdfc-2022"></a> with |unsecuredDocument| and
|proofOptions| passed as parameters.
</li>
<li>
Let |proofConfig| be the result of running the algorithm in Section <a
href="#proof-configuration-eddsa-rdfc-2022"></a> with |unsecuredDocument| and
|proofOptions| passed as parameters.
</li>
<li>
Let |hashData| be the result of running the algorithm in Section
[[[#hashing-eddsa-rdfc-2022]]] with |transformedData| and |proofConfig|
Expand Down Expand Up @@ -696,7 +698,8 @@ <h4>Proof Configuration (eddsa-rdfc-2022)</h4>
</p>

<p>
The required inputs to this algorithm are <em>proof options</em>
The required inputs to this algorithm are the <em>document</em>
(|unsecuredDocument|) and the <em>proof options</em>
(<var>options</var>). The <em>proof options</em> MUST contain a type identifier
for the
<a data-cite="vc-data-integrity#dfn-cryptosuite">
Expand Down Expand Up @@ -841,45 +844,10 @@ <h3>eddsa-jcs-2022</h3>
The `eddsa-jcs-2022` cryptographic suite takes an input document, canonicalizes
the document using the JSON Canonicalization Scheme [[RFC8785]], and then
cryptographically hashes and signs the output resulting in the production of a
data integrity proof. The algorithms for this cryptographic suite are the same
as the ones in Section <a href="#eddsa-rdfc-2022"></a> except for the
following modifications:
data integrity proof.
</p>

<p>
In Section <a href="#transformation-eddsa-rdfc-2022"></a>, step
<strong>1)</strong> and step <strong>2)</strong> are replaced by the following
text:
</p>

<ol class="algorithm">
<li>
If <var>options</var>.<var>type</var> is not set to the string
`DataIntegrityProof` and <var>options</var>.<var>cryptosuite</var> is not
set to the string `eddsa-jcs-2022` then a `PROOF_TRANSFORMATION_ERROR` MUST be
raised.
</li>
<li>
Let <var>canonicalDocument</var> be the result of applying the
JSON Canonicalization Scheme [[RFC8785]] to the <var>unsecuredDocument</var>.
</li>
</ol>

<p>
In Section <a href="#proof-configuration-eddsa-rdfc-2022"></a>, step
<strong>8)</strong> is not performed, and steps <strong>4)</strong> and
<strong>9)</strong> are replaced by the following text:
</p>

<p style="padding-left: 2em;">
<strong>4)</strong> If <var>options</var>.<var>type</var> is not set to
`DataIntegrityProof` and <var>proofConfig</var>.<var>cryptosuite</var> is not
set to `eddsa-jcs-2022`, an `INVALID_PROOF_CONFIGURATION` error MUST be raised.
</p>
<p style="padding-left: 2em;">
<strong>9)</strong> Let <var>canonicalProofConfig</var> be the result of applying the
JSON Canonicalization Scheme [[RFC8785]] to the <var>proofConfig</var>.
</p>

<section>
<h4>Create Proof (eddsa-jcs-2022)</h4>
Expand All @@ -892,11 +860,70 @@ <h4>Create Proof (eddsa-jcs-2022)</h4>
is produced as output.
</p>

<p>
The algorithm is the same as the one described in Section
[[[#create-proof-eddsa-rdfc-2022]]] with the changes outlined in
Section [[[#eddsa-jcs-2022]]].
</p>
<ol class="algorithm">
<li>
Let |proof| be a clone of the proof options, |options|.
</li>
<li>
Let |proofConfig| be the result of running the algorithm in
Section [[[#proof-configuration-eddsa-rdfc-2022]]] with
|options| passed as a parameter and where
steps <strong>4)</strong> and
<strong>9)</strong> are replaced by the following text respectively:
<ol class="algorithm">
<li>
If <var>options</var>.<var>type</var> is not set to
`DataIntegrityProof` and <var>proofConfig</var>.<var>cryptosuite</var> is not
set to `eddsa-jcs-2022`, an error MUST be raised and it SHOULD use error
code `PROOF_GENERATION_ERROR`.
</li>
<li>
Let <var>canonicalProofConfig</var> be the result of applying the
JSON Canonicalization Scheme [[RFC8785]] to the <var>proofConfig</var>.
</li>
</ol>
</li>
<li>
Let |transformedData| be the result of running the algorithm in Section
<a href="#transformation-eddsa-rdfc-2022"></a> with |unsecuredDocument|,
|proofConfig|, and |options| passed as parameters where step
<strong>1)</strong> and step <strong>2)</strong> are respectively replaced by
the following texts:
<ol class="algorithm">
<li>
If <var>options</var>.<var>type</var> is not set to the string
`DataIntegrityProof` and <var>options</var>.<var>cryptosuite</var> is not
set to the string `eddsa-jcs-2022`, then an error MUST be raised and it SHOULD
use error code `PROOF_GENERATION_ERROR`.
</li>
<li>
Let <var>canonicalDocument</var> be the result of applying the
JSON Canonicalization Scheme [[RFC8785]] to the <var>unsecuredDocument</var>.
</li>
</ol>
</li>
<li>
Let |hashData| be the result of running the algorithm in Section
[[[#hashing-eddsa-rdfc-2022]]] with |transformedData| and |proofConfig|
passed as a parameters.
</li>
<li>
Let |proofBytes| be the result of running the algorithm in Section
[[[#proof-serialization-eddsa-rdfc-2022]]] with |hashData| and
|options| passed as parameters.
</li>
<li>
Set <var>proof</var>.<var>@context</var> to
<var>unsecuredDocument</var>.<var>@context</var>.
</li>
<li>
Let |proof|.|proofValue| be a <a data-cite="VC-DATA-INTEGRITY#multibase-0">
base58-btc-encoded Multibase value</a> of the |proofBytes|.
</li>
<li>
Return |proof| as the [=data integrity proof=].
</li>
</ol>
</section>

<section>
Expand All @@ -919,11 +946,92 @@ <h4>Verify Proof (eddsa-jcs-2022)</h4>
</dd>
</dl>

<p>
The algorithm is the same as the one described in Section
[[[#verify-proof-eddsa-rdfc-2022]]] with the changes outlined in
Section [[[#eddsa-jcs-2022]]].
</p>
<ol class="algorithm">
<li>
Let |unsecuredDocument| be a copy of |securedDocument| with
the `proof` value removed.
</li>
<li>
Let |proofOptions| be the result of a copy of |securedDocument|.|proof| with `proofValue`
removed.
</li>
<li>
Let |proofBytes| be the
<a data-cite="VC-DATA-INTEGRITY#multibase-0">Multibase decoded base58-btc
value</a> in |securedDocument|.|proof|.|proofValue|.
</li>
<li>
If |proofOptions|.<var>@context</var> exists:
<ol class="algorithm">
<li>
Check that the |securedDocument|.<var>@context</var> starts with all values
contained in the |proofOptions|.<var>@context</var> in the same order.
Otherwise, set |verified| to `false` and skip to the last step.
</li>
<li>
Set |unsecuredDocument|.<var>@context</var> equal to
|proofOptions|.<var>@context</var>.
</li>
</ol>
</li>
<li>
Let |transformedData| be the result of running the algorithm in Section
<a href="#transformation-eddsa-rdfc-2022"></a> with |unsecuredDocument| and
|proofOptions| passed as parameters where step
<strong>1)</strong> and step <strong>2)</strong> are respectively replaced by
the following texts:
<ol class="algorithm">
<li>
If <var>options</var>.<var>type</var> is not set to the string
`DataIntegrityProof` and <var>options</var>.<var>cryptosuite</var> is not
set to the string `eddsa-jcs-2022`, then a `PROOF_TRANSFORMATION_ERROR` MUST be
raised.
</li>
<li>
Let <var>canonicalDocument</var> be the result of applying the
JSON Canonicalization Scheme [[RFC8785]] to the <var>unsecuredDocument</var>.
</li>
</ol>
</li>
<li>
Let |proofConfig| be the result of running the algorithm in
Section [[[#proof-configuration-eddsa-rdfc-2022]]] with
|unsecuredDocument| and |proofOptions| passed as a parameters and where step
<strong>8)</strong> is not performed and steps <strong>4)</strong> and
<strong>9)</strong> are respectively replaced by the following texts:
<ol class="algorithm">
<li>
If <var>options</var>.<var>type</var> is not set to
`DataIntegrityProof` and <var>proofConfig</var>.<var>cryptosuite</var> is not
set to `eddsa-jcs-2022`, an `INVALID_PROOF_CONFIGURATION` error MUST be raised.
</li>
<li>
Let <var>canonicalProofConfig</var> be the result of applying the
JSON Canonicalization Scheme [[RFC8785]] to the <var>proofConfig</var>.
</li>
</ol>
</li>
<li>
Let |hashData| be the result of running the algorithm in Section
[[[#hashing-eddsa-rdfc-2022]]] with |transformedData| and |proofConfig|
passed as a parameters.
</li>
<li>
Let |verified:boolean| be the result of running the algorithm in Section
[[[#proof-verification-eddsa-rdfc-2022]]] algorithm on |hashData|,
|proofBytes|, and |proofConfig|.
</li>
<li>
Return a [=verification result=] with [=struct/items=]:
<dl data-link-for="verification result">
<dt>[=verified=]</dt>
<dd>|verified|</dd>
<dt>[=verifiedDocument=]</dt>
<dd>
|unsecuredDocument|, if |verified| is `true`; otherwise, <a data-cite="INFRA#nulls">Null</a></dd>
</dl>
</li>
</ol>
</section>

</section>
Expand Down Expand Up @@ -2336,6 +2444,7 @@ <h4>Extended Proof Chain</h4>
<pre class="example nohighlight" title="Signed Proof Chain (Extended)" data-include="TestVectors/proof-set-chain/signedProofChain2.json"
data-include-format="text"></pre>
</section>
</section>
</section>

<section class="informative">
Expand Down