@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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Thin VC envelope surface.
|
|
2
|
+
// Owns credential-local structure, body-root derivation, and issuer-proof
|
|
3
|
+
// verification. Family-specific claim validation stays outside this module.
|
|
4
|
+
module VC<TPublicClaims, TClaimCommitments, THolderBinding, TStatusBinding> {
|
|
5
|
+
export struct Credential {
|
|
6
|
+
version: Uint<16>,
|
|
7
|
+
schema: SchemaRef,
|
|
8
|
+
issuerVerificationMethodRef: VerificationMethodRef,
|
|
9
|
+
holderBinding: THolderBinding,
|
|
10
|
+
statusBinding: TStatusBinding,
|
|
11
|
+
issuedAt: Uint<64>,
|
|
12
|
+
hasExpiration: Boolean,
|
|
13
|
+
expiresAt: Uint<64>,
|
|
14
|
+
// Direct values intentionally carried in the signed credential body.
|
|
15
|
+
claims: TPublicClaims,
|
|
16
|
+
// Commitment digests for private and predicate-only claim values.
|
|
17
|
+
claimCommitments: TClaimCommitments,
|
|
18
|
+
claimRoot: Bytes<32>,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export pure circuit credentialBodyRoot(credential: Credential): Bytes<32> {
|
|
22
|
+
return persistentHash<Credential>(credential);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export pure circuit assertValidCredentialEnvelope(
|
|
26
|
+
credential: Credential,
|
|
27
|
+
expectedClaimRoot: Bytes<32>
|
|
28
|
+
): [] {
|
|
29
|
+
assert(credential.version == 1, "Credential version mismatch");
|
|
30
|
+
assert(credential.claimRoot == expectedClaimRoot, "Credential claim root mismatch");
|
|
31
|
+
if (credential.hasExpiration) {
|
|
32
|
+
assert(credential.expiresAt >= credential.issuedAt, "Expiration must not precede issuance");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export pure circuit assertValidCredentialProof(
|
|
37
|
+
credential: Credential,
|
|
38
|
+
proof: Proof
|
|
39
|
+
): [] {
|
|
40
|
+
const bodyRoot: Bytes<32> = credentialBodyRoot(credential);
|
|
41
|
+
assertValidCredentialProofForBodyRoot(credential, proof, bodyRoot);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export pure circuit assertValidCredentialProofForBodyRoot(
|
|
45
|
+
credential: Credential,
|
|
46
|
+
proof: Proof,
|
|
47
|
+
bodyRoot: Bytes<32>
|
|
48
|
+
): [] {
|
|
49
|
+
assert(
|
|
50
|
+
credential.issuerVerificationMethodRef.didContractAddress == proof.signerVerificationMethodRef.didContractAddress,
|
|
51
|
+
"Issuer proof contract address does not match issuer verification method"
|
|
52
|
+
);
|
|
53
|
+
assert(
|
|
54
|
+
credential.issuerVerificationMethodRef.methodId == proof.signerVerificationMethodRef.methodId,
|
|
55
|
+
"Issuer proof method reference does not match issuer verification method"
|
|
56
|
+
);
|
|
57
|
+
assertValidIssuanceContextProof(bodyRoot, proof);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Thin VP envelope surface.
|
|
2
|
+
// Owns presentation-local structure and body-root derivation. VC↔VP linkage
|
|
3
|
+
// and holder-binding equality stay outside this module.
|
|
4
|
+
module VP<TDisclosures, THolderBinding> {
|
|
5
|
+
export struct Presentation {
|
|
6
|
+
version: Uint<16>,
|
|
7
|
+
schema: SchemaRef,
|
|
8
|
+
credentialClaimRoot: Bytes<32>,
|
|
9
|
+
issuerVerificationMethodRef: VerificationMethodRef,
|
|
10
|
+
holderBinding: THolderBinding,
|
|
11
|
+
disclosed: TDisclosures,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export pure circuit presentationBodyRoot(presentation: Presentation): Bytes<32> {
|
|
15
|
+
return persistentHash<Presentation>(presentation);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export pure circuit assertValidPresentationEnvelope(
|
|
19
|
+
presentation: Presentation
|
|
20
|
+
): [] {
|
|
21
|
+
// VC/VP linkage now lives in `relations.compact`; the thin VP surface only
|
|
22
|
+
// owns presentation-local envelope invariants.
|
|
23
|
+
assert(presentation.version == 1, "Presentation version mismatch");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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/composable";
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"same-holder.d.ts","sourceRoot":"","sources":["../../src/holder-binding/same-holder.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"same-holder.js","sourceRoot":"","sources":["../../src/holder-binding/same-holder.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAC","sourcesContent":["export * from \"../managed/same-holder/contract/index.js\";\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,yCAAyC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,yCAAyC,CAAC","sourcesContent":["export * from \"./jubjub.js\";\nexport * from \"./managed/credentials/contract/index.js\";\n"]}
|
package/dist/jubjub.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jubjub.d.ts","sourceRoot":"","sources":["../src/jubjub.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,gFAC6C,CAAC;AAEhF,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,KAAG,MAGtD,CAAC"}
|
package/dist/jubjub.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const JUBJUB_SUBGROUP_ORDER = 6554484396890773809930967563523245729705921265872317281365359162392183254199n;
|
|
2
|
+
export const modJubjubSubgroupOrder = (value) => {
|
|
3
|
+
const reduced = value % JUBJUB_SUBGROUP_ORDER;
|
|
4
|
+
return reduced >= 0n ? reduced : reduced + JUBJUB_SUBGROUP_ORDER;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=jubjub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jubjub.js","sourceRoot":"","sources":["../src/jubjub.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAChC,6EAA6E,CAAC;AAEhF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC9D,MAAM,OAAO,GAAG,KAAK,GAAG,qBAAqB,CAAC;IAC9C,OAAO,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,GAAG,qBAAqB,CAAC;AACnE,CAAC,CAAC","sourcesContent":["export const JUBJUB_SUBGROUP_ORDER =\n 6554484396890773809930967563523245729705921265872317281365359162392183254199n;\n\nexport const modJubjubSubgroupOrder = (value: bigint): bigint => {\n const reduced = value % JUBJUB_SUBGROUP_ORDER;\n return reduced >= 0n ? reduced : reduced + JUBJUB_SUBGROUP_ORDER;\n};\n"]}
|