-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.html
2796 lines (2566 loc) · 100 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>Data Integrity EdDSA Cryptosuites v1.0</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<!--
=== NOTA BENE ===
For the three scripts below, if your spec resides on dev.w3 you can check them
out in the same tree and use relative links so that they'll work offline,
-->
<script src="https://www.w3.org/Tools/respec/respec-w3c" class="remove"></script>
<script class="remove" src="https://w3c.github.io/vc-data-integrity/common.js"></script>
<script type="text/javascript" class="remove">
var respecConfig = {
subtitle: "Achieving Data Integrity using EdDSA with Edwards curves",
// specification status (e.g. WD, LCWD, NOTE, etc.). If in doubt use ED.
specStatus: "CR",
// the specification's short name, as in http://www.w3.org/TR/short-name/
shortName: "vc-di-eddsa",
group: "vc",
// if you wish the publication date to be other than today, set this
publishDate: "2024-12-19",
crEnd: "2024-01-19",
// if there is a previously published draft, uncomment this and set its YYYY-MM-DD date
// and its maturity status
// previousPublishDate: "1977-03-15",
// previousMaturity: "WD",
// if there a publicly available Editor's Draft, this is the link
edDraftURI: "https://w3c.github.io/vc-di-eddsa/",
//latestVersion: "https://www.w3.org/community/reports/credentials/CG-FINAL-di-eddsa-2020-20220724/",
// if this is a LCWD, uncomment and set the end of its review period
implementationReportURI: "https://w3c.github.io/vc-di-eddsa-test-suite/",
// if you want to have extra CSS, append them to this list
// it is recommended that the respec.css stylesheet be kept
//extraCSS: ["spec.css", "prettify.css"],
// editors, add as many as you like
// only "name" is required
editors: [{
name: "Manu Sporny",
url: "https://www.linkedin.com/in/manusporny/",
company: "Digital Bazaar",
companyURL: "https://digitalbazaar.com/",
w3cid: 41758
}, {
name: "Dmitri Zagidulin",
url: "https://www.linkedin.com/in/dzagidulin/",
company: "MIT Digital Credentials Consortium",
companyURL: "https://digitalcredentials.mit.edu/",
w3cid: 86708
}, {
name: "Greg Bernstein", url: "https://www.grotto-networking.com/",
company: "Invited Expert", w3cid: 140479
}, {
name: "Sebastian Crane", url: "https://github.com/seabass-labrax",
company: "Invited Expert", w3cid: 140132
}],
authors: [{
name: "Dave Longley", url: "https://digitalbazaar.com/",
company: "Digital Bazaar", companyURL: "https://digitalbazaar.com/",
w3cid: 48025
}, {
name: "Manu Sporny", url: "https://www.linkedin.com/in/manusporny/",
company: "Digital Bazaar", companyURL: "https://digitalbazaar.com/",
w3cid: 41758
}],
github: "https://github.com/w3c/vc-di-eddsa/",
// URI of the patent status for this WG, for Rec-track documents
// !!!! IMPORTANT !!!!
// This is important for Rec-track documents, do not copy a patent URI from a random
// document unless you know what you're doing. If in doubt ask your friendly neighbourhood
// Team Contact.
// wgPatentURI: "",
maxTocLevel: 4,
/*preProcess: [ webpayments.preProcess ],
alternateFormats: [ {uri: "diff-20111214.html", label: "diff to previous version"} ],
*/
localBiblio: {
MULTIBASE: {
title: "Multibase",
href: "https://datatracker.ietf.org/doc/html/draft-multiformats-multibase-01",
},
MULTICODEC: {
title: "Multicodec",
href: "https://github.com/multiformats/multicodec/",
},
Taming_EdDSAs: {
title: "Taming the many EdDSAs",
href: "https://eprint.iacr.org/2020/1244",
authors: ["Konstantinos Chalkias", "François Garillot", "Valeria Nikolaenko"],
date: "2020",
publisher: "Cryptology ePrint Archive, Paper 2020/1244",
doi: "10.1007/978-3-030-64357-7_4"
},
Provable_Ed25519: {
authors: ["Jacqueline Brendel", "Cas Cremers", "Dennis Jackson", "Mang Zhao"],
title: "The Provable Security of Ed25519: Theory and Practice",
publisher: "Cryptology ePrint Archive, Paper 2020/823",
date: "2020",
href: "https://eprint.iacr.org/2020/823"
}
},
xref: ["INFRA", "VC-DATA-MODEL-2.0", "VC-DATA-INTEGRITY"],
lint: {"informative-dfn": false},
otherLinks: [{
key: "Related Specifications",
data: [{
value: "Verifiable Credentials Data Model v2.0",
href: "https://www.w3.org/TR/vc-data-model-2.0/"
}, {
value: "Verifiable Credential Data Integrity v1.0",
href: "https://www.w3.org/TR/vc-data-integrity/"
}, {
value: "Controller Documents v1.0",
href: "https://www.w3.org/TR/controller-document/"
},{
value: "Data Integrity ECDSA Cryptosuites v1.0",
href: "https://www.w3.org/TR/vc-di-ecdsa/"
}, {
value: "Data Integrity BBS Cryptosuites v1.0",
href: "https://www.w3.org/TR/vc-di-bbs/"
}]
}]
};
</script>
<style>
code {
color: rgb(199, 73, 0);
font-weight: bold;
}
pre.nohighlight {
overflow-x: auto;
white-space: pre-wrap;
}
pre .highlight {
font-weight: bold;
color: green;
}
pre .comment {
font-weight: bold;
color: Gray;
}
.color-text {
font-weight: bold;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}
ol.algorithm {
counter-reset: numsection;
list-style-type: none;
}
ol.algorithm li {
margin: 0.5em 0;
}
ol.algorithm li:before {
font-weight: bold;
counter-increment: numsection;
content: counters(numsection, ".") ") ";
}
</style>
</head>
<body>
<section id="abstract">
<p>
This specification describes Data Integrity cryptographic suites for use when
creating or verifying a digital signature using the the Ed25519 instantiation
of the Edwards-Curve Digital Signature Algorithm (EdDSA).
</p>
</section>
<section id="sotd">
<p>
The Working Group is actively seeking implementation feedback for this
specification. In order to exit the Candidate Recommendation phase, the
Working Group has set the requirement of at least two independent
implementations for each mandatory feature in the specification. For details
on the conformance testing process, see the test suites listed in the
<a href="https://w3c.github.io/vc-di-eddsa-test-suite/">
implementation report</a>.
</p>
<p class="atrisk issue"
title="Features with less than two independent implementations">
Any feature with less than two independent implementations in the
<a href="https://w3c.github.io/vc-di-eddsa-test-suite/">
EdDSA Cryptosuite Implementation Report</a> is an "at risk" feature and might be
removed before the transition to W3C Proposed Recommendation.
</p>
</section>
<section>
<h2>Introduction</h2>
<p>
This specification defines a cryptographic suite for the purpose of creating,
verifying proofs for Ed25519 EdDSA signatures in conformance with the
Data Integrity [[VC-DATA-INTEGRITY]] specification. The approach is
accepted by the U.S. National Institute of Standards in the latest [[FIPS-186-5]]
publication and meets U.S. Federal Information Processing requirements when
using cryptography to secure digital information.
</p>
<p>
The suites described in this specification use the RDF Dataset Canonicalization
Algorithm [[RDF-CANON]] or the JSON Canonicalization Scheme [[RFC8785]] to
transform an input document into its canonical form. The canonical
representation is then hashed and signed with a detached signature algorithm.
</p>
<section id="terminology">
<h3>Terminology</h3>
<p>
Terminology used throughout this document is defined in the
<a data-cite="VC-DATA-INTEGRITY#terminology">Terminology</a> section of the
[[[VC-DATA-INTEGRITY]]] specification.
</p>
</section>
<section id="conformance">
<p>
A <dfn>conforming proof</dfn> is any concrete expression of the data model
that complies with the normative statements in this specification. Specifically,
all relevant normative statements in Sections
[[[#data-model]]] and [[[#algorithms]]]
of this document MUST be enforced.
</p>
<p>
A <dfn class="lint-ignore">conforming processor</dfn> is any algorithm realized
as software and/or hardware that generates or consumes a
<a>conforming proof</a>. Conforming processors MUST produce errors when
non-conforming documents are consumed.
</p>
<p>
This document contains examples of JSON and JSON-LD data. Some of these examples
are invalid JSON, as they include features such as inline comments (`//`)
explaining certain portions and ellipses (`...`) indicating the omission of
information that is irrelevant to the example. These parts would have to be
removed in order to treat the examples as valid JSON or JSON-LD.
</p>
</section>
</section>
<section>
<h2>Data Model</h2>
<p>
The following sections outline the data model that is used by this specification
to express verification methods, such as cryptographic public keys, and
data integrity proofs, such as digital signatures.
</p>
<section>
<h3>Verification Methods</h3>
<p>
This cryptographic suite is used to verify Data Integrity Proofs
[[VC-DATA-INTEGRITY]] produced using Edwards Curve cryptographic key material.
The encoding formats for those key types are provided in this section. Lossless
cryptographic key transformation processes that result in equivalent
cryptographic key material MAY be used for the processing of digital
signatures.
</p>
<section>
<h4>Multikey</h4>
<p>
The <a data-cite="controller-document#Multikey">Multikey format</a>, defined in
[[[controller-document]]], is used to express public keys for the cryptographic
suites defined in this specification.
</p>
<p>
The `publicKeyMultibase` value of the verification method MUST start with the
base-58-btc prefix (`z`), as defined in the
<a data-cite="controller-document#multibase-0">Multibase section</a> of
[[[controller-document]]]. A Multibase-encoded Ed25519 256-bit public key value
follows, as defined in the
<a data-cite="controller-document#Multikey">Multikey section</a> of
[[[controller-document]]]. Any other encoding MUST NOT be allowed.
</p>
<p class="advisement">
Developers are advised to not accidentally publish a representation of a private
key. Implementations of this specification will raise errors if they encounter a
Multikey prefix value other than `0xed01` in a `publicKeyMultibase` value.
</p>
<pre class="example nohighlight"
title="An Ed25519 public key encoded as a Multikey">
{
"id": "https://example.com/issuer/123#key-0",
"type": "Multikey",
"controller": "https://example.com/issuer/123",
"publicKeyMultibase": "z6Mkf5rGMoatrSj1f4CyvuHBeXJELe9RPdzo2PKGNCKVtZxP"
}
</pre>
<pre class="example nohighlight" title="An Ed25519 public key encoded as a
Multikey in a controller document">
{
"@context": [
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/multikey/v1"
],
"id": "did:example:123",
"verificationMethod": [{
"id": "did:example:123#key-0",
"type": "Multikey",
"controller": "did:example:123",
"publicKeyMultibase": "z6Mkf5rGMoatrSj1f4CyvuHBeXJELe9RPdzo2PKGNCKVtZxP"
}],
"authentication": [
"did:example:123#key-0"
],
"assertionMethod": [
"did:example:123#key-0"
],
"capabilityDelegation": [
"did:example:123#key-0"
],
"capabilityInvocation": [
"did:example:123#key-0"
]
}
</pre>
<p>
The `secretKeyMultibase` value of the verification method MUST start with the
base-58-btc prefix (`z`), as defined in the
<a data-cite="controller-document#multibase-0">Multibase section</a> of
[[[controller-document]]]. A Multibase-encoded Ed25519 256-bit secret key value
follows, as defined in the
<a data-cite="controller-document#Multikey">Multikey section</a> of
[[[controller-document]]]. Any other encoding MUST NOT be allowed.
</p>
<p class="advisement">
Developers are advised to prevent accidental publication of a representation of
a secret key, and to not export the `secretKeyMultibase` property by default,
when serializing key pairs to Multikey.
</p>
</section>
</section>
<section>
<h3>Proof Representations</h3>
<p>
This section details the proof representation formats that are defined by
this specification.
</p>
<section>
<h4>DataIntegrityProof</h4>
<p>
A proof contains the attributes specified in the
<a href="https://www.w3.org/TR/vc-data-integrity/#proofs">Proofs section</a>
of [[VC-DATA-INTEGRITY]] with the following restrictions.
</p>
<p>
The `type` property MUST be `DataIntegrityProof`.
</p>
<p>
The `cryptosuite` property of the proof MUST be `eddsa-rdfc-2022` or `eddsa-jcs-2022`.
</p>
<p>
The `proofValue` property of the proof MUST be a detached EdDSA signature
produced according to [[RFC8032]], encoded using the base-58-btc header and
alphabet as described in the
<a data-cite="controller-document#multibase-0">Multibase section</a> of
[[[controller-document]]].
</p>
<pre class="example nohighlight"
title="An Ed25519 digital signature expressed as a
DataIntegrityProof">
{
"@context": [
{"myWebsite": "https://vocabulary.example/myWebsite"},
"https://www.w3.org/ns/credentials/v2"
],
"myWebsite": "https://hello.world.example/",
"proof": {
"type": "DataIntegrityProof",
"cryptosuite": "eddsa-rdfc-2022",
"created": "2023-02-24T23:36:38Z",
"verificationMethod": "https://vc.example/issuers/5678#z6MkrJVnaZkeFzdQyMZu1
cgjg7k1pZZ6pvBQ7XJPt4swbTQ2",
"proofPurpose": "assertionMethod",
"proofValue": "z5C5b1uzYJN6pDR3aWgAqUMoSB1JY29epA74qyjaie9qh4okm9DZP6y77eTNq
5NfYyMwNu9bpQQWUHKH5zAmEtszK"
}
}
</pre>
</section>
</section>
</section>
<section>
<h2>Algorithms</h2>
<p>
The following section describes multiple Data Integrity cryptographic suites
that use the Edwards-Curve Digital Signature Algorithm.
</p>
<section>
<h3>Instantiate Cryptosuite</h3>
<p>
This algorithm is used to configure a cryptographic suite to be used by the
<a data-cite="VC-DATA-INTEGRITY#add-proof">Add Proof</a> and
<a data-cite="VC-DATA-INTEGRITY#verify-proof">Verify Proof</a>
functions in [[[VC-DATA-INTEGRITY]]]. The algorithm takes an options object
([=map=] |options|) as input and returns a [=data integrity cryptographic suite
instance|cryptosuite instance=] ([=struct=] |cryptosuite|).
</p>
<ol class="algorithm">
<li>
Initialize |cryptosuite| to an empty [=struct=].
</li>
<li>
If |options|.|type| does not equal `DataIntegrityProof`, return |cryptosuite|.
</li>
<li>
If |options|.|cryptosuite| is `eddsa-rdfc-2022`:
<ol class="algorithm">
<li>
Set |cryptosuite|.|createProof| to the algorithm in Section
[[[#create-proof-eddsa-rdfc-2022]]].
</li>
<li>
Set |cryptosuite|.|verifyProof| to the algorithm in Section
[[[#verify-proof-eddsa-rdfc-2022]]].
</li>
</ol>
</li>
<li>
If |options|.|cryptosuite| is `eddsa-jcs-2022`:
<ol class="algorithm">
<li>
Set |cryptosuite|.|createProof| to the algorithm in Section
[[[#create-proof-eddsa-jcs-2022]]].
</li>
<li>
Set |cryptosuite|.|verifyProof| to the algorithm in Section
[[[#verify-proof-eddsa-jcs-2022]]].
</li>
</ol>
</li>
<li>
Return |cryptosuite|.
</li>
</ol>
</section>
<section>
<h3>eddsa-rdfc-2022</h3>
<p>
The `eddsa-rdfc-2022` cryptographic suite takes an input document, canonicalizes
the document using the RDF Dataset Canonicalization algorithm [[RDF-CANON]], and then
cryptographically hashes and signs the output
resulting in the production of a data integrity proof. The algorithms in this
section also include the verification of such a data integrity proof.
</p>
<p class="advisement">
When the RDF Dataset Canonicalization Algorithm [[RDF-CANON]] is used,
implementations will detect <a data-cite="RDF-CANON#dataset-poisoning">
dataset poisoning</a> by default, and abort processing upon such detection.
</p>
<section>
<h4>Create Proof (eddsa-rdfc-2022)</h4>
<p>
The following algorithm specifies how to create a [=data integrity proof=] given
an <a>unsecured data document</a>. Required inputs are an
<a>unsecured data document</a> ([=map=] |unsecuredDocument|), and a set of proof
options ([=map=] |options|). A [=data integrity proof=] ([=map=]), or an error,
is produced as output.
</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.
</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.
</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>
Let |proof|.|proofValue| be a <a data-cite="controller-document#multibase-0">
base58-btc-encoded Multibase value</a> of the |proofBytes|.
</li>
<li>
Return |proof| as the [=data integrity proof=].
</li>
</ol>
</section>
<section>
<h4>Verify Proof (eddsa-rdfc-2022)</h4>
<p>
The following algorithm specifies how to verify a [=data integrity proof=] given
an <a>secured data document</a>. Required inputs are an
<a>secured data document</a> ([=map=] |securedDocument|). This algorithm returns
a <dfn>verification result</dfn>, which is a [=struct=] whose
[=struct/items=] are:
</p>
<dl>
<dt><dfn data-dfn-for="verification result">verified</dfn></dt>
<dd>`true` or `false`</dd>
<dt><dfn data-dfn-for="verification result">verifiedDocument</dfn></dt>
<dd>
if [=verification result/verified=] is `false`, <a data-cite="INFRA#nulls">Null</a>;
otherwise, an [=unsecured data document=]
</dd>
</dl>
<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="controller-document#multibase-0">Multibase decoded base58-btc
value</a> in |securedDocument|.|proof|.|proofValue|.
</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.
</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|
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>
if |verified| is `true`, |unsecuredDocument|;
otherwise, <a data-cite="INFRA#nulls">Null</a></dd>
</dl>
</li>
</ol>
</section>
<section>
<h4>Transformation (eddsa-rdfc-2022)</h4>
<p>
The following algorithm specifies how to transform an unsecured input document
into a transformed document that is ready to be provided as input to the
hashing algorithm in Section [[[#hashing-eddsa-rdfc-2022]]].
</p>
<p>
Required inputs to this algorithm are an
<a data-cite="vc-data-integrity#dfn-unsecured-data-document">
unsecured data document</a> (`unsecuredDocument`) and
transformation options (`options`). The
transformation options MUST contain a type identifier for the
<a data-cite="vc-data-integrity#dfn-cryptosuite">
cryptographic suite</a> (`type`) and a cryptosuite
identifier (`cryptosuite`). A <em>transformed data document</em> is
produced as output. Whenever this algorithm encodes strings, it MUST use UTF-8
encoding.
</p>
<ol class="algorithm">
<li>
If `options`.`type` is not set to the string
`DataIntegrityProof` and `options`.`cryptosuite` is not
set to the string `eddsa-rdfc-2022`,
an error MUST be raised that SHOULD convey an error type of
<a data-cite="VC-DATA-INTEGRITY#PROOF_TRANSFORMATION_ERROR">PROOF_TRANSFORMATION_ERROR</a>.
</li>
<li>
Let |canonicalDocument| be the result of converting |unsecuredDocument|
<a data-cite="JSON-LD11-API#deserialize-json-ld-to-rdf-algorithm">
to RDF statements</a>, applying the <a data-cite="RDF-CANON#canon-algorithm">RDF Dataset Canonicalization
Algorithm</a> [[RDF-CANON]] to the result, and then serializing the result to a
<a data-cite="RDF-CANON#dfn-serialized-canonical-form">serialized canonical form</a> [[RDF-CANON]].
</li>
<li>
Return `canonicalDocument` as the <em>transformed data document</em>.
</li>
</ol>
</section>
<section>
<h4>Hashing (eddsa-rdfc-2022)</h4>
<p>
The following algorithm specifies how to cryptographically hash a
<em>transformed data document</em> and <em>proof configuration</em>
into cryptographic hash data that is ready to be provided as input to the
algorithms in Section [[[#proof-serialization-eddsa-rdfc-2022]]] or
Section [[[#proof-verification-eddsa-rdfc-2022]]].
</p>
<p>
The required inputs to this algorithm are a <em>transformed data document</em>
(`transformedDocument`) and <em>canonical proof configuration</em>
(`canonicalProofConfig`). A single <em>hash data</em> value represented as
series of bytes is produced as output.
</p>
<ol class="algorithm">
<li>
Let `proofConfigHash` be the result of applying the
SHA-256 (SHA-2 with 256-bit output) cryptographic hashing algorithm [[RFC6234]]
to the `canonicalProofConfig`. `proofConfigHash` will be
exactly 32 bytes in size.
</li>
<li>
Let `transformedDocumentHash` be the result of applying the
SHA-256 (SHA-2 with 256-bit output) cryptographic hashing algorithm [[RFC6234]]
to the `transformedDocument`. `transformedDocumentHash` will
be exactly 32 bytes in size.
</li>
<li>
Let `hashData` be the result of concatenating `proofConfigHash`
(the first hash produced above) followed by `transformedDocumentHash`
(the second hash produced above).
</li>
<li>
Return `hashData` as the <em>hash data</em>.
</li>
</ol>
</section>
<section>
<h4>Proof Configuration (eddsa-rdfc-2022)</h4>
<p>
The following algorithm specifies how to generate a
<em>proof configuration</em> from a set of <em>proof options</em>
that is used as input to the <a href="#hashing-eddsa-rdfc-2022">proof hashing algorithm</a>.
</p>
<p>
The required inputs to this algorithm are the <em>document</em>
(|unsecuredDocument|) and the <em>proof options</em>
(`options`). The <em>proof options</em> MUST contain a type identifier
for the
<a data-cite="vc-data-integrity#dfn-cryptosuite">
cryptographic suite</a> (`type`) and MUST contain a cryptosuite
identifier (`cryptosuite`). A <em>proof configuration</em>
object is produced as output.
</p>
<ol class="algorithm">
<li>
Let |proofConfig| be a clone of the |options| object.
</li>
<li>
If |proofConfig|.|type| is not set to `DataIntegrityProof` and/or
|proofConfig|.|cryptosuite| is not set to `eddsa-rdfc-2022`, an
error MUST be raised and SHOULD convey an error type of
<a data-cite="VC-DATA-INTEGRITY#PROOF_GENERATION_ERROR">PROOF_GENERATION_ERROR</a>.
</li>
<li>
If |proofConfig|.|created| is present and set to a value that is not a
valid [[XMLSCHEMA11-2]] datetime, an error MUST be
raised and SHOULD convey an error type of
<a data-cite="VC-DATA-INTEGRITY#PROOF_GENERATION_ERROR">PROOF_GENERATION_ERROR</a>.
</li>
<li>
Set |proofConfig|.`@context `to
|unsecuredDocument|.<var>@context</var>.
</li>
<li>
Let |canonicalProofConfig| be the result of applying the
RDF Dataset Canonicalization Algorithm
[[RDF-CANON]] to the |proofConfig|.
</li>
<li>
Return |canonicalProofConfig|.
</li>
</ol>
</section>
<section>
<h4>Proof Serialization (eddsa-rdfc-2022)</h4>
<p>
The following algorithm specifies how to serialize a digital signature from
a set of cryptographic hash data. This
algorithm is designed to be used in conjunction with the algorithms defined
in the Data Integrity [[VC-DATA-INTEGRITY]] specification,
<a data-cite="vc-data-integrity#algorithms">
Section 4: Algorithms</a>. Required inputs are
cryptographic hash data (`hashData`) and
<em>proof options</em> (`options`). The
<em>proof options</em> MUST contain a type identifier for the
<a data-cite="vc-data-integrity#dfn-cryptosuite">
cryptographic suite</a> (`type`) and MAY contain a cryptosuite
identifier (`cryptosuite`). A single <em>digital proof</em> value
represented as series of bytes is produced as output.
</p>
<ol class="algorithm">
<li>
Let `privateKeyBytes` be the result of retrieving the
private key bytes associated with the
`options`.`verificationMethod` value as described in the
Data Integrity [[VC-DATA-INTEGRITY]] specification,
<a data-cite="vc-data-integrity#processing-model">
Section 4.1: Processing Model</a>.
</li>
<li>
Let `proofBytes` be the result of applying the Edwards-Curve Digital
Signature Algorithm (EdDSA) [[RFC8032]], using the `Ed25519` variant
(Pure EdDSA), with `hashData` as the data to be signed using
the private key specified by `privateKeyBytes`.
`proofBytes` will be exactly 64 bytes in size.
</li>
<li>
Return `proofBytes` as the <em>digital proof</em>.
</li>
</ol>
</section>
<section>
<h4>Proof Verification (eddsa-rdfc-2022)</h4>
<p>
The following algorithm specifies how to verify a digital signature from
a set of cryptographic hash data. This
algorithm is designed to be used in conjunction with the algorithms defined
in the Data Integrity [[VC-DATA-INTEGRITY]] specification,
<a data-cite="vc-data-integrity#algorithms">
Section 4: Algorithms</a>. Required inputs are
cryptographic hash data (`hashData`),
a digital signature (`proofBytes`) and
proof options (`options`). A <em>verification result</em>
represented as a boolean value is produced as output.
</p>
<ol class="algorithm">
<li>
Let `publicKeyBytes` be the result of retrieving the
public key bytes associated with the
`options`.`verificationMethod` value as described in the
[[[controller-document]]] specification,
<a data-cite="controller-document#retrieve-verification-method">
Section 3.3: Retrieve Verification Method</a>.
</li>
<li>
Let `verificationResult` be the result of applying the verification
algorithm for the Edwards-Curve Digital Signature Algorithm (EdDSA)
[[RFC8032]], using the `Ed25519` variant (Pure EdDSA),
with `hashData` as the data to be verified against the
`proofBytes` using the public key specified by
`publicKeyBytes`.
</li>
<li>
Return `verificationResult` as the <em>verification result</em>.
</li>
</ol>
</section>
</section>
<section>
<h3>eddsa-jcs-2022</h3>
<p>
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.
</p>
<section>
<h4>Create Proof (eddsa-jcs-2022)</h4>
<p>
The following algorithm specifies how to create a [=data integrity proof=] given
an <a>unsecured data document</a>. Required inputs are an
<a>unsecured data document</a> ([=map=] |unsecuredDocument|), and a set of proof
options ([=map=] |options|). A [=data integrity proof=] ([=map=]), or an error,
is produced as output.
</p>
<ol class="algorithm">
<li>
Let |proof| be a clone of the proof options, |options|.
</li>
<li>
If `unsecuredDocument`.<var>@context</var> is present,
set `proof`.<var>@context</var> to
`unsecuredDocument`.<var>@context</var>.
</li>
<li>
Let |proofConfig| be the result of running the algorithm in
Section [[[#proof-configuration-eddsa-jcs-2022]]] with
|proof| passed as the <em>proof options</em> parameter.
</li>
<li>
Let |transformedData| be the result of running the algorithm in Section
[[[#transformation-eddsa-jcs-2022]]] with |unsecuredDocument|
and |options| passed as parameters.
</li>
<li>
Let |hashData| be the result of running the algorithm in Section
[[[#hashing-eddsa-jcs-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-jcs-2022]]] with |hashData| and
|options| passed as parameters.
</li>
<li>
Let |proof|.|proofValue| be a <a data-cite="controller-document#multibase-0">
base58-btc-encoded Multibase value</a> of the |proofBytes|.
</li>
<li>
Return |proof| as the [=data integrity proof=].
</li>
</ol>
</section>
<section>
<h4>Verify Proof (eddsa-jcs-2022)</h4>
<p>
The following algorithm specifies how to verify a [=data integrity proof=] given
an <a>secured data document</a>. Required inputs are an
<a>secured data document</a> ([=map=] |securedDocument|). This algorithm returns
a [=verification result=], which is a [=struct=] whose [=struct/items=] are:
</p>
<dl>
<dt>[=verification result/verified=]</dt>
<dd>`true` or `false`</dd>
<dt>[=verification result/verifiedDocument=]</dt>
<dd>
if [=verification result/verified=] is `true`, an [=unsecured data document=];
otherwise <a data-cite="INFRA#nulls">Null</a>
</dd>
</dl>
<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="controller-document#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
[[[#transformation-eddsa-jcs-2022]]] with |unsecuredDocument| and
|proofOptions| passed as parameters.
</li>
<li>
Let |proofConfig| be the result of running the algorithm in Section
[[[#proof-configuration-eddsa-jcs-2022]]] with |proofOptions| passed
as the parameter.
</li>
<li>
Let |hashData| be the result of running the algorithm in Section
[[[#hashing-eddsa-jcs-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-jcs-2022]]] 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>
if |verified| is `true`, |unsecuredDocument|;
otherwise, <a data-cite="INFRA#nulls">Null</a></dd>
</dl>
</li>
</ol>
</section>
<section>
<h4>Transformation (eddsa-jcs-2022)</h4>
<p>
The following algorithm specifies how to transform an unsecured input document
into a transformed document that is ready to be provided as input to the
hashing algorithm in Section [[[#hashing-eddsa-jcs-2022]]].
</p>
<p>
Required inputs to this algorithm are an
<a data-cite="vc-data-integrity#dfn-unsecured-data-document">
unsecured data document</a> (`unsecuredDocument`) and
transformation options (`options`). The
transformation options MUST contain a type identifier for the
<a data-cite="vc-data-integrity#dfn-cryptosuite">
cryptographic suite</a> (`type`) and a cryptosuite
identifier (`cryptosuite`). A <em>transformed data document</em> is
produced as output. Whenever this algorithm encodes strings, it MUST use UTF-8
encoding.
</p>
<ol class="algorithm">
<li>
If `options`.`type` is not set to the string
`DataIntegrityProof` and `options`.`cryptosuite` is not
set to the string `eddsa-jcs-2022`,
an error MUST be raised that SHOULD convey an error type of
<a data-cite="VC-DATA-INTEGRITY#PROOF_VERIFICATION_ERROR">PROOF_VERIFICATION_ERROR</a>.