forked from w3c/vc-di-bbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
4111 lines (3969 loc) · 178 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 BBS 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">
const respecConfig = {
// 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-bbs",
subtitle: "Achieving Unlinkable Data Integrity with Pairing-based Cryptography",
group: "vc",
// latestVersion: "https://www.w3.org/community/reports/credentials/CG-FINAL-vc-di-bbs-20230405/",
// if you wish the publication date to be other than today, set this
publishDate: "2024-04-04",
// 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-bbs/",
// if this is a LCWD, uncomment and set the end of its review period
implementationReportURI: "https://w3c.github.io/vc-data-integrity/implementations/",
crEnd: "2024-05-04",
// 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: "Greg Bernstein", url: "https://www.grotto-networking.com/",
company: "Invited Expert", w3cid: 140479
}, {
name: "Manu Sporny", url: "https://www.linkedin.com/in/manusporny/",
company: "Digital Bazaar", companyURL: "https://www.digitalbazaar.com/",
w3cid: 41758
}
],
// extend the bibliography entries
//localBiblio: webpayments.localBiblio,
// wg: "Verifiable Credentials Working Group 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",
// 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: "https://www.w3.org/community/about/agreements/cla/",
github: "https://github.com/w3c/vc-di-bbs",
// 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: {
"RDF-CONCEPTS": {
title: "RDF 1.1 Concepts and Abstract Syntax",
href: "https://www.w3.org/TR/rdf11-concepts/",
authors: ["Richard Cyganiak", "David Wood", "Markus Lanthaler"],
status: "Recommendation",
publisher: "W3C"
},
"DI-ECDSA": {
title: "The Elliptic Curve Digital Signature Algorithm Cryptosuites v1.0",
href: "https://www.w3.org/TR/vc-di-ecdsa/",
authors: ["David Longley", "Manu Sporny", "Marty Reed"],
status: "WD",
publisher: "W3C Verifiable Credentials Working Group"
},
"VC-DATA-MODEL-2": {
title: "Verifiable Credentials Data Model v2.0",
href: "https://www.w3.org/TR/vc-data-model-2.0/",
authors: [
"Manu Sporny", "Dave Longley", "Grant Noble", "Dan Burnett",
"Ted Thibodeau", "Brent Zundel", "David Chadwick",
"Kyle Den Hartog"
],
status: "Working Draft",
publisher: "W3C Verifiable Credentials Working Group"
},
"CFRG-BBS-SIGNATURE": {
title: "The BBS Signature Scheme",
href: "https://www.ietf.org/archive/id/draft-irtf-cfrg-bbs-signatures-05.html",
authors: ["Tobias Looker", "Vasilis Kalos", "Andrew Whitehead", "Mike Lodder"],
status: "Draft"
},
"CFRG-PAIRING-FRIENDLY": {
title: "Pairing-Friendly Curves",
href: "https://www.ietf.org/archive/id/draft-irtf-cfrg-pairing-friendly-curves-11.html",
authors: ["Yumi Sakemi", "Tetsutaro Kobayashi", "Tsunekazu Saito", "Riad S. Wahby"],
status: "Draft"
},
"BLS-JOSE-COSE": {
title: "Barreto-Lynn-Scott Elliptic Curve Key Representations for JOSE and COSE",
href: "https://datatracker.ietf.org/doc/draft-ietf-cose-bls-key-representations/",
authors: ["Michael B. Jones", "Tobias Looker"],
status: "Draft"
},
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"
},
CDL2016: {
title: "Anonymous Attestation Using the Strong Diffie Hellman Assumption Revisited",
href: "https://eprint.iacr.org/2016/663",
authors: ["Jan Camenisch", "Manu Drijvers", "Anja Lehmann"],
date: "2016",
publisher: "Cryptology ePrint Archive, Paper 2016/663"
},
TZ2023: {
title: "Revisiting BBS Signatures",
href: "https://eprint.iacr.org/2023/275",
authors: ["Stefano Tessaro", "Chenzhi Zhu"],
date: "2023",
publisher: "Cryptology ePrint Archive, Paper 2023/275"
},
"NISTIR8053": {
title: "NISTIR 8053: De-Identification of Personal Information",
href: "https://nvlpubs.nist.gov/nistpubs/ir/2015/NIST.IR.8053.pdf",
authors: ["Simson L. Garfinkel"],
date: "October 2015"
},
"Powar2023": {
title: "SoK: Managing risks of linkage attacks on data privacy",
authors: ["J. Powar", "A. R. Beresford"],
publisher: "Proceedings on Privacy Enhancing Technologies",
date: "2023",
href: "https://petsymposium.org/popets/2023/popets-2023-0043.php"
},
"Pugliese2020": {
title: "Long-Term Observation on Browser Fingerprinting: Users' Trackability and Perspective",
authors: ["G. Pugliese", "C. Riess", "F. Gassmann", "Z. Benenson"],
publisher: "Proceedings on Privacy Enhancing Technologies",
date: "2020",
href: "https://petsymposium.org/popets/2020/popets-2020-0041.php"
},
"CFRG-Blind-BBS-Signature": {
title: "Blind BBS Signatures",
authors: ["V. Kalos", "G. Bernstein"],
date: "2024",
href: "https://www.ietf.org/archive/id/draft-kalos-bbs-blind-signatures-00.html#name-proof-generationhttps://www.ietf.org/archive/id/draft-kalos-bbs-blind-signatures-03.html"
},
"CFRG-Pseudonym-BBS-Signature": {
title: "BBS per Verifier Linkability",
authors: ["V. Kalos"],
date: "2024",
href: "https://www.ietf.org/archive/id/draft-kalos-bbs-per-verifier-linkability-00.html"
}
},
lint: { "informative-dfn": false },
postProcess: [],
xref: [
"INFRA", "I18N-GLOSSARY", "VC-DATA-MODEL-2.0", "VC-DATA-INTEGRITY"
]
};
</script>
<style>
code {
color: rgb(199, 73, 0);
font-weight: bold;
}
pre {
overflow-x: auto;
white-space: pre-wrap;
}
pre .highlight {
font-weight: bold;
color: Green;
}
pre .subject {
font-weight: bold;
color: RoyalBlue;
}
pre .property {
font-weight: bold;
color: DarkGoldenrod;
}
pre .comment {
font-weight: bold;
color: SteelBlue;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
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
digital signatures using the BBS signature scheme.
The Signature Suite utilizes BBS signatures to provide selective disclosure and
unlinkable derived proofs.
</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 feature, both mandatory and optional, in the specification. For details on
the conformance testing process, see the test suites listed in the
<a href="https://w3c.github.io/vc-data-integrity/implementations/">
implementation report</a>.
</p>
</section>
<section>
<h2>Introduction</h2>
<p>
This specification defines a cryptographic suite for the purpose of
creating, verifying, and deriving proofs using the BBS Signature Scheme in
conformance with the Data Integrity [[VC-DATA-INTEGRITY]] specification. The
BBS signature scheme directly provides for selective disclosure and unlinkable
proofs. It provides four high-level functions that work within the <i>issuer,
holder, verifier</i> model. Specifically, an issuer uses the BBS `Sign` function to
create a cryptographic value known as a "BBS signature" which is used in signing
the original credential. A holder, on receipt of
a credential signed with BBS, then verifies the credential with the BBS `Verify`
function.
</p>
<p>
The holder then chooses information to selectively disclose from the
received credential and uses the BBS `ProofGen` function to generate a
cryptographic value, known as a "BBS proof", which is used in creating a proof
for this "derived credential". The cryptographic "BBS proof" value is not linkable
to the original "BBS signature" and a different, unlinkable "BBS proof" can be
generated by the holder for additional "derived credentials", including any
containing the exact same information.
Finally, a verifier uses the BBS `ProofVerify` function to verify the derived
credential received from the holder.
</p>
<p>
Applying the BBS signature scheme to verifiable credentials involves the
processing specified in this document.
In general the suite uses the RDF Dataset Canonicalization Algorithm
[[RDF-CANON]] to transform an input document into its canonical
form. An issuer then uses selective disclosure primitives to separate the
canonical form into mandatory and non-mandatory statements. These are processed
separately with other information to serve as the inputs to the BBS `Sign`
function along with appropriate key material. This output is used to
generate a secured credential. A holder uses a set of selective disclosure
functions and the BBS `Verify` function on receipt of the credential
to ascertain validity.
</p>
<p>
Similarly, on receipt of a BBS signed credential, a holder uses the RDF Dataset
Canonicalization Algorithm [[RDF-CANON]] to transform an input
document into its canonical form, and then applies selective disclosure
primitives to separate the canonical form into mandatory and selectively
disclosed statements, which are appropriately processed and serve as inputs to
the BBS `ProofGen` function. Suitably processed, the output of this function
becomes the signed selectively disclosed credential sent to a verifier. Using
canonicalization and selective disclosure primitives, the verifier can then use
the BBS `verifyProof` function to validate the credential.
</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
<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 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. Such parts need to be
removed if implementers want 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
for <a>verification methods</a> and <a>data integrity proof</a> formats.
</p>
<section>
<h2>Verification Methods</h2>
<p>
These verification methods are used to verify Data Integrity Proofs
[[VC-DATA-INTEGRITY]] produced using BLS12-381 cryptographic key material
that is compliant with [[CFRG-BBS-SIGNATURE]]. The encoding formats for these key types
are provided in this section. Lossless cryptographic key transformation
processes that result in equivalent cryptographic key material MAY be used
during the processing of digital signatures.
</p>
<section>
<h3>Multikey</h3>
<p>
The <a data-cite="VC-DATA-INTEGRITY#multikey">Multikey format</a>, as defined in
[[VC-DATA-INTEGRITY]], is used to express public keys for the cryptographic
suites defined in this specification.
</p>
<p>
The `publicKeyMultibase` property represents a Multibase-encoded Multikey
expression of a BLS12-381 public key in the G2 group. The encoding of this field
is the two-byte prefix `0xeb01` followed
by the 96-byte compressed public key data.
The 98-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
value other than `0xeb01` being used in a `publicKeyMultibase` value.
</p>
<pre class="example"
title="A BLS12-381 G2 group public key, encoded as a Multikey">
{
"id": "https://example.com/issuer/123#key-0",
"type": "Multikey",
"controller": "https://example.com/issuer/123",
"publicKeyMultibase": "zUC7EK3ZakmukHhuncwkbySmomv3FmrkmS36E4Ks5rsb6VQSRpoCrx6
Hb8e2Nk6UvJFSdyw9NK1scFXJp21gNNYFjVWNgaqyGnkyhtagagCpQb5B7tagJu3HDbjQ8h
5ypoHjwBb"
}
</pre>
<pre class="example" title="A BLS12-381 G2 group 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": "https://example.com/issuer/123",
"verificationMethod": [{
"id": "https://example.com/issuer/123#key-1",
"type": "Multikey",
"controller": "https://example.com/issuer/123",
"publicKeyMultibase": "zUC7EK3ZakmukHhuncwkbySmomv3FmrkmS36E4Ks5rsb6VQSRpoCr
x6Hb8e2Nk6UvJFSdyw9NK1scFXJp21gNNYFjVWNgaqyGnkyhtagagCpQb5B7tagJu3HDbjQ8h
5ypoHjwBb"
}]
}
</pre>
</section>
</section>
<section>
<h2>Proof Representations</h2>
<section>
<h3>DataIntegrityProof</h3>
<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 `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 `bbs-2023`.
</p>
<p>
The value of the `proofValue` property of the proof MUST be a BBS signature or
BBS proof produced according to [[CFRG-BBS-SIGNATURE]] that is serialized and encoded
according to procedures in section <a href="#algorithms"></a>.
</p>
</section>
</section>
</section>
<section>
<h2>Algorithms</h2>
<p>
The following algorithms describe how to use verifiable credentials with
the BBS Signature Scheme [[CFRG-BBS-SIGNATURE]]. When using the BBS signature
scheme the SHA-256 variant SHOULD be used.
</p>
<p>
Implementations SHOULD fetch and cache <a>verification method</a> information as
early as possible when adding or verifying proofs. Parameters passed to
functions in this section use information from the <a>verification
method</a> — such as the public key size — to determine function parameters — such
as the cryptographic hashing algorithm.
</p>
<p class="advisement">
When the RDF Dataset Canonicalization Algorithm [[RDF-CANON]] is used,
implementations of that algorithm will detect
<a data-cite="RDF-CANON#dataset-poisoning">dataset poisoning</a>
by default, and abort processing upon detection.
</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 `bbs-2023` then:
<ol class="algorithm">
<li>
Set |cryptosuite|.|createProof| to the algorithm in Section
[[[#create-base-proof-bbs-2023]]].
</li>
<li>
Set |cryptosuite|.|verifyProof| to the algorithm in Section
[[[#verify-derived-proof-bbs-2023]]].
</li>
</ol>
</li>
<li>
Return |cryptosuite|.
</li>
</ol>
</section>
<section>
<h3>Selective Disclosure Functions</h3>
<section>
<h4>createShuffledIdLabelMapFunction</h4>
<p>
The following algorithm creates a label map factory function that uses an
HMAC to shuffle canonical blank node identifiers. The required input is an HMAC
(previously initialized with a secret key), |HMAC|. A function,
<em>labelMapFactoryFunction</em>, is produced as output.
</p>
<ol class="algorithm">
<li>
Create a function, |labelMapFactoryFunction|, with one required input
(a canonical node identifier map, |canonicalIdMap|), that will
return a blank node identifier map, <em>bnodeIdMap</em>, as output. Set the
function's implementation to:
<ol class="algorithm">
<li>
Generate a new empty bnode identifier map, <em>bnodeIdMap</em>.
</li>
<li>
For each map entry, <em>entry</em>, in |canonicalIdMap|:
<ol class="algorithm">
<li>
Perform an HMAC operation on the canonical identifier from the value in <em>entry</em> to get an HMAC
digest, <em>digest</em>.
</li>
<li>
Generate a new string value, <em>b64urlDigest</em>, and initialize it to "u"
followed by appending a base64url-no-pad encoded version of the <em>digest</em>
value.
</li>
<li>
Add a new entry, |newEntry|, to <em>bnodeIdMap</em> using the key
from <em>entry</em> and <em>b64urlDigest</em> as the value.
</li>
</ol>
</li>
<li>
Derive the shuffled mapping from the `bnodeIdMap` as follows:
<ol class="algorithm">
<li>
Set `hmacIds` to be the sorted array of values from the `bnodeIdMap`, and set
`bnodeKeys` to be the ordered array of keys from the `bnodeIdMap`.
</li>
<li>
For each key in `bnodeKeys`, replace the `bnodeIdMap` value for that key with the
index position of the value in the `hmacIds` array prefixed by "b", i.e.,
`bnodeIdMap.set(bkey, 'b' + hmacIds.indexOf(bnodeIdMap.get(bkey)))`.
</li>
</ol>
</li>
<li>
Return <em>bnodeIdMap</em>.
</li>
</ol>
</li>
<li>
Return |labelMapFactoryFunction|.
</li>
</ol>
<p class="note informative">
It should be noted that step 1.2 in the above algorithm is identical to step 1.2
in <a href="https://www.w3.org/TR/vc-di-ecdsa/#createhmacidlabelmapfunction">
Section 3.3.4 `createHmacIdLabelMapFunction`</a> of [[DI-ECDSA]],
so developers might be able to reuse the code or call the function if implementing
both.
</p>
</section>
</section>
<section>
<h3>bbs-2023 Functions</h3>
<section>
<h4>serializeBaseProofValue</h4>
<p>
The following algorithm serializes the base proof value, including the
BBS signature, HMAC key, and mandatory pointers.
The required inputs are a base signature |bbsSignature|, |bbsHeader|,
|publicKey|, an HMAC key |hmacKey|, an array of
|mandatoryPointers|, |featureOption|, and, depending on
the |featureOption| value, possibly a |signer_nym_entropy| value.
A single <em>base proof</em> string value is produced as output.
</p>
<ol class="algorithm">
<li>
Depending upon the value of the |featureOption|, set up the |proofValue| as
follows.
</li>
<li>
If |featureOption| equals `"baseline"`:
<ol class="algorithm">
<li>
Initialize a byte array, |proofValue|, that starts with the BBS base proof
header bytes `0xd9`, `0x5d`, and `0x02`.
</li>
<li>
Initialize |components| to an array with five elements containing the values of:
|bbsSignature|, |bbsHeader|, |publicKey|, |hmacKey|, and |mandatoryPointers|.
</li>
</ol>
</li>
<li>
If |featureOption| equals `"anonymous_holder_binding"`:
<ol class="algorithm">
<li>
Initialize a byte array, |proofValue|, that starts with the BBS base proof
header bytes `0xd9`, `0x5d`, and `0x04`.
</li>
<li>
Initialize |components| to an array with six elements containing the values of:
|bbsSignature|, |bbsHeader|, |publicKey|, |hmacKey|, and |mandatoryPointers|.
</li>
</ol>
</li>
<li>
If |featureOption| equals `"pseudonym"`:
<ol class="algorithm">
<li>
Initialize a byte array, |proofValue|, that starts with the BBS base proof
header bytes `0xd9`, `0x5d`, and `0x06`.
</li>
<li>
Initialize |components| to an array with six elements containing the values of:
|bbsSignature|, |bbsHeader|, |publicKey|, |hmacKey|, |mandatoryPointers|, and
|signer_nym_entropy|.
</li>
</ol>
</li>
<li>
If |featureOption| equals `"holder_binding_pseudonym"`:
<ol class="algorithm">
<li>
Initialize a byte array, |proofValue|, that starts with the BBS base proof
header bytes `0xd9`, `0x5d`, and `0x08`.
</li>
<li>
Initialize |components| to an array with six elements containing the values of:
|bbsSignature|, |bbsHeader|, |publicKey|, |hmacKey|, |mandatoryPointers|, and
|signer_nym_entropy|.
</li>
</ol>
</li>
<li>
CBOR-encode |components| per [[RFC8949]] where CBOR tagging MUST NOT be used on
any of the |components|. Append the produced encoded value to |proofValue|.
</li>
<li>
Initialize |baseProof| to a string with the multibase-base64url-no-pad-encoding
of `proofValue`. That is, return a string starting with "`u`" and ending with the
base64url-no-pad-encoded value of |proofValue|.
</li>
<li>
Return |baseProof| as <em>base proof</em>.
</li>
</ol>
</section>
<section>
<h4>parseBaseProofValue</h4>
<p>
The following algorithm parses the components of a `bbs-2023` selective
disclosure base proof value. The required input is a proof value
(|proofValue|). A single object, <em>parsed base proof</em>, containing
six or seven elements, using the names "bbsSignature", "bbsHeader",
"publicKey",
"hmacKey", "mandatoryPointers", "featureOption", and possibly optional feature
parameter "signer_nym_entropy", is produced as output.
</p>
<ol class="algorithm">
<li>
If the `proofValue` string does not start with
<span class="codepoint" translate="no">
<bdi lang="en"><code title="LATIN SMALL LETTER U">u</code></bdi>
(<code class="codepoint">U+0075</code>
<code class="uname">LATIN SMALL LETTER U</code>)</span>,
indicating that it is a `multibase-base64url-no-pad-encoded` value,
an error MUST be raised and SHOULD convey an error type of
<a data-cite="VC-DATA-INTEGRITY#PROOF_VERIFICATION_ERROR">PROOF_VERIFICATION_ERROR</a>.
</li>
<li>
Initialize |decodedProofValue| to the result of base64url-no-pad-decoding the
substring that follows the leading `u` in `proofValue`.
</li>
<li>
Check that the BBS base proof starts with an allowed header value and set the
|featureOption| variable as follows:
<ol class="algorithm">
<li>
If the |decodedProofValue| starts with the bytes `0xd9`, `0x5d`, and `0x02`, set
|featureOption| to `"baseline"`.
</li>
<li>
If the |decodedProofValue| starts with the bytes `0xd9`, `0x5d`, and `0x04`, set
|featureOption| to `"anonymous_holder_binding"`.
</li>
<li>
If the |decodedProofValue| starts with the bytes `0xd9`, `0x5d`, and `0x06`, set
|featureOption| to `"pseudonym"`.
</li>
<li>
If the |decodedProofValue| starts with the bytes `0xd9`, `0x5d`, and `0x08`, set
|featureOption| to `"holder_binding_pseudonym"`.
</li>
<li>
If the |decodedProofValue| starts with any other three byte sequence,
an error MUST be raised and SHOULD convey an error type of
<a data-cite="VC-DATA-INTEGRITY#PROOF_VERIFICATION_ERROR">PROOF_VERIFICATION_ERROR</a>.
</li>
</ol>
</li>
<li>
Initialize `components` to an array that is the result of CBOR-decoding the
bytes that follow the three-byte BBS base proof header.
</li>
<li>
Based on the value of |featureOption|, return an object based on |components|,
as follows:
<ol class="algorithm">
<li>
If |featureOption| equals `"baseline"`, set the property names for the object
based on |components| to "bbsSignature", "bbsHeader", "publicKey", "hmacKey",
and "mandatoryPointers", in that order, and add |featureOption| as a property.
</li>
<li>
If |featureOption| equals `"anonymous_holder_binding"`, set the property names
for the object based on |components| to "bbsSignature", "bbsHeader",
"publicKey", "hmacKey", and "mandatoryPointers", in that order, and
add |featureOption| as a property.
</li>
<li>
If |featureOption| equals `"pseudonym"`, set the property names
for the object based on |components| to "bbsSignature", "bbsHeader",
"publicKey", "hmacKey", "mandatoryPointers", and "signer_nym_entropy", in that
order, and add |featureOption| as a property.
</li>
<li>
If |featureOption| equals `"holder_binding_pseudonym"`, set the property names
for the object based on |components| to "bbsSignature", "bbsHeader",
"publicKey", "hmacKey", "mandatoryPointers", and "signer_nym_entropy", in that
order, and add |featureOption| as a property.
</li>
</ol>
</li>
</ol>
</section>
<section>
<h4>createDisclosureData</h4>
<p>
The following algorithm creates data to be used to generate a derived proof. The
inputs include a JSON-LD document (|document|), a BBS base proof
(|proof|), an array of JSON pointers to use to selectively disclose
statements (|selectivePointers|), an OPTIONAL BBS
|presentationHeader| (byte array that defaults to an empty byte array if
not present), a |featureOption| indicator, additional inputs as required by
the |featureOption| (see <a href="#add-derived-proof-bbs-2023">Add Derived Proof</a>),
and any custom JSON-LD API options
(such as a document loader). A single object, <em>disclosure data</em>, is
produced as output, which contains the following fields: |bbsProof|,
|labelMap|, |mandatoryIndexes|, |selectiveIndexes|, |presentationHeader|,
|revealDocument|, and, if computed, |pseudonym|.
</p>
<ol class="algorithm">
<li>
Initialize |bbsSignature|, |bbsHeader|, |publicKey|, |hmacKey|,
and |mandatoryPointers|
to the values of the associated properties in the object
returned when calling the algorithm in Section
<a href="#parsebaseproofvalue"></a>, passing the `proofValue` from `proof`.
</li>
<li>
Initialize |hmac| to an HMAC API using |hmacKey|. The HMAC uses the same hash
algorithm used in the signature algorithm, i.e., SHA-256.
</li>
<li>
Initialize |labelMapFactoryFunction| to the result of calling the algorithm of
section <a href="#createshuffledidlabelmapfunction"></a>, passing |hmac| as |HMAC|.
</li>
<li>
Initialize |combinedPointers| to the concatenation of |mandatoryPointers|
and |selectivePointers|.
</li>
<li>
Initialize |groupDefinitions| to a map with the following entries: key of
the string `"mandatory"` and value of |mandatoryPointers|; key of the string
`"selective"` and value of |selectivePointers|; and key of the string `"combined"`
and value of |combinedPointers|.
</li>
<li>
Initialize |groups| and |labelMap| to the result of calling the algorithm in
<a href="https://www.w3.org/TR/vc-di-ecdsa/#canonicalizeandgroup">Section 3.3.16
canonicalizeAndGroup</a> of the [[DI-ECDSA]] specification, passing |document|
|labelMapFactoryFunction|,
|groupDefinitions|, and any custom JSON-LD
API options. Note: This step transforms the document into an array of canonical
N-Quads whose order has been shuffled based on 'hmac'-applied blank node
identifiers, and groups
the N-Quad strings according to selections based on JSON pointers.
</li>
<li>
Compute the mandatory indexes relative to their positions in the combined
statement list, i.e., find the position at which a mandatory statement occurs
in the list of combined statements. One method for doing this is given below.
<ol class="algorithm">
<li>
Initialize |mandatoryIndexes| to an empty array. Set |mandatoryMatch| to
|groups.mandatory.matching| map; set |combinedMatch| to
|groups.combined.matching|; and set |combinedIndexes| to the ordered array of
just the keys of the |combinedMatch| map.
</li>
<li>
For each key in the |mandatoryMatch| map, find its index in the |combinedIndexes|
array (e.g., `combinedIndexes.indexOf(key)`), and add this value to the
|mandatoryIndexes| array.
</li>
</ol>
</li>
<li>
Compute the selective indexes relative to their positions in the non-mandatory
statement list, i.e., find the position at which a selected statement occurs in
the list of non-mandatory statements. One method for doing this is given below.
<ol class="algorithm">
<li>
Initialize |selectiveIndexes| to an empty array. Set |selectiveMatch| to the
|groups.selective.matching| map; set |mandatoryNonMatch| to the map
|groups.mandatory.nonMatching|; and |nonMandatoryIndexes| to to the ordered
array of just the keys of the |mandatoryNonMatch| map.
</li>
<li>
For each key in the |selectiveMatch| map, find its index in the
|nonMandatoryIndexes| array (e.g., `nonMandatoryIndexes.indexOf(key)`), and add
this value to the |selectiveIndexes| array.
</li>
</ol>
</li>
<li>
Initialize |bbsMessages| to an array of byte arrays containing the values in the
|nonMandatory| array of strings encoded using the UTF-8
<a>character encoding</a>.
</li>
<li>
Set |bbsProof| to the value computed by the appropriate procedure given below
based on the value of the |featureOption| parameter.
<ol class="algorithm">
<li>
If |featureOption| equals `"baseline"`,
set `bbsProof` to the value computed by the `ProofGen` procedure from
[[CFRG-BBS-SIGNATURE]], i.e.,
`ProofGen(PK, signature, header, ph, messages, disclosed_indexes)`,
where `PK` is the original issuers public key, `signature` is the
`bbsSignature`, `header` is the `bbsHeader`, `ph` is the `presentationHeader`
`messages` is `bbsMessages`, and `disclosed_indexes` is `selectiveIndexes`.
</li>
<li>
If |featureOption| equals `"anonymous_holder_binding"`,
set `bbsProof` to the value computed by the `BlindProofGen` procedure from
[[CFRG-Blind-BBS-Signature]], where |PK| is the original issuers public key,
|signature| is the
|bbsSignature|, |header| is the |bbsHeader|, |ph| is the |presentationHeader|,
|messages| is |bbsMessages|, |disclosed_indexes| is |selectiveIndexes|,
and `commitment_with_proof`. The holder will also furnish its
|holder_secret|, and the |proverBlind| that was used to compute the
|commitment_with_proof|. This is the
<a href="#anonymous-holder-binding">Anonymous Holder Binding</a> feature option.
<span class="note">To
be updated when IETF API is finalized.</span>
</li>
<li>
If |featureOption| equals `"pseudonym"`,
use the "Verification and Finalization" operation
from [[CFRG-Pseudonym-BBS-Signature]] with an empty |committed_messages| array
to both verify the |bbsSignature| and compute
the |nym_secret| value. This operation uses the |prover_nym|,
|signer_nym_entropy|, and |secret_prover_blind|.
<br><br>
Determine the |nym_domain|. This might be specified by
the verifier or set by the holder, depending on the usage scenario. Use
the "Proof Generation with Pseudonym"
operation from [[CFRG-Pseudonym-BBS-Signature]] to produce the derived proof.
This operation takes as inputs
the original issuer's public key as |PK|,
the |bbsSignature| as |signature|,
the |bbsHeader| as |header|,
the |presentationHeader| as |ph|,
the |bbsMessages| as |messages|,
the |selectiveIndexes| as |disclosed_indexes|,
a |nym_secret|,
a |nym_domain|,
an empty array for |committed_messages|,
and a |secret_prover_blind|.
In addition to providing
the raw
cryptographic proof value which is assigned to |bbsProof|,
it also returns the |pseudonym|.
<br><br>
This is for the
<a href="#credential-bound-pseudonyms">Credential-Bound Pseudonyms</a>
feature option. <span class="note">To be updated when IETF API is finalized.
</span>
</li>
<li>
If |featureOption| equals `"holder_binding_pseudonym"`,
use the "Verification and Finalization" operation
from [[CFRG-Pseudonym-BBS-Signature]] with the |committed_messages| array
containing the |holder_secret| as its only value,
to both verify the |bbsSignature| and compute
the |nym_secret| value. This operation uses the |prover_nym|,
|signer_nym_entropy|, and |secret_prover_blind|.
<br><br>
Determine the |nym_domain|. This might be specified by
the verifier or set by the holder depending on the usage scenario. Use
the "Proof Generation with Pseudonym"
operation from [[CFRG-Pseudonym-BBS-Signature]] to produce the derived proof.
This operation takes as inputs
|PK|, the original issuers public key,
|signature|, the |bbsSignature|, |header| is the |bbsHeader|,
|ph| is the |presentationHeader|,
|messages| is |bbsMessages|, |disclosed_indexes| is |selectiveIndexes|,
This operation takes as inputs
the original issuers public key as |PK|,
the |bbsSignature| as |signature|,
the |bbsHeader| as |header|,
the |presentationHeader| as |ph|,
the |bbsMessages| as |messages|,
the |selectiveIndexes| as |disclosed_indexes|,
a |nym_secret|,
a |nym_domain|,
the only value of the |committed_messages| array as |holder_secret|,
and a |secret_prover_blind|.
In addition to
providing the raw cryptographic proof value which is assigned to |bbsProof|,
it also returns the |pseudonym|.
This is for the
<a href="#holder-binding-and-pseudonyms">Holder Binding and Pseudonyms</a>
feature option. <span class="note">To be updated when IETF API is finalized.
</span>
</li>
</ol>
</li>
<li>
If |featureOption| equals `"anonymous_holder_binding"`,
`"pseudonym"`, or `"holder_binding_pseudonym"` set the |lengthBBSMessages|
parameter to the length of the |bbsMessages| array.
</li>
<li>
Initialize |revealDocument| to the result of the "selectJsonLd" algorithm from
[[DI-ECDSA]], passing `document`, and `combinedPointers` as `pointers`.
</li>
<li>
Run the RDF Dataset Canonicalization Algorithm [[RDF-CANON]] on
the joined |combinedGroup|.|deskolemizedNQuads|, passing any custom
options, and get the canonical bnode identifier map, |canonicalIdMap|.
Note: This map includes the canonical blank node identifiers that a verifier
will produce when they canonicalize the reveal document.
</li>
<li>
Initialize |verifierLabelMap| to an empty map. This map will map
the canonical blank node identifiers produced by the verifier when they
canonicalize the revealed document, to the blank node identifiers that were
originally signed in the base proof.
</li>
<li>
For each key (`inputLabel`) and value (`verifierLabel`) in `canonicalIdMap:
<ol class="algorithm">
<li>
Add an entry to `verifierLabelMap`, using `verifierLabel` as the key, and the
value associated with `inputLabel` as a key in `labelMap` as the value.
</li>
</ol>
</li>
<li>
Return an object with properties matching |bbsProof|, "verifierLabelMap" for |labelMap|,
|mandatoryIndexes|, |selectiveIndexes|, |revealDocument|, |pseudonym|, and, if
computed, |lengthBBSMessages|.