@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.
Files changed (61) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +201 -0
  3. package/README.md +59 -0
  4. package/dist/compact-build.json +29 -0
  5. package/dist/contract.d.ts +2 -0
  6. package/dist/contract.d.ts.map +1 -0
  7. package/dist/contract.js +2 -0
  8. package/dist/contract.js.map +1 -0
  9. package/dist/credentials/bindings.compact +5 -0
  10. package/dist/credentials/composable.compact +14 -0
  11. package/dist/credentials/holder-bindings.compact +320 -0
  12. package/dist/credentials/issue.compact +91 -0
  13. package/dist/credentials/present.compact +84 -0
  14. package/dist/credentials/proofs.compact +122 -0
  15. package/dist/credentials/protocol-support.compact +7 -0
  16. package/dist/credentials/protocols.compact +125 -0
  17. package/dist/credentials/relations.compact +36 -0
  18. package/dist/credentials/status-bindings.compact +60 -0
  19. package/dist/credentials/types.compact +141 -0
  20. package/dist/credentials/vc-support.compact +8 -0
  21. package/dist/credentials/vc.compact +59 -0
  22. package/dist/credentials/vp.compact +25 -0
  23. package/dist/credentials.compact +20 -0
  24. package/dist/holder-binding/same-holder/composable.compact +179 -0
  25. package/dist/holder-binding/same-holder.compact +180 -0
  26. package/dist/holder-binding/same-holder.d.ts +2 -0
  27. package/dist/holder-binding/same-holder.d.ts.map +1 -0
  28. package/dist/holder-binding/same-holder.js +2 -0
  29. package/dist/holder-binding/same-holder.js.map +1 -0
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +3 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/jubjub.d.ts +3 -0
  35. package/dist/jubjub.d.ts.map +1 -0
  36. package/dist/jubjub.js +6 -0
  37. package/dist/jubjub.js.map +1 -0
  38. package/dist/managed/credentials/contract/index.d.ts +330 -0
  39. package/dist/managed/credentials/contract/index.js +2213 -0
  40. package/dist/managed/credentials/contract/index.js.map +8 -0
  41. package/dist/managed/same-holder/contract/index.d.ts +400 -0
  42. package/dist/managed/same-holder/contract/index.js +2688 -0
  43. package/dist/managed/same-holder/contract/index.js.map +8 -0
  44. package/package.json +113 -0
  45. package/src/credentials/bindings.compact +5 -0
  46. package/src/credentials/composable.compact +14 -0
  47. package/src/credentials/holder-bindings.compact +320 -0
  48. package/src/credentials/issue.compact +91 -0
  49. package/src/credentials/present.compact +84 -0
  50. package/src/credentials/proofs.compact +122 -0
  51. package/src/credentials/protocol-support.compact +7 -0
  52. package/src/credentials/protocols.compact +125 -0
  53. package/src/credentials/relations.compact +36 -0
  54. package/src/credentials/status-bindings.compact +60 -0
  55. package/src/credentials/types.compact +141 -0
  56. package/src/credentials/vc-support.compact +8 -0
  57. package/src/credentials/vc.compact +59 -0
  58. package/src/credentials/vp.compact +25 -0
  59. package/src/credentials.compact +20 -0
  60. package/src/holder-binding/same-holder/composable.compact +179 -0
  61. package/src/holder-binding/same-holder.compact +180 -0
@@ -0,0 +1,179 @@
1
+ // This file is part of midnightntwrk/midnight-did.
2
+ // Copyright (C) 2026 Midnight Foundation
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+
16
+ // Composition-safe entry point for Layer 3 contracts. The importing contract
17
+ // must include `credentials/bindings` or
18
+ // `credentials/composable` before including this file.
19
+
20
+
21
+ // Capability package: prove that multiple holder bindings are satisfied by the
22
+ // same hidden holder secret witness under one verifier session challenge.
23
+
24
+ export pure circuit assertSameSecretHolderBindingWitnesses(
25
+ firstBinding: SecretHolderBinding,
26
+ secondBinding: SecretHolderBinding,
27
+ verifierChallengeHash: Bytes<32>,
28
+ holderSecret: Bytes<32>,
29
+ firstOpening: Bytes<32>,
30
+ secondOpening: Bytes<32>
31
+ ): [] {
32
+ assert(
33
+ firstBinding.holderSecretCommitment != secondBinding.holderSecretCommitment,
34
+ "Same-holder proof requires two distinct credential bindings"
35
+ );
36
+ assertSecretHolderBindingWitness(
37
+ firstBinding,
38
+ verifierChallengeHash,
39
+ holderSecret,
40
+ firstOpening
41
+ );
42
+ assertSecretHolderBindingWitness(
43
+ secondBinding,
44
+ verifierChallengeHash,
45
+ holderSecret,
46
+ secondOpening
47
+ );
48
+ }
49
+
50
+ // Three-credential same-holder composition for plain secret bindings.
51
+ // This keeps the reusable capability explicit and bounded instead of
52
+ // prematurely introducing a generic "bundle" abstraction.
53
+ export pure circuit assertSameSecretHolderBindingWitnesses3(
54
+ firstBinding: SecretHolderBinding,
55
+ secondBinding: SecretHolderBinding,
56
+ thirdBinding: SecretHolderBinding,
57
+ verifierChallengeHash: Bytes<32>,
58
+ holderSecret: Bytes<32>,
59
+ firstOpening: Bytes<32>,
60
+ secondOpening: Bytes<32>,
61
+ thirdOpening: Bytes<32>
62
+ ): [] {
63
+ assert(
64
+ firstBinding.holderSecretCommitment != secondBinding.holderSecretCommitment,
65
+ "Same-holder proof requires distinct first and second credential bindings"
66
+ );
67
+ assert(
68
+ firstBinding.holderSecretCommitment != thirdBinding.holderSecretCommitment,
69
+ "Same-holder proof requires distinct first and third credential bindings"
70
+ );
71
+ assert(
72
+ secondBinding.holderSecretCommitment != thirdBinding.holderSecretCommitment,
73
+ "Same-holder proof requires distinct second and third credential bindings"
74
+ );
75
+
76
+ assertSecretHolderBindingWitness(
77
+ firstBinding,
78
+ verifierChallengeHash,
79
+ holderSecret,
80
+ firstOpening
81
+ );
82
+ assertSecretHolderBindingWitness(
83
+ secondBinding,
84
+ verifierChallengeHash,
85
+ holderSecret,
86
+ secondOpening
87
+ );
88
+ assertSecretHolderBindingWitness(
89
+ thirdBinding,
90
+ verifierChallengeHash,
91
+ holderSecret,
92
+ thirdOpening
93
+ );
94
+ }
95
+
96
+ // Same-holder composition for blinded bindings. The caller supplies the same
97
+ // hidden holder witness together with the binding-specific opening and blinding
98
+ // factor for each independently issued credential.
99
+ export pure circuit assertSameBlindedSecretHolderBindingWitnesses(
100
+ firstBinding: BlindedSecretHolderBinding,
101
+ secondBinding: BlindedSecretHolderBinding,
102
+ verifierChallengeHash: Bytes<32>,
103
+ holderSecret: Bytes<32>,
104
+ firstOpening: Bytes<32>,
105
+ firstBlindingFactor: Bytes<32>,
106
+ secondOpening: Bytes<32>,
107
+ secondBlindingFactor: Bytes<32>
108
+ ): [] {
109
+ assert(
110
+ firstBinding.blindedHolderSecretCommitment != secondBinding.blindedHolderSecretCommitment,
111
+ "Same-holder proof requires two distinct credential bindings"
112
+ );
113
+ assertBlindedSecretHolderBindingWitness(
114
+ firstBinding,
115
+ verifierChallengeHash,
116
+ holderSecret,
117
+ firstOpening,
118
+ firstBlindingFactor
119
+ );
120
+ assertBlindedSecretHolderBindingWitness(
121
+ secondBinding,
122
+ verifierChallengeHash,
123
+ holderSecret,
124
+ secondOpening,
125
+ secondBlindingFactor
126
+ );
127
+ }
128
+
129
+ // Three-credential same-holder composition for blinded bindings. This is the
130
+ // next bounded step after the two-credential primitive and is sufficient for
131
+ // staged business flows such as travel or onboarding checks.
132
+ export pure circuit assertSameBlindedSecretHolderBindingWitnesses3(
133
+ firstBinding: BlindedSecretHolderBinding,
134
+ secondBinding: BlindedSecretHolderBinding,
135
+ thirdBinding: BlindedSecretHolderBinding,
136
+ verifierChallengeHash: Bytes<32>,
137
+ holderSecret: Bytes<32>,
138
+ firstOpening: Bytes<32>,
139
+ firstBlindingFactor: Bytes<32>,
140
+ secondOpening: Bytes<32>,
141
+ secondBlindingFactor: Bytes<32>,
142
+ thirdOpening: Bytes<32>,
143
+ thirdBlindingFactor: Bytes<32>
144
+ ): [] {
145
+ assert(
146
+ firstBinding.blindedHolderSecretCommitment != secondBinding.blindedHolderSecretCommitment,
147
+ "Same-holder proof requires distinct first and second credential bindings"
148
+ );
149
+ assert(
150
+ firstBinding.blindedHolderSecretCommitment != thirdBinding.blindedHolderSecretCommitment,
151
+ "Same-holder proof requires distinct first and third credential bindings"
152
+ );
153
+ assert(
154
+ secondBinding.blindedHolderSecretCommitment != thirdBinding.blindedHolderSecretCommitment,
155
+ "Same-holder proof requires distinct second and third credential bindings"
156
+ );
157
+
158
+ assertBlindedSecretHolderBindingWitness(
159
+ firstBinding,
160
+ verifierChallengeHash,
161
+ holderSecret,
162
+ firstOpening,
163
+ firstBlindingFactor
164
+ );
165
+ assertBlindedSecretHolderBindingWitness(
166
+ secondBinding,
167
+ verifierChallengeHash,
168
+ holderSecret,
169
+ secondOpening,
170
+ secondBlindingFactor
171
+ );
172
+ assertBlindedSecretHolderBindingWitness(
173
+ thirdBinding,
174
+ verifierChallengeHash,
175
+ holderSecret,
176
+ thirdOpening,
177
+ thirdBlindingFactor
178
+ );
179
+ }
@@ -0,0 +1,180 @@
1
+ // This file is part of midnightntwrk/midnight-did.
2
+ // Copyright (C) 2026 Midnight Foundation
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+
16
+ pragma language_version >= 0.20;
17
+
18
+ import CompactStandardLibrary;
19
+
20
+ include "../credentials";
21
+
22
+ // Capability package: prove that multiple holder bindings are satisfied by the
23
+ // same hidden holder secret witness under one verifier session challenge.
24
+
25
+ export pure circuit assertSameSecretHolderBindingWitnesses(
26
+ firstBinding: SecretHolderBinding,
27
+ secondBinding: SecretHolderBinding,
28
+ verifierChallengeHash: Bytes<32>,
29
+ holderSecret: Bytes<32>,
30
+ firstOpening: Bytes<32>,
31
+ secondOpening: Bytes<32>
32
+ ): [] {
33
+ assert(
34
+ firstBinding.holderSecretCommitment != secondBinding.holderSecretCommitment,
35
+ "Same-holder proof requires two distinct credential bindings"
36
+ );
37
+ assertSecretHolderBindingWitness(
38
+ firstBinding,
39
+ verifierChallengeHash,
40
+ holderSecret,
41
+ firstOpening
42
+ );
43
+ assertSecretHolderBindingWitness(
44
+ secondBinding,
45
+ verifierChallengeHash,
46
+ holderSecret,
47
+ secondOpening
48
+ );
49
+ }
50
+
51
+ // Three-credential same-holder composition for plain secret bindings.
52
+ // This keeps the reusable capability explicit and bounded instead of
53
+ // prematurely introducing a generic "bundle" abstraction.
54
+ export pure circuit assertSameSecretHolderBindingWitnesses3(
55
+ firstBinding: SecretHolderBinding,
56
+ secondBinding: SecretHolderBinding,
57
+ thirdBinding: SecretHolderBinding,
58
+ verifierChallengeHash: Bytes<32>,
59
+ holderSecret: Bytes<32>,
60
+ firstOpening: Bytes<32>,
61
+ secondOpening: Bytes<32>,
62
+ thirdOpening: Bytes<32>
63
+ ): [] {
64
+ assert(
65
+ firstBinding.holderSecretCommitment != secondBinding.holderSecretCommitment,
66
+ "Same-holder proof requires distinct first and second credential bindings"
67
+ );
68
+ assert(
69
+ firstBinding.holderSecretCommitment != thirdBinding.holderSecretCommitment,
70
+ "Same-holder proof requires distinct first and third credential bindings"
71
+ );
72
+ assert(
73
+ secondBinding.holderSecretCommitment != thirdBinding.holderSecretCommitment,
74
+ "Same-holder proof requires distinct second and third credential bindings"
75
+ );
76
+
77
+ assertSecretHolderBindingWitness(
78
+ firstBinding,
79
+ verifierChallengeHash,
80
+ holderSecret,
81
+ firstOpening
82
+ );
83
+ assertSecretHolderBindingWitness(
84
+ secondBinding,
85
+ verifierChallengeHash,
86
+ holderSecret,
87
+ secondOpening
88
+ );
89
+ assertSecretHolderBindingWitness(
90
+ thirdBinding,
91
+ verifierChallengeHash,
92
+ holderSecret,
93
+ thirdOpening
94
+ );
95
+ }
96
+
97
+ // Same-holder composition for blinded bindings. The caller supplies the same
98
+ // hidden holder witness together with the binding-specific opening and blinding
99
+ // factor for each independently issued credential.
100
+ export pure circuit assertSameBlindedSecretHolderBindingWitnesses(
101
+ firstBinding: BlindedSecretHolderBinding,
102
+ secondBinding: BlindedSecretHolderBinding,
103
+ verifierChallengeHash: Bytes<32>,
104
+ holderSecret: Bytes<32>,
105
+ firstOpening: Bytes<32>,
106
+ firstBlindingFactor: Bytes<32>,
107
+ secondOpening: Bytes<32>,
108
+ secondBlindingFactor: Bytes<32>
109
+ ): [] {
110
+ assert(
111
+ firstBinding.blindedHolderSecretCommitment != secondBinding.blindedHolderSecretCommitment,
112
+ "Same-holder proof requires two distinct credential bindings"
113
+ );
114
+ assertBlindedSecretHolderBindingWitness(
115
+ firstBinding,
116
+ verifierChallengeHash,
117
+ holderSecret,
118
+ firstOpening,
119
+ firstBlindingFactor
120
+ );
121
+ assertBlindedSecretHolderBindingWitness(
122
+ secondBinding,
123
+ verifierChallengeHash,
124
+ holderSecret,
125
+ secondOpening,
126
+ secondBlindingFactor
127
+ );
128
+ }
129
+
130
+ // Three-credential same-holder composition for blinded bindings. This is the
131
+ // next bounded step after the two-credential primitive and is sufficient for
132
+ // staged business flows such as travel or onboarding checks.
133
+ export pure circuit assertSameBlindedSecretHolderBindingWitnesses3(
134
+ firstBinding: BlindedSecretHolderBinding,
135
+ secondBinding: BlindedSecretHolderBinding,
136
+ thirdBinding: BlindedSecretHolderBinding,
137
+ verifierChallengeHash: Bytes<32>,
138
+ holderSecret: Bytes<32>,
139
+ firstOpening: Bytes<32>,
140
+ firstBlindingFactor: Bytes<32>,
141
+ secondOpening: Bytes<32>,
142
+ secondBlindingFactor: Bytes<32>,
143
+ thirdOpening: Bytes<32>,
144
+ thirdBlindingFactor: Bytes<32>
145
+ ): [] {
146
+ assert(
147
+ firstBinding.blindedHolderSecretCommitment != secondBinding.blindedHolderSecretCommitment,
148
+ "Same-holder proof requires distinct first and second credential bindings"
149
+ );
150
+ assert(
151
+ firstBinding.blindedHolderSecretCommitment != thirdBinding.blindedHolderSecretCommitment,
152
+ "Same-holder proof requires distinct first and third credential bindings"
153
+ );
154
+ assert(
155
+ secondBinding.blindedHolderSecretCommitment != thirdBinding.blindedHolderSecretCommitment,
156
+ "Same-holder proof requires distinct second and third credential bindings"
157
+ );
158
+
159
+ assertBlindedSecretHolderBindingWitness(
160
+ firstBinding,
161
+ verifierChallengeHash,
162
+ holderSecret,
163
+ firstOpening,
164
+ firstBlindingFactor
165
+ );
166
+ assertBlindedSecretHolderBindingWitness(
167
+ secondBinding,
168
+ verifierChallengeHash,
169
+ holderSecret,
170
+ secondOpening,
171
+ secondBlindingFactor
172
+ );
173
+ assertBlindedSecretHolderBindingWitness(
174
+ thirdBinding,
175
+ verifierChallengeHash,
176
+ holderSecret,
177
+ thirdOpening,
178
+ thirdBlindingFactor
179
+ );
180
+ }