@midnight-ntwrk/credential-compact 0.1.0-rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/LICENSE +201 -0
- package/README.md +59 -0
- package/dist/compact-build.json +29 -0
- package/dist/contract.d.ts +2 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +2 -0
- package/dist/contract.js.map +1 -0
- package/dist/credentials/bindings.compact +5 -0
- package/dist/credentials/composable.compact +14 -0
- package/dist/credentials/holder-bindings.compact +320 -0
- package/dist/credentials/issue.compact +91 -0
- package/dist/credentials/present.compact +84 -0
- package/dist/credentials/proofs.compact +122 -0
- package/dist/credentials/protocol-support.compact +7 -0
- package/dist/credentials/protocols.compact +125 -0
- package/dist/credentials/relations.compact +36 -0
- package/dist/credentials/status-bindings.compact +60 -0
- package/dist/credentials/types.compact +141 -0
- package/dist/credentials/vc-support.compact +8 -0
- package/dist/credentials/vc.compact +59 -0
- package/dist/credentials/vp.compact +25 -0
- package/dist/credentials.compact +20 -0
- package/dist/holder-binding/same-holder/composable.compact +179 -0
- package/dist/holder-binding/same-holder.compact +180 -0
- package/dist/holder-binding/same-holder.d.ts +2 -0
- package/dist/holder-binding/same-holder.d.ts.map +1 -0
- package/dist/holder-binding/same-holder.js +2 -0
- package/dist/holder-binding/same-holder.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/jubjub.d.ts +3 -0
- package/dist/jubjub.d.ts.map +1 -0
- package/dist/jubjub.js +6 -0
- package/dist/jubjub.js.map +1 -0
- package/dist/managed/credentials/contract/index.d.ts +330 -0
- package/dist/managed/credentials/contract/index.js +2213 -0
- package/dist/managed/credentials/contract/index.js.map +8 -0
- package/dist/managed/same-holder/contract/index.d.ts +400 -0
- package/dist/managed/same-holder/contract/index.js +2688 -0
- package/dist/managed/same-holder/contract/index.js.map +8 -0
- package/package.json +113 -0
- package/src/credentials/bindings.compact +5 -0
- package/src/credentials/composable.compact +14 -0
- package/src/credentials/holder-bindings.compact +320 -0
- package/src/credentials/issue.compact +91 -0
- package/src/credentials/present.compact +84 -0
- package/src/credentials/proofs.compact +122 -0
- package/src/credentials/protocol-support.compact +7 -0
- package/src/credentials/protocols.compact +125 -0
- package/src/credentials/relations.compact +36 -0
- package/src/credentials/status-bindings.compact +60 -0
- package/src/credentials/types.compact +141 -0
- package/src/credentials/vc-support.compact +8 -0
- package/src/credentials/vc.compact +59 -0
- package/src/credentials/vp.compact +25 -0
- package/src/credentials.compact +20 -0
- package/src/holder-binding/same-holder/composable.compact +179 -0
- package/src/holder-binding/same-holder.compact +180 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 - RC2 supported prerelease
|
|
4
|
+
|
|
5
|
+
- Extracted curated family-neutral Compact VC/VP semantics from the internal
|
|
6
|
+
credentials package.
|
|
7
|
+
- Excluded verification-v1, authority contracts, family code, and private
|
|
8
|
+
proving/deployment material.
|
|
9
|
+
- Added audited same-holder standalone and composition-safe entrypoints.
|
|
10
|
+
- Promoted the package into the supported RC2 development surface.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @midnight-ntwrk/credential-compact
|
|
2
|
+
|
|
3
|
+
> Release stage: `supported`
|
|
4
|
+
> Maturity: `core`
|
|
5
|
+
> Package class: `dist`
|
|
6
|
+
|
|
7
|
+
Supported prerelease package for reusable, family-neutral Compact VC/VP
|
|
8
|
+
semantics. This is a library include surface, not a deployable contract,
|
|
9
|
+
credential family, proof artifact, or registry authority.
|
|
10
|
+
|
|
11
|
+
## Scope
|
|
12
|
+
|
|
13
|
+
The package contains generic VC/VP envelopes, schema references, issuer and
|
|
14
|
+
holder-binding shapes, proof/challenge primitives, issuance and presentation
|
|
15
|
+
message envelopes, VC-side status-binding shapes, and VC/VP linkage helpers.
|
|
16
|
+
`StatusRegistryRef` is vocabulary only: this package does not authenticate
|
|
17
|
+
registry mutation, roots, time, witnesses, or final non-membership.
|
|
18
|
+
|
|
19
|
+
`verification-v1`, family claims and predicates, status-registry authority,
|
|
20
|
+
proving/deployment artifacts, wallets, signing keys, witnesses, secrets, and
|
|
21
|
+
use-case code are deliberately excluded.
|
|
22
|
+
|
|
23
|
+
## Toolchain and generated output
|
|
24
|
+
|
|
25
|
+
The candidate is compiled and checked with the pinned Compact `0.30.0` compiler
|
|
26
|
+
and exactly `@midnight-ntwrk/compact-runtime` `0.15.0`. Builds fail before
|
|
27
|
+
generated output is accepted if either resolved version drifts. `src/managed` and
|
|
28
|
+
`dist` are generated during build and are not hand-edited.
|
|
29
|
+
`dist/compact-build.json` records the exact compiler/runtime tuple, source digest,
|
|
30
|
+
and generated-artifact digest.
|
|
31
|
+
|
|
32
|
+
Only `./credentials.compact` and `./holder-binding/same-holder.compact` are
|
|
33
|
+
standalone roots. `./holder-binding/same-holder/composable.compact` is an
|
|
34
|
+
explicit composition fragment: include `credentials/bindings` (or the full
|
|
35
|
+
`credentials` root) first, then include the fragment exactly once. The other
|
|
36
|
+
credential leaf modules remain packaged for internal composition but are not
|
|
37
|
+
advertised as standalone exports because they rely on declarations supplied by
|
|
38
|
+
the shared root.
|
|
39
|
+
|
|
40
|
+
The external consumer gate compiles both standalone roots and the composition
|
|
41
|
+
fragment, then runs positive and negative same-holder vectors (different holder
|
|
42
|
+
secret, challenge, and binding) against each generated contract. This is a pure
|
|
43
|
+
binding predicate and adds no family or business semantics.
|
|
44
|
+
|
|
45
|
+
## Compatibility and ownership
|
|
46
|
+
|
|
47
|
+
The old private `@midnight-ntwrk/midnight-did-credentials` package remains an
|
|
48
|
+
internal compatibility facade for one migration cycle and receives no new API.
|
|
49
|
+
The old same-holder package remains private and unchanged as a compatibility
|
|
50
|
+
implementation. Technical ownership is the VC package maintainers; support and
|
|
51
|
+
publication ownership remain unassigned until a separate graduation review.
|
|
52
|
+
ADR-0014 remains **Proposed**; this candidate records an implementation graph,
|
|
53
|
+
not normative ADR acceptance.
|
|
54
|
+
|
|
55
|
+
## Usage boundary
|
|
56
|
+
|
|
57
|
+
Consumers must use the package name and explicit exports, never repository
|
|
58
|
+
relative includes or `src`/`managed` paths. Candidate tarball and clean-consumer
|
|
59
|
+
checks compile every advertised Compact entrypoint outside this repository.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": 1,
|
|
3
|
+
"compiler": "0.30.0",
|
|
4
|
+
"runtime": {
|
|
5
|
+
"name": "@midnight-ntwrk/compact-runtime",
|
|
6
|
+
"version": "0.15.0"
|
|
7
|
+
},
|
|
8
|
+
"sourceDigest": "5543655b0f1f0e0d9524120811a7bf82d68d93190b14b56a37845446031d3439",
|
|
9
|
+
"artifactDigest": "e33d5b53bfccf195e8ed955bc80c87277b21e5bd5f03a7856a10855c160255b6",
|
|
10
|
+
"sourceFiles": [
|
|
11
|
+
"src/credentials/bindings.compact",
|
|
12
|
+
"src/credentials/composable.compact",
|
|
13
|
+
"src/credentials/holder-bindings.compact",
|
|
14
|
+
"src/credentials/issue.compact",
|
|
15
|
+
"src/credentials/present.compact",
|
|
16
|
+
"src/credentials/proofs.compact",
|
|
17
|
+
"src/credentials/protocol-support.compact",
|
|
18
|
+
"src/credentials/protocols.compact",
|
|
19
|
+
"src/credentials/relations.compact",
|
|
20
|
+
"src/credentials/status-bindings.compact",
|
|
21
|
+
"src/credentials/types.compact",
|
|
22
|
+
"src/credentials/vc-support.compact",
|
|
23
|
+
"src/credentials/vc.compact",
|
|
24
|
+
"src/credentials/vp.compact",
|
|
25
|
+
"src/credentials.compact",
|
|
26
|
+
"src/holder-binding/same-holder/composable.compact",
|
|
27
|
+
"src/holder-binding/same-holder.compact"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAC"}
|
package/dist/contract.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAC","sourcesContent":["export * from \"./managed/credentials/contract/index.js\";\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Composition-safe shared root for Layer 3 contracts and credential-family
|
|
2
|
+
// entrypoints. This file includes the leaf modules directly because Compact
|
|
3
|
+
// does not deduplicate repeated includes across intermediate entry points.
|
|
4
|
+
|
|
5
|
+
include "./types";
|
|
6
|
+
include "./proofs";
|
|
7
|
+
include "./vc";
|
|
8
|
+
include "./vp";
|
|
9
|
+
include "./relations";
|
|
10
|
+
include "./holder-bindings";
|
|
11
|
+
include "./protocols";
|
|
12
|
+
include "./issue";
|
|
13
|
+
include "./present";
|
|
14
|
+
include "./status-bindings";
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
// Holder-binding and holder-witness primitives.
|
|
2
|
+
// This file groups the reusable binding checks for explicit DID, Jubjub,
|
|
3
|
+
// offchain DID, secret-holder, and blinded-secret-holder profiles.
|
|
4
|
+
// =====================
|
|
5
|
+
// Explicit and Jubjub-backed holder bindings
|
|
6
|
+
// =====================
|
|
7
|
+
export pure circuit assertValidExplicitHolderBinding(
|
|
8
|
+
binding: ExplicitHolderBinding
|
|
9
|
+
): [] {
|
|
10
|
+
assert(
|
|
11
|
+
binding.holderVerificationMethodRef.didContractAddress.bytes != pad(32, ""),
|
|
12
|
+
"Explicit holder binding DID contract address must be set"
|
|
13
|
+
);
|
|
14
|
+
assert(
|
|
15
|
+
binding.holderVerificationMethodRef.methodId != pad(32, ""),
|
|
16
|
+
"Explicit holder binding method reference must be set"
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export pure circuit assertMatchingExplicitHolderBindings(
|
|
21
|
+
credentialBinding: ExplicitHolderBinding,
|
|
22
|
+
presentationBinding: ExplicitHolderBinding
|
|
23
|
+
): [] {
|
|
24
|
+
assert(
|
|
25
|
+
presentationBinding.holderVerificationMethodRef.didContractAddress
|
|
26
|
+
== credentialBinding.holderVerificationMethodRef.didContractAddress,
|
|
27
|
+
"Presentation holder contract does not match credential holder binding"
|
|
28
|
+
);
|
|
29
|
+
assert(
|
|
30
|
+
presentationBinding.holderVerificationMethodRef.methodId
|
|
31
|
+
== credentialBinding.holderVerificationMethodRef.methodId,
|
|
32
|
+
"Presentation holder method reference does not match credential holder binding"
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export pure circuit assertProofMatchesExplicitHolderBinding(
|
|
37
|
+
binding: ExplicitHolderBinding,
|
|
38
|
+
presentationProof: Proof
|
|
39
|
+
): [] {
|
|
40
|
+
assert(
|
|
41
|
+
binding.holderVerificationMethodRef.didContractAddress
|
|
42
|
+
== presentationProof.signerVerificationMethodRef.didContractAddress,
|
|
43
|
+
"Presentation proof signer must match holder binding"
|
|
44
|
+
);
|
|
45
|
+
assert(
|
|
46
|
+
binding.holderVerificationMethodRef.methodId
|
|
47
|
+
== presentationProof.signerVerificationMethodRef.methodId,
|
|
48
|
+
"Presentation proof signer method reference must match holder binding"
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export pure circuit assertValidJubjubHolderBinding(
|
|
53
|
+
binding: JubjubHolderBinding
|
|
54
|
+
): [] {
|
|
55
|
+
// This is only a sentinel check that the binding is populated.
|
|
56
|
+
// The helper remains useful for the legacy compatibility profile and as a
|
|
57
|
+
// building block inside richer DID-shaped bindings.
|
|
58
|
+
// Callers still need assertValidPresentationContextProof(...) or an
|
|
59
|
+
// equivalent proof verification path to establish proof-of-possession.
|
|
60
|
+
assert(
|
|
61
|
+
jubjubPointX(binding.holderPublicKey) != 0 as Field ||
|
|
62
|
+
jubjubPointY(binding.holderPublicKey) != 0 as Field,
|
|
63
|
+
"Jubjub holder binding public key must be set"
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export pure circuit assertMatchingJubjubHolderBindings(
|
|
68
|
+
credentialBinding: JubjubHolderBinding,
|
|
69
|
+
presentationBinding: JubjubHolderBinding
|
|
70
|
+
): [] {
|
|
71
|
+
assert(
|
|
72
|
+
jubjubPointX(presentationBinding.holderPublicKey)
|
|
73
|
+
== jubjubPointX(credentialBinding.holderPublicKey) &&
|
|
74
|
+
jubjubPointY(presentationBinding.holderPublicKey)
|
|
75
|
+
== jubjubPointY(credentialBinding.holderPublicKey),
|
|
76
|
+
"Presentation Jubjub holder key does not match the credential holder binding"
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export pure circuit assertProofMatchesJubjubHolderBinding(
|
|
81
|
+
binding: JubjubHolderBinding,
|
|
82
|
+
presentationProof: Proof
|
|
83
|
+
): [] {
|
|
84
|
+
assert(
|
|
85
|
+
jubjubPointX(binding.holderPublicKey)
|
|
86
|
+
== jubjubPointX(presentationProof.publicKey) &&
|
|
87
|
+
jubjubPointY(binding.holderPublicKey)
|
|
88
|
+
== jubjubPointY(presentationProof.publicKey),
|
|
89
|
+
"Presentation proof public key must match the Jubjub holder binding"
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export pure circuit assertValidOffchainMidnightHolderBinding(
|
|
94
|
+
binding: OffchainMidnightHolderBinding
|
|
95
|
+
): [] {
|
|
96
|
+
// This validates presence and consistency only for the preferred lightweight
|
|
97
|
+
// DID-shaped offchain profile.
|
|
98
|
+
// It does not prove that holderPublicKey is the verification method
|
|
99
|
+
// published under holderMethodId in the referenced offchain DID state.
|
|
100
|
+
assert(
|
|
101
|
+
binding.holderDidStateHash != pad(32, ""),
|
|
102
|
+
"Offchain Midnight holder state hash must be set"
|
|
103
|
+
);
|
|
104
|
+
assert(
|
|
105
|
+
binding.holderMethodId != pad(32, ""),
|
|
106
|
+
"Offchain Midnight holder method id must be set"
|
|
107
|
+
);
|
|
108
|
+
const jubjubBinding: JubjubHolderBinding = JubjubHolderBinding {
|
|
109
|
+
holderPublicKey: binding.holderPublicKey
|
|
110
|
+
};
|
|
111
|
+
assertValidJubjubHolderBinding(jubjubBinding);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export pure circuit assertMatchingOffchainMidnightHolderBindings(
|
|
115
|
+
credentialBinding: OffchainMidnightHolderBinding,
|
|
116
|
+
presentationBinding: OffchainMidnightHolderBinding
|
|
117
|
+
): [] {
|
|
118
|
+
assert(
|
|
119
|
+
presentationBinding.holderDidStateHash
|
|
120
|
+
== credentialBinding.holderDidStateHash,
|
|
121
|
+
"Offchain Midnight holder state hash does not match the credential holder binding"
|
|
122
|
+
);
|
|
123
|
+
assert(
|
|
124
|
+
presentationBinding.holderMethodId
|
|
125
|
+
== credentialBinding.holderMethodId,
|
|
126
|
+
"Offchain Midnight holder method id does not match the credential holder binding"
|
|
127
|
+
);
|
|
128
|
+
const credentialJubjubBinding: JubjubHolderBinding = JubjubHolderBinding {
|
|
129
|
+
holderPublicKey: credentialBinding.holderPublicKey
|
|
130
|
+
};
|
|
131
|
+
const presentationJubjubBinding: JubjubHolderBinding = JubjubHolderBinding {
|
|
132
|
+
holderPublicKey: presentationBinding.holderPublicKey
|
|
133
|
+
};
|
|
134
|
+
assertMatchingJubjubHolderBindings(
|
|
135
|
+
credentialJubjubBinding,
|
|
136
|
+
presentationJubjubBinding
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export pure circuit assertProofMatchesOffchainMidnightHolderBinding(
|
|
141
|
+
binding: OffchainMidnightHolderBinding,
|
|
142
|
+
presentationProof: Proof
|
|
143
|
+
): [] {
|
|
144
|
+
const jubjubBinding: JubjubHolderBinding = JubjubHolderBinding {
|
|
145
|
+
holderPublicKey: binding.holderPublicKey
|
|
146
|
+
};
|
|
147
|
+
assertProofMatchesJubjubHolderBinding(jubjubBinding, presentationProof);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// =====================
|
|
151
|
+
// Secret-holder bindings and derived pseudonyms
|
|
152
|
+
// =====================
|
|
153
|
+
export pure circuit noSecretHolderChallengeResponse(): Bytes<32> {
|
|
154
|
+
return pad(32, "midnight:vc:no-holder-response");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export pure circuit secretHolderBindingCommitment(
|
|
158
|
+
holderSecret: Bytes<32>,
|
|
159
|
+
opening: Bytes<32>
|
|
160
|
+
): Bytes<32> {
|
|
161
|
+
return persistentCommit<Bytes<32>>(holderSecret, opening);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export pure circuit secretHolderBindingChallengeResponse(
|
|
165
|
+
holderSecret: Bytes<32>,
|
|
166
|
+
verifierChallengeHash: Bytes<32>
|
|
167
|
+
): Bytes<32> {
|
|
168
|
+
return persistentHash<Vector<3, Bytes<32>>>([
|
|
169
|
+
pad(32, "midnight:vc:holder-chall"),
|
|
170
|
+
holderSecret,
|
|
171
|
+
verifierChallengeHash
|
|
172
|
+
]);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export pure circuit verifierScopedPseudonym(
|
|
176
|
+
holderSecret: Bytes<32>,
|
|
177
|
+
verifierDomainHash: Bytes<32>
|
|
178
|
+
): Bytes<32> {
|
|
179
|
+
return persistentHash<Vector<3, Bytes<32>>>([
|
|
180
|
+
pad(32, "midnight:vc:holder-pseudonym"),
|
|
181
|
+
holderSecret,
|
|
182
|
+
verifierDomainHash
|
|
183
|
+
]);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export pure circuit assertVerifierScopedPseudonym(
|
|
187
|
+
pseudonym: Bytes<32>,
|
|
188
|
+
holderSecret: Bytes<32>,
|
|
189
|
+
verifierDomainHash: Bytes<32>
|
|
190
|
+
): [] {
|
|
191
|
+
assert(
|
|
192
|
+
pseudonym == verifierScopedPseudonym(holderSecret, verifierDomainHash),
|
|
193
|
+
"Verifier-scoped pseudonym does not match the holder secret and verifier domain"
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export pure circuit blindedSecretHolderCommitment(
|
|
198
|
+
holderSecretCommitment: Bytes<32>,
|
|
199
|
+
issuerNonce: Bytes<32>,
|
|
200
|
+
blindingFactor: Bytes<32>
|
|
201
|
+
): Bytes<32> {
|
|
202
|
+
// NOTE: This remains a hash-based compatibility commitment today. The
|
|
203
|
+
// breaking `persistentCommit` migration is tracked separately and should not
|
|
204
|
+
// be rolled in silently with source-style or purity cleanups.
|
|
205
|
+
return persistentHash<Vector<4, Bytes<32>>>([
|
|
206
|
+
pad(32, "midnight:vc:blind-holder"),
|
|
207
|
+
holderSecretCommitment,
|
|
208
|
+
issuerNonce,
|
|
209
|
+
blindingFactor
|
|
210
|
+
]);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export pure circuit assertValidSecretHolderCredentialBinding(
|
|
214
|
+
binding: SecretHolderBinding
|
|
215
|
+
): [] {
|
|
216
|
+
assert(
|
|
217
|
+
binding.requestChallengeResponse == noSecretHolderChallengeResponse(),
|
|
218
|
+
"Credential secret holder binding must not embed a request challenge response"
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export pure circuit assertValidSecretHolderPresentationBinding(
|
|
223
|
+
binding: SecretHolderBinding
|
|
224
|
+
): [] {
|
|
225
|
+
assert(
|
|
226
|
+
binding.requestChallengeResponse != noSecretHolderChallengeResponse(),
|
|
227
|
+
"Presentation secret holder binding must include a request challenge response"
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export pure circuit assertMatchingSecretHolderBindings(
|
|
232
|
+
credentialBinding: SecretHolderBinding,
|
|
233
|
+
presentationBinding: SecretHolderBinding
|
|
234
|
+
): [] {
|
|
235
|
+
assert(
|
|
236
|
+
credentialBinding.holderSecretCommitment == presentationBinding.holderSecretCommitment,
|
|
237
|
+
"Presentation holder secret commitment does not match the credential holder binding"
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export pure circuit assertValidBlindedSecretHolderCredentialBinding(
|
|
242
|
+
binding: BlindedSecretHolderBinding
|
|
243
|
+
): [] {
|
|
244
|
+
assert(
|
|
245
|
+
binding.requestChallengeResponse == noSecretHolderChallengeResponse(),
|
|
246
|
+
"Credential blinded holder binding must not embed a request challenge response"
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export pure circuit assertValidBlindedSecretHolderPresentationBinding(
|
|
251
|
+
binding: BlindedSecretHolderBinding
|
|
252
|
+
): [] {
|
|
253
|
+
assert(
|
|
254
|
+
binding.requestChallengeResponse != noSecretHolderChallengeResponse(),
|
|
255
|
+
"Presentation blinded holder binding must include a request challenge response"
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export pure circuit assertMatchingBlindedSecretHolderBindings(
|
|
260
|
+
credentialBinding: BlindedSecretHolderBinding,
|
|
261
|
+
presentationBinding: BlindedSecretHolderBinding
|
|
262
|
+
): [] {
|
|
263
|
+
assert(
|
|
264
|
+
credentialBinding.blindedHolderSecretCommitment
|
|
265
|
+
== presentationBinding.blindedHolderSecretCommitment,
|
|
266
|
+
"Presentation blinded holder commitment does not match the credential holder binding"
|
|
267
|
+
);
|
|
268
|
+
assert(
|
|
269
|
+
credentialBinding.issuerNonce == presentationBinding.issuerNonce,
|
|
270
|
+
"Presentation issuer nonce does not match the credential holder binding"
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// =====================
|
|
275
|
+
// Witness validation and recomputation helpers
|
|
276
|
+
// =====================
|
|
277
|
+
// NOTE: these helpers validate caller-supplied witness material passed as
|
|
278
|
+
// ordinary parameters. They do not perform Compact `witness` reads themselves.
|
|
279
|
+
export pure circuit assertSecretHolderBindingWitness(
|
|
280
|
+
binding: SecretHolderBinding,
|
|
281
|
+
verifierChallengeHash: Bytes<32>,
|
|
282
|
+
holderSecret: Bytes<32>,
|
|
283
|
+
opening: Bytes<32>
|
|
284
|
+
): [] {
|
|
285
|
+
assert(
|
|
286
|
+
secretHolderBindingCommitment(holderSecret, opening) == binding.holderSecretCommitment,
|
|
287
|
+
"Holder secret witness does not match the holder-binding commitment"
|
|
288
|
+
);
|
|
289
|
+
assert(
|
|
290
|
+
secretHolderBindingChallengeResponse(holderSecret, verifierChallengeHash)
|
|
291
|
+
== binding.requestChallengeResponse,
|
|
292
|
+
"Holder secret challenge response does not match the verifier challenge"
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export pure circuit assertBlindedSecretHolderBindingWitness(
|
|
297
|
+
binding: BlindedSecretHolderBinding,
|
|
298
|
+
verifierChallengeHash: Bytes<32>,
|
|
299
|
+
holderSecret: Bytes<32>,
|
|
300
|
+
opening: Bytes<32>,
|
|
301
|
+
blindingFactor: Bytes<32>
|
|
302
|
+
): [] {
|
|
303
|
+
const holderCommitment: Bytes<32> = secretHolderBindingCommitment(
|
|
304
|
+
holderSecret,
|
|
305
|
+
opening
|
|
306
|
+
);
|
|
307
|
+
assert(
|
|
308
|
+
blindedSecretHolderCommitment(
|
|
309
|
+
holderCommitment,
|
|
310
|
+
binding.issuerNonce,
|
|
311
|
+
blindingFactor
|
|
312
|
+
) == binding.blindedHolderSecretCommitment,
|
|
313
|
+
"Blinded holder commitment does not match the hidden holder secret witness"
|
|
314
|
+
);
|
|
315
|
+
assert(
|
|
316
|
+
secretHolderBindingChallengeResponse(holderSecret, verifierChallengeHash)
|
|
317
|
+
== binding.requestChallengeResponse,
|
|
318
|
+
"Blinded holder challenge response does not match the verifier challenge"
|
|
319
|
+
);
|
|
320
|
+
}
|