-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
1462 lines (1293 loc) · 59.1 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 ECDSA 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="//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 ECDSA with NIST-compliant curves",
// specification status (e.g. WD, LCWD, NOTE, etc.). If in doubt use ED.
group: "vc",
specStatus: "WD",
// the specification's short name, as in http://www.w3.org/TR/short-name/
shortName: "vc-di-ecdsa",
// if you wish the publication date to be other than today, set this
//publishDate: "2023-04-18",
// 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-ecdsa/",
//latestVersion: "https://www.w3.org/community/reports/credentials/CG-FINAL-di-ecdsa-2019-20220724/",
// if this is a LCWD, uncomment and set the end of its review period
// lcEnd: "2009-08-05",
// 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: "Marty Reed",
url: "https://www.linkedin.com/in/marty-reed-b5b2352/",
company: "RANDA Solutions",
companyURL: "https://www.randasolutions.com/",
w3cid: 127611
}],
// authors, add as many as you like.
// This is optional, uncomment if you have authors as well as editors.
// only "name" is required. Same format as editors.
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
}],
// extend the bibliography entries
//localBiblio: webpayments.localBiblio,
// name of the WG
//wg: "W3C Credentials Community Group",
// URI of the public WG page
//wgURI: "https://www.w3.org/community/credentials/",
// name (with the @w3c.org) of the public mailing to which comments are due
//wgPublicList: "public-credentials",
github: "https://github.com/w3c/vc-di-ecdsa/",
otherLinks: [],
// 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/",
},
SECG2: {
title: "SEC 2: Recommended Elliptic Curve Domain Parameters",
href: "http://www.secg.org/sec2-v2.pdf",
date: "January 27, 2010",
publisher: "Certicom Research"
},
"NIST-SP-800-186": {
title: "Recommendations for Discrete Logarithm-based Cryptography: Elliptic Curve Domain Parameters",
authors: ["Lily Chen", "Dustin Moody", "Karen Randall", "Andrew Regenscheid", "Angela Robinson"],
date: "February 2023",
publisher: "National Institute of Standards and Technology"
},
"NIST-SP-800-186": {
title: "Recommendations for Discrete Logarithm-based Cryptography: Elliptic Curve Domain Parameters",
authors: ["Lily Chen", "Dustin Moody", "Karen Randall", "Andrew Regenscheid", "Angela Robinson"],
date: "February 2023",
publisher: "National Institute of Standards and Technology"
},
"NIST-SP-800-57-Part-1": {
title: "Recommendation for Key Management: Part 1 – General",
authors: ["Elaine Barker"],
date: "May 2020",
publisher: "National Institute of Standards and Technology",
href: "https://doi.org/10.6028/NIST.SP.800-57pt1r5"
}
},
lint: {"no-unused-dfns": false},
postProcess: [restrictRefs]
};
</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 a Data Integrity Cryptosuite for use when
generating a digital signature using the Elliptic Curve Digital Signature
Algorithm (ECDSA).
</p>
</section>
<section id="sotd">
<p>
This is an experimental specification and is undergoing regular revisions. It
is not fit for production deployment.
</p>
</section>
<section>
<h2>Introduction</h2>
<p>
This specification defines a cryptographic suite for the purpose of creating,
and verifying proofs for ECDSA signatures in conformance with the
Data Integrity [[VC-DATA-INTEGRITY]] specification. ECDSA signatures are
specified in [[FIPS-186-5]] with elliptic curves P-256 and P-384 specified in
[[NIST-SP-800-186]]. [[FIPS-186-5]] includes the <em>deterministic</em> ECDSA
algorithm which is also specified in [[RFC6979]].
</p>
<p>
This specification uses either the RDF Dataset Canonicalization Algorithm
[[RDF-CANON]] or the JSON Canonicalization Scheme [[RFC8785]] to transform the
input document into its canonical form. It uses one of two mechanisms to digest
and sign: SHA-256 [[RFC6234]] as the message digest algorithm and ECDSA with
Curve P-256 as the signature algorithm, or SHA-384 [[RFC6234]] as the message
digest algorithm and ECDSA with Curve P-384 as the signature algorithm.
</p>
<p class="note">
The elliptic curves P-256 and P-384 of [[NIST-SP-800-186]] are referred to as
<em>secp256r1</em> and <em>secp384r1</em> respectively in [[SECG2]]. In
addition, this notation is sometimes used in ECDSA software libraries.
</p>
<section id="terminology">
<h3>Terminology</h3>
<div data-include="https://w3c.github.io/vc-data-integrity/terms.html"></div>
</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
<a href="#data-model"></a> and <a href="#algorithms"></a>
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 also contains examples that contain JSON and JSON-LD content. Some
of these examples contain characters that are invalid JSON, such as inline
comments (`//`) and the use of ellipsis (`...`) to denote
information that adds little value to the example. Implementers are cautioned to
remove this content if they desire to use the information 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
for <a>verification methods</a> and <a>data integrity proof</a> formats.
</p>
<section>
<h3>Verification Methods</h3>
<p>
The cryptographic material used to verify a <a>data integrity proof</a> is
called the <a>verification method</a>. This suite relies on public key material
represented using [[MULTIBASE]] and [[MULTICODEC]]. This suite supports public
key use for both digital signature generation and verification, according to
[[FIPS-186-5]].
</p>
<p>
This suite MAY be used to verify Data Integrity Proofs [[VC-DATA-INTEGRITY]]
produced by ECDSA public key material encoded as a
<a href="#multikey">Multikey</a>. Loss-less key transformation processes that
result in equivalent cryptographic material MAY be utilized.
</p>
<section>
<h4>Multikey</h4>
<p class="issue">
This definition should go in the Data Integrity specification and referenced
from there.
</p>
<p>
The `type` of the verification method MUST be `Multikey`.
</p>
<p>
The `controller` of the verification method MUST be a URL.
</p>
<p>
The `publicKeyMultibase` property of the verification method MUST be
a public key encoded according to [[MULTICODEC]] and formatted according to
[[MULTIBASE]]. The multicodec encoding of a P-256 public key is the
two-byte prefix `0x1200` followed by the 33-byte compressed public key data.
The 35 byte value is then encoded using base58-btc (`z`) as the prefix.
The multicodec encoding of a P-384 public key is the
two-byte prefix `0x1201` followed by the 49-byte compressed public key data.
The 51 byte value is then encoded using base58-btc (`z`) as the prefix.
Any other encodings 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 in the event of a
[[MULTICODEC]] value other than `0x1200` or `0x1201` being used in a
`publicKeyMultibase` value.
</p>
<pre class="example nohighlight"
title="An P-256 public key encoded as a Multikey">
{
"id": "https://example.com/issuer/123#key-0",
"type": "Multikey",
"controller": "https://example.com/issuer/123",
"publicKeyMultibase": "zDnaerx9CtbPJ1q36T5Ln5wYt3MQYeGRG5ehnPAmxcf5mDZpv"
}
</pre>
<pre class="example nohighlight"
title="An P-384 public key encoded as a Multikey">
{
"id": "https://example.com/issuer/123#key-0",
"type": "Multikey",
"controller": "https://example.com/issuer/123",
"publicKeyMultibase": "z82LkvCwHNreneWpsgPEbV3gu1C6NFJEBg4srfJ5gdxEsMGRJ
Uz2sG9FE42shbn2xkZJh54"
}
</pre>
<pre class="example nohighlight" title="Two public keys (P-256 and P-384)
encoded as Multikeys in a controller document">
{
"@context": [
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/data-integrity/v1"
],
"id": "did:example:123",
"verificationMethod": [{
"id": "https://example.com/issuer/123#key-1",
"type": "Multikey",
"controller": "https://example.com/issuer/123",
"publicKeyMultibase": "zDnaerx9CtbPJ1q36T5Ln5wYt3MQYeGRG5ehnPAmxcf5mDZpv"
}, {
"id": "https://example.com/issuer/123#key-2",
"type": "Multikey",
"controller": "https://example.com/issuer/123",
"publicKeyMultibase": "z82LkvCwHNreneWpsgPEbV3gu1C6NFJEBg4srfJ5gdxEsMGRJ
Uz2sG9FE42shbn2xkZJh54"
}],
"authentication": [
"did:example:123#key-1"
],
"assertionMethod": [
"did:example:123#key-2"
],
"capabilityDelegation": [
"did:example:123#key-2"
],
"capabilityInvocation": [
"did:example:123#key-2"
]
}
</pre>
</section>
<p class="issue" title="Refer normatively to a Multikey specification">
This specification should not specify multikey formats. It should, instead,
point to a multikey registry and/or specification. Examples of these
sorts of documents include the DID Specification Registries for <a
href="https://www.w3.org/TR/did-spec-registries/#verification-method-types">
Verification Method Types</a>, the key types in the <a
href="https://ns.did.ai/suites/multikey-2021/v1/">
Multikey2021 JSON-LD Context</a>, and key definitions in the <a
href="https://w3c-ccg.github.io/security-vocab/">Security Vocabulary</a>.
Ideally, the specification that this one points to would define all possible
multikeys listed in the <a href="https://github.com/multiformats/multicodec/blob/master/table.csv">Multicodec Registry</a>
and define how to encode them as multibase values in fields such as
`publicKeyMultibase` and `secretKeyMultibase`. The referenced specification
should also include an extensibility mechanism and registry for new values as
they are added to the Multicodec Registry.
</p>
</section>
<section>
<h3>Proof Representations</h3>
<p>
This suite relies on detached digital signatures represented using [[MULTIBASE]]
and [[MULTICODEC]].
</p>
<section>
<h4>DataIntegrityProof</h4>
<p>
The `verificationMethod` property of the proof MUST be a URL.
Dereferencing the `verificationMethod` MUST result in an object
containing a `type` property with the value set to
`Multikey`.
</p>
<p>
The `type` property of the proof MUST be `DataIntegrityProof`.
</p>
<p>
The `cryptosuite` property of the proof MUST be `ecdsa-2019`.
</p>
<p>
The `created` property of the proof MUST be an [[XMLSCHEMA11-2]]
formatted date string.
</p>
<p>
The `proofPurpose` property of the proof MUST be a string, and MUST
match the verification relationship expressed by the verification method
`controller`.
</p>
<p>
The `proofValue` property of the proof MUST be a detached ECDSA
produced according to [[FIPS-186-5]], encoded according to [[MULTIBASE]] using
the base58-btc base encoding.
</p>
<pre class="example nohighlight"
title="An ECDSA P-256 digital signature expressed as a
DataIntegrityProof">
{
"@context": [
{"title": "https://schema.org/title"},
"https://w3id.org/security/data-integrity/v1"
],
"title": "Hello world!",
"proof": {
"type": "DataIntegrityProof",
"cryptosuite": "ecdsa-2019",
"created": "2020-11-05T19:23:24Z",
"verificationMethod": "https://example.com/issuer/123#key-2",
"proofPurpose": "assertionMethod",
"proofValue": "z4oey5q2M3XKaxup3tmzN4DRFTLVqpLMweBrSxMY2xHX5XTYVQeVbY8nQA
VHMrXFkXJpmEcqdoDwLWxaqA3Q1geV6"
}
}
</pre>
</section>
</section>
</section>
<section>
<h2>Algorithms</h2>
<p>
The following section describes multiple Data Integrity cryptographic suites
that utilize the Elliptic Curve Digital Signature Algorithm (ECDSA) [[FIPS-186-5]].
</p>
<section>
<h3>ecdsa-2019</h3>
<p>
The `ecdsa-2019` cryptographic suite takes an input document, canonicalizes
the document using the Universal 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>
<section>
<h4>Add Proof (ecdsa-2019)</h4>
<p>
To generate a proof, the algorithm in
<a href="https://www.w3.org/TR/vc-data-integrity/#add-proof">
Section 4.1: Add Proof</a> in the Data Integrity
[[VC-DATA-INTEGRITY]] specification MUST be executed.
For that algorithm, the cryptographic suite specific
<a href="https://www.w3.org/TR/vc-data-integrity/#dfn-transformation-algorithm">
transformation algorithm</a> is defined in Section
<a href="#transformation-ecdsa-2019"></a>, the
<a href="https://www.w3.org/TR/vc-data-integrity/#dfn-hashing-algorithm">
hashing algorithm</a> is defined in Section <a href="#hashing-ecdsa-2019"></a>,
and the
<a href="https://www.w3.org/TR/vc-data-integrity/#dfn-proof-serialization-algorithm">
proof serialization algorithm</a> is defined in Section
<a href="#proof-serialization-ecdsa-2019"></a>.
</p>
</section>
<section>
<h4>Verify Proof (ecdsa-2019)</h4>
<p>
To verify a proof, the algorithm in
<a href="https://www.w3.org/TR/vc-data-integrity/#verify-proof">
Section 4.2: Verify Proof</a> in the Data Integrity
[[VC-DATA-INTEGRITY]] specification MUST be executed.
For that algorithm, the cryptographic suite specific
<a href="https://www.w3.org/TR/vc-data-integrity/#dfn-transformation-algorithm">
transformation algorithm</a> is defined in Section
<a href="#transformation-ecdsa-2019"></a>, the
<a href="https://www.w3.org/TR/vc-data-integrity/#dfn-hashing-algorithm">
hashing algorithm</a> is defined in Section <a href="#hashing-ecdsa-2019"></a>,
and the
<a href="https://www.w3.org/TR/vc-data-integrity/#dfn-proof-serialization-algorithm">
proof verification algorithm</a> is defined in Section
<a href="#proof-verification-ecdsa-2019"></a>.
</p>
</section>
<section>
<h4>Transformation (ecdsa-2019)</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 <a href="#hashing-ecdsa-2019"></a>.
</p>
<p>
Required inputs to this algorithm are an
<a data-cite="vc-data-integrity#dfn-unsecured-data-document">
unsecured data document</a> (<var>unsecuredDocument</var>) and
transformation options (<var>options</var>). The
transformation options MUST contain a type identifier for the
<a data-cite="vc-data-integrity#dfn-cryptosuite">
cryptographic suite</a> (<var>type</var>) and a cryptosuite
identifier (<var>cryptosuite</var>). 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 <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 `ecdsa-2019` then a `PROOF_TRANSFORMATION_ERROR` MUST be
raised.
</li>
<li>
Let <var>canonicalDocument</var> be the result of applying the
Universal RDF Dataset Canonicalization Algorithm
[[RDF-CANON]] to the <var>unsecuredDocument</var>.
</li>
<li>
Set <var>output</var> to the value of <var>canonicalDocument</var>.
</li>
<li>
Return <var>canonicalDocument</var> as the <em>transformed data document</em>.
</li>
</ol>
</section>
<section>
<h4>Hashing (ecdsa-2019)</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 <a href="#proof-serialization-ecdsa-2019"></a> or
Section <a href="#proof-verification-ecdsa-2019"></a>. One must use the hash
algorithm appropriate in security level to the curve used, i.e., for curve
P-256 one uses SHA-256 and for curve P-384 one uses SHA-384.
</p>
<p>
The required inputs to this algorithm are a <em>transformed data document</em>
(<var>transformedDocument</var>) and <em>canonical proof configuration</em>
(<var>canonicalProofConfig</var>). A single <em>hash data</em> value represented as
series of bytes is produced as output.
</p>
<ol class="algorithm">
<li>
Let <var>transformedDocumentHash</var> be the result of applying the
SHA-256 (SHA-2 with 256-bit output) or SHA-384 (SHA-2 with 384-bit output)
cryptographic hashing algorithm [[RFC6234]] to the
respective curve P-256 or curve P-384 <var>transformedDocument</var>.
Respective <var>transformedDocumentHash</var> will be exactly 32 or 48 bytes
in size.
</li>
<li>
Let <var>proofConfigHash</var> be the result of applying the
SHA-256 (SHA-2 with 256-bit output) or SHA-384 (SHA-2 with 384-bit output)
cryptographic hashing algorithm [[RFC6234]] to the respective curve P-256 or curve P-384
<var>canonicalProofConfig</var>. Respective <var>proofConfigHash</var>
will be exactly 32 or 48 bytes in size.
</li>
<li>
Let <var>hashData</var> be the result of joining <var>proofConfigHash</var> (the
first hash) with <var>transformedDocumentHash</var> (the second hash).
</li>
<li>
Return <var>hashData</var> as the <em>hash data</em>.
</li>
</ol>
</section>
<section>
<h4>Proof Configuration (ecdsa-2019)</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-ecdsa-2019">proof hashing algorithm</a>.
</p>
<p>
The required inputs to this algorithm are <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">
cryptographic suite</a> (<var>type</var>) and MUST contain a cryptosuite
identifier (<var>cryptosuite</var>). A <em>proof configuration</em>
object is produced as output.
</p>
<ol class="algorithm">
<li>
Let <var>proofConfig</var> be an empty object.
</li>
<li>
Set <var>proofConfig</var>.<var>type</var> to
<var>options</var>.<var>type</var>.
</li>
<li>
If <var>options</var>.<var>cryptosuite</var> is set, set
<var>proofConfig</var>.<var>cryptosuite</var> to its value.
</li>
<li>
If <var>options</var>.<var>type</var> is not set to `DataIntegrityProof` and
<var>proofConfig</var>.<var>cryptosuite</var> is not set to `ecdsa-2019`, an
`INVALID_PROOF_CONFIGURATION` error MUST be raised.
</li>
<li>
Set <var>proofConfig</var>.<var>created</var> to
<var>options</var>.<var>created</var>. If the value is not a valid
[[XMLSCHEMA11-2]] datetime, an `INVALID_PROOF_DATETIME` error MUST be raised.
</li>
<li>
Set <var>proofConfig</var>.<var>verificationMethod</var> to
<var>options</var>.<var>verificationMethod</var>.
</li>
<li>
Set <var>proofConfig</var>.<var>proofPurpose</var> to
<var>options</var>.<var>proofPurpose</var>.
</li>
<li>
Set <var>proofConfig</var>.<var>@context</var> to
<var>unsecuredDocument</var>.<var>@context</var>.
</li>
<li>
Let <var>canonicalProofConfig</var> be the result of applying the
Universal RDF Dataset Canonicalization Algorithm
[[RDF-CANON]] to the <var>proofConfig</var>.
</li>
<li>
Return <var>canonicalProofConfig</var>.
</li>
</ol>
</section>
<section>
<h4>Proof Serialization (ecdsa-2019)</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 (<var>hashData</var>) and
<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">
cryptographic suite</a> (<var>type</var>) and MAY contain a cryptosuite
identifier (<var>cryptosuite</var>). A single <em>digital proof</em> value
represented as series of bytes is produced as output.
</p>
<ol class="algorithm">
<li>
Let <var>privateKeyBytes</var> be the result of retrieving the
private key bytes associated with the
<var>options</var>.<var>verificationMethod</var> value as described in the
Data Integrity [[VC-DATA-INTEGRITY]] specification,
<a data-cite="vc-data-integrity#algorithms">
Section 4: Retrieving Cryptographic Material</a>.
</li>
<li>
Let <var>proofBytes</var> be the result of applying the Elliptic Curve Digital
Signature Algorithm (ECDSA) [[FIPS-186-5]], with <var>hashData</var> as the data
to be signed using the private key specified by <var>privateKeyBytes</var>.
<var>proofBytes</var> will be exactly 64 bytes in size for a P-256 key, and
96 bytes in size for a P-384 key.
</li>
<li>
Return <var>proofBytes</var> as the <em>digital proof</em>.
</li>
</ol>
</section>
<section>
<h4>Proof Verification (ecdsa-2019)</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 (<var>hashData</var>),
a digital signature (<var>proofBytes</var>) and
proof options (<var>options</var>). A <em>verification result</em>
represented as a boolean value is produced as output.
</p>
<ol class="algorithm">
<li>
Let <var>publicKeyBytes</var> be the result of retrieving the
public key bytes associated with the
<var>options</var>.<var>verificationMethod</var> value as described in the
Data Integrity [[VC-DATA-INTEGRITY]] specification,
<a data-cite="vc-data-integrity#algorithms">
Section 4: Retrieving Cryptographic Material</a>.
</li>
<li>
Let <var>verificationResult</var> be the result of applying the verification
algorithm Elliptic Curve Digital Signature Algorithm (ECDSA) [[FIPS-186-5]],
with <var>hashData</var> as the data to be verified against the
<var>proofBytes</var> using the public key specified by
<var>publicKeyBytes</var>.
</li>
<li>
Return <var>verificationResult</var> as the <em>verification result</em>.
</li>
</ol>
</section>
</section>
<section>
<h3>jcs-ecdsa-2019</h3>
<p>
The `jcs-ecdsa-2019` 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 in this
section also include the verification of such a data integrity proof.
</p>
<section>
<h4>Add Proof (jcs-ecdsa-2019)</h4>
<p>
To generate a proof, the algorithm in
<a href="https://www.w3.org/TR/vc-data-integrity/#add-proof">
Section 4.1: Add Proof</a> of the Data Integrity
[[VC-DATA-INTEGRITY]] specification MUST be executed.
For that algorithm, the cryptographic suite-specific
<a href="https://www.w3.org/TR/vc-data-integrity/#dfn-transformation-algorithm">
transformation algorithm</a> is defined in Section
<a href="#transformation-jcs-ecdsa-2019"></a>, the
<a href="https://www.w3.org/TR/vc-data-integrity/#dfn-hashing-algorithm">
hashing algorithm</a> is defined in Section <a href="#hashing-jcs-ecdsa-2019"></a>,
and the
<a href="https://www.w3.org/TR/vc-data-integrity/#dfn-proof-serialization-algorithm">
proof serialization algorithm</a> is defined in Section
<a href="#proof-serialization-jcs-ecdsa-2019"></a>.
</p>
</section>
<section>
<h4>Verify Proof (jcs-ecdsa-2019)</h4>
<p>
To verify a proof, the algorithm in
<a href="https://www.w3.org/TR/vc-data-integrity/#verify-proof">
Section 4.2: Verify Proof</a> of the Data Integrity
[[VC-DATA-INTEGRITY]] specification MUST be executed.
For that algorithm, the cryptographic suite-specific
<a href="https://www.w3.org/TR/vc-data-integrity/#dfn-transformation-algorithm">
transformation algorithm</a> is defined in Section
<a href="#transformation-jcs-ecdsa-2019"></a>, the
<a href="https://www.w3.org/TR/vc-data-integrity/#dfn-hashing-algorithm">
hashing algorithm</a> is defined in Section <a href="#hashing-jcs-ecdsa-2019"></a>,
and the
<a href="https://www.w3.org/TR/vc-data-integrity/#dfn-proof-serialization-algorithm">
proof verification algorithm</a> is defined in Section
<a href="#proof-verification-jcs-ecdsa-2019"></a>.
</p>
</section>
<section>
<h4>Transformation (jcs-ecdsa-2019)</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 <a href="#hashing-jcs-ecdsa-2019"></a>.
</p>
<p>
Required inputs to this algorithm are an
<a data-cite="vc-data-integrity#dfn-unsecured-data-document">
unsecured data document</a> (<var>unsecuredDocument</var>) and
transformation options (<var>options</var>). The
transformation options MUST contain a type identifier for the
<a data-cite="vc-data-integrity#dfn-cryptosuite">
cryptographic suite</a> (<var>type</var>) and a cryptosuite
identifier (<var>cryptosuite</var>). 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 <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 `jcs-ecdsa-2019`, 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>
<li>
Set <var>output</var> to the value of <var>canonicalDocument</var>.
</li>
<li>
Return <var>canonicalDocument</var> as the <em>transformed data document</em>.
</li>
</ol>
</section>
<section>
<h4>Hashing (jcs-ecdsa-2019)</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 <a href="#proof-serialization-jcs-ecdsa-2019"></a> or
Section <a href="#proof-verification-jcs-ecdsa-2019"></a>. One must use the
hash algorithm appropriate in security level to the curve used, i.e., for curve
P-256 one uses SHA-256, and for curve P-384 one uses SHA-384.
</p>
<p>
The required inputs to this algorithm are a <em>transformed data document</em>
(<var>transformedDocument</var>) and a <em>canonical proof configuration</em>
(<var>canonicalProofConfig</var>). A single <em>hash data</em> value represented as
series of bytes is produced as output.
</p>
<ol class="algorithm">
<li>
Let <var>transformedDocumentHash</var> be the result of applying the SHA-256
(SHA-2 with 256-bit output) or SHA-384 (SHA-2 with 384-bit output)
cryptographic hashing algorithm [[RFC6234]] to the
respective curve P-256 or curve P-384 <var>transformedDocument</var>.
Respective <var>transformedDocumentHash</var> will be exactly 32 or 48 bytes
in size.
</li>
<li>
Let <var>proofConfigHash</var> be the result of applying the SHA-256
(SHA-2 with 256-bit output) or SHA-384 (SHA-2 with 384-bit output)
cryptographic hashing algorithm [[RFC6234]] to the
respective curve P-256 or curve P-384 <var>canonicalProofConfig</var>.
Respective <var>proofConfigHash</var> will be exactly 32 or 48 bytes in size.
</li>
<li>
Let <var>hashData</var> be the result of concatenating <var>proofConfigHash</var> (the
first hash) followed by <var>transformedDocumentHash</var> (the second hash).
</li>
<li>
Return <var>hashData</var> as the <em>hash data</em>.
</li>
</ol>
</section>
<section>
<h4>Proof Configuration (jcs-ecdsa-2019)</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-jcs-ecdsa-2019">proof hashing algorithm</a>.
</p>
<p>
The required inputs to this algorithm are <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">
cryptographic suite</a> (<var>type</var>) and MUST contain a cryptosuite
identifier (<var>cryptosuite</var>). A <em>proof configuration</em>
object is produced as output.
</p>
<ol class="algorithm">
<li>
Let <var>proofConfig</var> be an empty object.
</li>
<li>
Set <var>proofConfig</var>.<var>type</var> to
<var>options</var>.<var>type</var>.
</li>
<li>
If <var>options</var>.<var>cryptosuite</var> is set, set
<var>proofConfig</var>.<var>cryptosuite</var> to its value.
</li>
<li>
If <var>options</var>.<var>type</var> is not set to `DataIntegrityProof` and
<var>proofConfig</var>.<var>cryptosuite</var> is not set to `jcs-ecdsa-2019`, an
`INVALID_PROOF_CONFIGURATION` error MUST be raised.
</li>
<li>
Set <var>proofConfig</var>.<var>created</var> to
<var>options</var>.<var>created</var>. If the value is not a valid
[[XMLSCHEMA11-2]] datetime, an `INVALID_PROOF_DATETIME` error MUST be raised.
</li>
<li>
Set <var>proofConfig</var>.<var>verificationMethod</var> to
<var>options</var>.<var>verificationMethod</var>.
</li>
<li>
Set <var>proofConfig</var>.<var>proofPurpose</var> to
<var>options</var>.<var>proofPurpose</var>.
</li>
<li>
Let <var>canonicalProofConfig</var> be the result of applying the
JSON Canonicalization Scheme [[RFC8785]] to the <var>proofConfig</var>.
</li>
<li>
Return <var>canonicalProofConfig</var>.
</li>
</ol>
</section>
<section>
<h4>Proof Serialization (jcs-ecdsa-2019)</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 (<var>hashData</var>) and
<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">
cryptographic suite</a> (<var>type</var>) and MAY contain a cryptosuite
identifier (<var>cryptosuite</var>). A single <em>digital proof</em> value
represented as series of bytes is produced as output.
</p>
<ol class="algorithm">
<li>
Let <var>privateKeyBytes</var> be the result of retrieving the
private key bytes associated with the
<var>options</var>.<var>verificationMethod</var> value as described in the
Data Integrity [[VC-DATA-INTEGRITY]] specification,
<a data-cite="vc-data-integrity#algorithms">
Section 4: Retrieving Cryptographic Material</a>.
</li>
<li>
Let <var>proofBytes</var> be the result of applying the Elliptic Curve Digital
Signature Algorithm (ECDSA) [[FIPS-186-5]], with <var>hashData</var> as the data
to be signed using the private key specified by <var>privateKeyBytes</var>.
<var>proofBytes</var> will be exactly 64 bytes in size for a P-256 key, and
96 bytes in size for a P-384 key.
</li>
<li>
Return <var>proofBytes</var> as the <em>digital proof</em>.
</li>
</ol>
</section>
<section>
<h4>Proof Verification (jcs-ecdsa-2019)</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 (<var>hashData</var>),
a digital signature (<var>proofBytes</var>), and
proof options (<var>options</var>). A <em>verification result</em>