@midnight-ntwrk/midnight-did-contract 0.5.0-rc1
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/LICENSE +201 -0
- package/README.md +63 -0
- package/dist/controller-key.d.ts +2 -0
- package/dist/controller-key.d.ts.map +1 -0
- package/dist/controller-key.js +30 -0
- package/dist/controller-key.js.map +1 -0
- package/dist/did.compact +375 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/managed/did/compiler/contract-info.json +481 -0
- package/dist/managed/did/contract/index.d.ts +233 -0
- package/dist/managed/did/contract/index.js +3658 -0
- package/dist/managed/did/contract/index.js.map +8 -0
- package/dist/managed/did/keys/deactivate.prover +0 -0
- package/dist/managed/did/keys/deactivate.verifier +0 -0
- package/dist/managed/did/keys/removeSchnorrJubjubVerificationMethod.prover +0 -0
- package/dist/managed/did/keys/removeSchnorrJubjubVerificationMethod.verifier +0 -0
- package/dist/managed/did/keys/removeService.prover +0 -0
- package/dist/managed/did/keys/removeService.verifier +0 -0
- package/dist/managed/did/keys/removeVerificationMethod.prover +0 -0
- package/dist/managed/did/keys/removeVerificationMethod.verifier +0 -0
- package/dist/managed/did/keys/rotateControllerKey.prover +0 -0
- package/dist/managed/did/keys/rotateControllerKey.verifier +0 -0
- package/dist/managed/did/keys/setAlsoKnownAs.prover +0 -0
- package/dist/managed/did/keys/setAlsoKnownAs.verifier +0 -0
- package/dist/managed/did/keys/setSchnorrJubjubVerificationMethod.prover +0 -0
- package/dist/managed/did/keys/setSchnorrJubjubVerificationMethod.verifier +0 -0
- package/dist/managed/did/keys/setService.prover +0 -0
- package/dist/managed/did/keys/setService.verifier +0 -0
- package/dist/managed/did/keys/setVerificationMethod.prover +0 -0
- package/dist/managed/did/keys/setVerificationMethod.verifier +0 -0
- package/dist/managed/did/keys/setVerificationMethodRelation.prover +0 -0
- package/dist/managed/did/keys/setVerificationMethodRelation.verifier +0 -0
- package/dist/managed/did/keys/verifySchnorrJubjubDigestSignature.prover +0 -0
- package/dist/managed/did/keys/verifySchnorrJubjubDigestSignature.verifier +0 -0
- package/dist/managed/did/zkir/deactivate.bzkir +0 -0
- package/dist/managed/did/zkir/deactivate.zkir +162 -0
- package/dist/managed/did/zkir/removeSchnorrJubjubVerificationMethod.bzkir +0 -0
- package/dist/managed/did/zkir/removeSchnorrJubjubVerificationMethod.zkir +299 -0
- package/dist/managed/did/zkir/removeService.bzkir +0 -0
- package/dist/managed/did/zkir/removeService.zkir +166 -0
- package/dist/managed/did/zkir/removeVerificationMethod.bzkir +0 -0
- package/dist/managed/did/zkir/removeVerificationMethod.zkir +300 -0
- package/dist/managed/did/zkir/rotateControllerKey.bzkir +0 -0
- package/dist/managed/did/zkir/rotateControllerKey.zkir +166 -0
- package/dist/managed/did/zkir/setAlsoKnownAs.bzkir +0 -0
- package/dist/managed/did/zkir/setAlsoKnownAs.zkir +258 -0
- package/dist/managed/did/zkir/setSchnorrJubjubVerificationMethod.bzkir +0 -0
- package/dist/managed/did/zkir/setSchnorrJubjubVerificationMethod.zkir +293 -0
- package/dist/managed/did/zkir/setService.bzkir +0 -0
- package/dist/managed/did/zkir/setService.zkir +256 -0
- package/dist/managed/did/zkir/setVerificationMethod.bzkir +0 -0
- package/dist/managed/did/zkir/setVerificationMethod.zkir +326 -0
- package/dist/managed/did/zkir/setVerificationMethodRelation.bzkir +0 -0
- package/dist/managed/did/zkir/setVerificationMethodRelation.zkir +683 -0
- package/dist/managed/did/zkir/verifySchnorrJubjubDigestSignature.bzkir +0 -0
- package/dist/managed/did/zkir/verifySchnorrJubjubDigestSignature.zkir +110 -0
- package/dist/witnesses.d.ts +11 -0
- package/dist/witnesses.d.ts.map +1 -0
- package/dist/witnesses.js +27 -0
- package/dist/witnesses.js.map +1 -0
- package/package.json +64 -0
- package/scripts/align-runtime-version.mjs +41 -0
- package/scripts/strip-managed-sourcemaps.mjs +30 -0
- package/tsconfig.build.json +24 -0
- package/tsconfig.json +37 -0
package/dist/did.compact
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
// This file is part of midnightntwrk/midnight-did.
|
|
2
|
+
// Copyright (C) 2025 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
|
+
import "../../jubjub-schnorr/src/schnorr" prefix Schnorr_;
|
|
20
|
+
|
|
21
|
+
export { Schnorr_SchnorrSignature };
|
|
22
|
+
|
|
23
|
+
// Ledger state - Full DID Document
|
|
24
|
+
export ledger contractVersion: Uint<32>;
|
|
25
|
+
export ledger controllerPublicKey: Bytes<32>;
|
|
26
|
+
export ledger id: ContractAddress;
|
|
27
|
+
export ledger alsoKnownAs: Set<Opaque<"string">>;
|
|
28
|
+
export ledger version: Counter;
|
|
29
|
+
export ledger created: Uint<64>;
|
|
30
|
+
export ledger updated: Uint<64>;
|
|
31
|
+
export ledger deactivated: Boolean;
|
|
32
|
+
export ledger active: Boolean;
|
|
33
|
+
export ledger operationCount: Counter;
|
|
34
|
+
export ledger verificationMethods: Map<Opaque<"string">, VerificationMethod>;
|
|
35
|
+
export ledger schnorrJubjubVerificationMethods: Map<Opaque<"string">, SchnorrJubjubVerificationMethod>;
|
|
36
|
+
export ledger authenticationRelation: Set<Opaque<"string">>;
|
|
37
|
+
export ledger assertionMethodRelation: Set<Opaque<"string">>;
|
|
38
|
+
export ledger keyAgreementRelation: Set<Opaque<"string">>;
|
|
39
|
+
export ledger capabilityInvocationRelation: Set<Opaque<"string">>;
|
|
40
|
+
export ledger capabilityDelegationRelation: Set<Opaque<"string">>;
|
|
41
|
+
export ledger services: Map<Opaque<"string">, Service>;
|
|
42
|
+
|
|
43
|
+
// Witnesses
|
|
44
|
+
witness localSecretKey(): Bytes<32>;
|
|
45
|
+
witness currentTimestamp(): Uint<64>;
|
|
46
|
+
|
|
47
|
+
// Enums and Structs
|
|
48
|
+
export enum VerificationMethodType {
|
|
49
|
+
Undefined,
|
|
50
|
+
JsonWebKey
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export enum VerificationMethodRelation {
|
|
54
|
+
Undefined,
|
|
55
|
+
Authentication,
|
|
56
|
+
AssertionMethod,
|
|
57
|
+
KeyAgreement,
|
|
58
|
+
CapabilityInvocation,
|
|
59
|
+
CapabilityDelegation
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export enum MapMutation {
|
|
63
|
+
Undefined,
|
|
64
|
+
Insert,
|
|
65
|
+
Update
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export enum SetMutation {
|
|
69
|
+
Undefined,
|
|
70
|
+
Insert,
|
|
71
|
+
Remove
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export enum KeyType {
|
|
75
|
+
EC, RSA, oct, OKP
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export enum CurveType {
|
|
79
|
+
Ed25519, X25519, Jubjub, P256, Secp256k1, BLS12381G1, BLS12381G2
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export struct PublicKeyJwk {
|
|
83
|
+
kty: KeyType,
|
|
84
|
+
crv: CurveType,
|
|
85
|
+
x: Opaque<"string">,
|
|
86
|
+
y: Opaque<"string">,
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export struct VerificationMethod {
|
|
90
|
+
id: Opaque<"string">,
|
|
91
|
+
typ: VerificationMethodType,
|
|
92
|
+
publicKeyJwk: PublicKeyJwk,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export struct SchnorrJubjubVerificationMethod {
|
|
96
|
+
id: Opaque<"string">,
|
|
97
|
+
publicKey: JubjubPoint,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export struct Service {
|
|
101
|
+
id: Opaque<"string">,
|
|
102
|
+
typ: Opaque<"string">,
|
|
103
|
+
serviceEndpoint: Opaque<"string">,
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
circuit verificationMethodExists(id: Opaque<"string">): Boolean {
|
|
107
|
+
return verificationMethods.member(id) || schnorrJubjubVerificationMethods.member(id);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
circuit controllerKey(sk: Bytes<32>): Bytes<32> {
|
|
111
|
+
return persistentHash<Vector<2, Bytes<32>>>([pad(32, "did:controller:pk"), sk]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
circuit assertController(): [] {
|
|
115
|
+
assert(controllerKey(localSecretKey()) == controllerPublicKey, "DID controller is allowed to update the DID only");
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
circuit assertControllerCanUpdate(): [] {
|
|
119
|
+
assertController();
|
|
120
|
+
assert(active, "Contract is not active");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
circuit recordUpdate(): [] {
|
|
124
|
+
operationCount.increment(1);
|
|
125
|
+
version.increment(1);
|
|
126
|
+
updated = disclose(currentTimestamp());
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
circuit assertMapMutationDefined(mutation: MapMutation): [] {
|
|
130
|
+
assert(mutation == MapMutation.Insert || mutation == MapMutation.Update, "Map mutation must be Insert or Update");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
circuit assertSetMutationDefined(mutation: SetMutation): [] {
|
|
134
|
+
assert(mutation == SetMutation.Insert || mutation == SetMutation.Remove, "Set mutation must be Insert or Remove");
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
circuit assertSupportedVerificationMethod(verificationMethod: VerificationMethod): [] {
|
|
138
|
+
assert(verificationMethod.typ == VerificationMethodType.JsonWebKey, "Only JsonWebKey verification methods are supported");
|
|
139
|
+
if (verificationMethod.publicKeyJwk.kty == KeyType.OKP) {
|
|
140
|
+
assert(verificationMethod.publicKeyJwk.crv == CurveType.Ed25519 || verificationMethod.publicKeyJwk.crv == CurveType.X25519 || verificationMethod.publicKeyJwk.crv == CurveType.BLS12381G1 || verificationMethod.publicKeyJwk.crv == CurveType.BLS12381G2, "OKP keys must use Ed25519, X25519, BLS12381G1, or BLS12381G2");
|
|
141
|
+
} else if (verificationMethod.publicKeyJwk.kty == KeyType.EC) {
|
|
142
|
+
assert(verificationMethod.publicKeyJwk.crv == CurveType.P256 || verificationMethod.publicKeyJwk.crv == CurveType.Secp256k1, "EC keys must use P-256 or secp256k1; use SchnorrJubjub methods for Jubjub");
|
|
143
|
+
} else {
|
|
144
|
+
assert(false, "Only OKP (Ed25519/X25519/BLS12381G1/BLS12381G2) and EC (P-256/secp256k1) keys are supported");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
circuit verificationMethodRelationMember(
|
|
149
|
+
relation: VerificationMethodRelation,
|
|
150
|
+
methodId: Opaque<"string">
|
|
151
|
+
): Boolean {
|
|
152
|
+
if (relation == VerificationMethodRelation.Authentication) {
|
|
153
|
+
return authenticationRelation.member(methodId);
|
|
154
|
+
} else if (relation == VerificationMethodRelation.AssertionMethod) {
|
|
155
|
+
return assertionMethodRelation.member(methodId);
|
|
156
|
+
} else if (relation == VerificationMethodRelation.KeyAgreement) {
|
|
157
|
+
return keyAgreementRelation.member(methodId);
|
|
158
|
+
} else if (relation == VerificationMethodRelation.CapabilityInvocation) {
|
|
159
|
+
return capabilityInvocationRelation.member(methodId);
|
|
160
|
+
} else if (relation == VerificationMethodRelation.CapabilityDelegation) {
|
|
161
|
+
return capabilityDelegationRelation.member(methodId);
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
circuit insertVerificationMethodRelation(
|
|
167
|
+
relation: VerificationMethodRelation,
|
|
168
|
+
methodId: Opaque<"string">
|
|
169
|
+
): [] {
|
|
170
|
+
if (relation == VerificationMethodRelation.Authentication) {
|
|
171
|
+
authenticationRelation.insert(methodId);
|
|
172
|
+
} else if (relation == VerificationMethodRelation.AssertionMethod) {
|
|
173
|
+
assertionMethodRelation.insert(methodId);
|
|
174
|
+
} else if (relation == VerificationMethodRelation.KeyAgreement) {
|
|
175
|
+
keyAgreementRelation.insert(methodId);
|
|
176
|
+
} else if (relation == VerificationMethodRelation.CapabilityInvocation) {
|
|
177
|
+
capabilityInvocationRelation.insert(methodId);
|
|
178
|
+
} else if (relation == VerificationMethodRelation.CapabilityDelegation) {
|
|
179
|
+
capabilityDelegationRelation.insert(methodId);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
circuit removeVerificationMethodRelationFromLedger(
|
|
184
|
+
relation: VerificationMethodRelation,
|
|
185
|
+
methodId: Opaque<"string">
|
|
186
|
+
): [] {
|
|
187
|
+
if (relation == VerificationMethodRelation.Authentication) {
|
|
188
|
+
authenticationRelation.remove(methodId);
|
|
189
|
+
} else if (relation == VerificationMethodRelation.AssertionMethod) {
|
|
190
|
+
assertionMethodRelation.remove(methodId);
|
|
191
|
+
} else if (relation == VerificationMethodRelation.KeyAgreement) {
|
|
192
|
+
keyAgreementRelation.remove(methodId);
|
|
193
|
+
} else if (relation == VerificationMethodRelation.CapabilityInvocation) {
|
|
194
|
+
capabilityInvocationRelation.remove(methodId);
|
|
195
|
+
} else if (relation == VerificationMethodRelation.CapabilityDelegation) {
|
|
196
|
+
capabilityDelegationRelation.remove(methodId);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
circuit assertVerificationMethodIsNotReferenced(id: Opaque<"string">): [] {
|
|
201
|
+
assert(!authenticationRelation.member(id), "Verification method still referenced in authenticationRelation");
|
|
202
|
+
assert(!assertionMethodRelation.member(id), "Verification method still referenced in assertionMethodRelation");
|
|
203
|
+
assert(!keyAgreementRelation.member(id), "Verification method still referenced in keyAgreementRelation");
|
|
204
|
+
assert(!capabilityInvocationRelation.member(id), "Verification method still referenced in capabilityInvocationRelation");
|
|
205
|
+
assert(!capabilityDelegationRelation.member(id), "Verification method still referenced in capabilityDelegationRelation");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Constructor
|
|
209
|
+
constructor() {
|
|
210
|
+
contractVersion = 1;
|
|
211
|
+
id = kernel.self();
|
|
212
|
+
active = true;
|
|
213
|
+
deactivated = false;
|
|
214
|
+
controllerPublicKey = disclose(controllerKey(localSecretKey()));
|
|
215
|
+
|
|
216
|
+
const timestamp = disclose(currentTimestamp());
|
|
217
|
+
created = timestamp;
|
|
218
|
+
updated = timestamp;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export circuit rotateControllerKey(newControllerPublicKey: Bytes<32>): [] {
|
|
222
|
+
assertControllerCanUpdate();
|
|
223
|
+
const disclosedNewControllerPublicKey = disclose(newControllerPublicKey);
|
|
224
|
+
assert(disclosedNewControllerPublicKey != controllerPublicKey, "New controller key matches current controller key");
|
|
225
|
+
controllerPublicKey = disclosedNewControllerPublicKey;
|
|
226
|
+
|
|
227
|
+
recordUpdate();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export circuit setAlsoKnownAs(value: Opaque<"string">, mutation: SetMutation): [] {
|
|
231
|
+
assertControllerCanUpdate();
|
|
232
|
+
const disclosedMutation = disclose(mutation);
|
|
233
|
+
assertSetMutationDefined(disclosedMutation);
|
|
234
|
+
const alias = disclose(value);
|
|
235
|
+
if (disclosedMutation == SetMutation.Insert) {
|
|
236
|
+
assert(!alsoKnownAs.member(alias), "alsoKnownAs value already exists");
|
|
237
|
+
alsoKnownAs.insert(alias);
|
|
238
|
+
} else if (disclosedMutation == SetMutation.Remove) {
|
|
239
|
+
assert(alsoKnownAs.member(alias), "alsoKnownAs value does not exist");
|
|
240
|
+
alsoKnownAs.remove(alias);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
recordUpdate();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export circuit setVerificationMethod(
|
|
247
|
+
verificationMethod: VerificationMethod,
|
|
248
|
+
mutation: MapMutation
|
|
249
|
+
): [] {
|
|
250
|
+
assertControllerCanUpdate();
|
|
251
|
+
const disclosedVerificationMethod = disclose(verificationMethod);
|
|
252
|
+
const disclosedMutation = disclose(mutation);
|
|
253
|
+
assertMapMutationDefined(disclosedMutation);
|
|
254
|
+
assertSupportedVerificationMethod(disclosedVerificationMethod);
|
|
255
|
+
if (disclosedMutation == MapMutation.Update) {
|
|
256
|
+
assert(verificationMethods.member(disclosedVerificationMethod.id), "Verification method does not exist");
|
|
257
|
+
verificationMethods.remove(disclosedVerificationMethod.id);
|
|
258
|
+
} else if (disclosedMutation == MapMutation.Insert) {
|
|
259
|
+
assert(!verificationMethodExists(disclosedVerificationMethod.id), "Verification method already exists");
|
|
260
|
+
}
|
|
261
|
+
verificationMethods.insert(disclosedVerificationMethod.id, disclosedVerificationMethod);
|
|
262
|
+
|
|
263
|
+
recordUpdate();
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export circuit removeVerificationMethod(id: Opaque<"string">): [] {
|
|
267
|
+
assertControllerCanUpdate();
|
|
268
|
+
const disclosedId = disclose(id);
|
|
269
|
+
assert(verificationMethods.member(disclosedId), "Verification method does not exist");
|
|
270
|
+
assertVerificationMethodIsNotReferenced(disclosedId);
|
|
271
|
+
verificationMethods.remove(disclosedId);
|
|
272
|
+
|
|
273
|
+
recordUpdate();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export circuit setSchnorrJubjubVerificationMethod(
|
|
277
|
+
verificationMethod: SchnorrJubjubVerificationMethod,
|
|
278
|
+
mutation: MapMutation
|
|
279
|
+
): [] {
|
|
280
|
+
assertControllerCanUpdate();
|
|
281
|
+
const disclosedVerificationMethod = disclose(verificationMethod);
|
|
282
|
+
const disclosedMutation = disclose(mutation);
|
|
283
|
+
assertMapMutationDefined(disclosedMutation);
|
|
284
|
+
if (disclosedMutation == MapMutation.Update) {
|
|
285
|
+
assert(schnorrJubjubVerificationMethods.member(disclosedVerificationMethod.id), "Verification method does not exist");
|
|
286
|
+
schnorrJubjubVerificationMethods.remove(disclosedVerificationMethod.id);
|
|
287
|
+
} else if (disclosedMutation == MapMutation.Insert) {
|
|
288
|
+
assert(!verificationMethodExists(disclosedVerificationMethod.id), "Verification method already exists");
|
|
289
|
+
}
|
|
290
|
+
schnorrJubjubVerificationMethods.insert(disclosedVerificationMethod.id, disclosedVerificationMethod);
|
|
291
|
+
|
|
292
|
+
recordUpdate();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export circuit removeSchnorrJubjubVerificationMethod(id: Opaque<"string">): [] {
|
|
296
|
+
assertControllerCanUpdate();
|
|
297
|
+
const disclosedId = disclose(id);
|
|
298
|
+
assert(schnorrJubjubVerificationMethods.member(disclosedId), "Verification method does not exist");
|
|
299
|
+
assertVerificationMethodIsNotReferenced(disclosedId);
|
|
300
|
+
schnorrJubjubVerificationMethods.remove(disclosedId);
|
|
301
|
+
|
|
302
|
+
recordUpdate();
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Intentionally non-mutating but exported as a transaction circuit: it proves a
|
|
306
|
+
// private digest/signature against the current ledger-bound verification method.
|
|
307
|
+
export circuit verifySchnorrJubjubDigestSignature(
|
|
308
|
+
methodId: Opaque<"string">,
|
|
309
|
+
digest: Vector<4, Field>,
|
|
310
|
+
signature: Schnorr_SchnorrSignature
|
|
311
|
+
): [] {
|
|
312
|
+
assert(active, "Contract is not active");
|
|
313
|
+
const disclosedMethodId = disclose(methodId);
|
|
314
|
+
assert(schnorrJubjubVerificationMethods.member(disclosedMethodId), "Verification method does not exist");
|
|
315
|
+
const verificationMethod = schnorrJubjubVerificationMethods.lookup(disclosedMethodId);
|
|
316
|
+
Schnorr_schnorrVerifyDigest(digest, signature, verificationMethod.publicKey);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export circuit setVerificationMethodRelation(
|
|
320
|
+
relation: VerificationMethodRelation,
|
|
321
|
+
methodId: Opaque<"string">,
|
|
322
|
+
mutation: SetMutation
|
|
323
|
+
): [] {
|
|
324
|
+
assertControllerCanUpdate();
|
|
325
|
+
const disclosedRelation = disclose(relation);
|
|
326
|
+
const disclosedMethodId = disclose(methodId);
|
|
327
|
+
const disclosedMutation = disclose(mutation);
|
|
328
|
+
assertSetMutationDefined(disclosedMutation);
|
|
329
|
+
assert(verificationMethodExists(disclosedMethodId), "Verification method does not exist");
|
|
330
|
+
assert(disclosedRelation != VerificationMethodRelation.Undefined, "Verification relation must be defined");
|
|
331
|
+
const currentPresent = verificationMethodRelationMember(disclosedRelation, disclosedMethodId);
|
|
332
|
+
if (disclosedMutation == SetMutation.Insert) {
|
|
333
|
+
assert(!currentPresent, "Verification method relation already exists");
|
|
334
|
+
insertVerificationMethodRelation(disclosedRelation, disclosedMethodId);
|
|
335
|
+
} else if (disclosedMutation == SetMutation.Remove) {
|
|
336
|
+
assert(currentPresent, "Verification method relation does not exist");
|
|
337
|
+
removeVerificationMethodRelationFromLedger(disclosedRelation, disclosedMethodId);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
recordUpdate();
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export circuit setService(service: Service, mutation: MapMutation): [] {
|
|
344
|
+
assertControllerCanUpdate();
|
|
345
|
+
const disclosedService = disclose(service);
|
|
346
|
+
const disclosedMutation = disclose(mutation);
|
|
347
|
+
assertMapMutationDefined(disclosedMutation);
|
|
348
|
+
if (disclosedMutation == MapMutation.Update) {
|
|
349
|
+
assert(services.member(disclosedService.id), "Service with a given id does not exist");
|
|
350
|
+
services.remove(disclosedService.id);
|
|
351
|
+
} else if (disclosedMutation == MapMutation.Insert) {
|
|
352
|
+
assert(!services.member(disclosedService.id), "Service with a given id already exists");
|
|
353
|
+
}
|
|
354
|
+
services.insert(disclosedService.id, disclosedService);
|
|
355
|
+
|
|
356
|
+
recordUpdate();
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export circuit removeService(id: Opaque<"string">): [] {
|
|
360
|
+
assertControllerCanUpdate();
|
|
361
|
+
const disclosedId = disclose(id);
|
|
362
|
+
assert(services.member(disclosedId), "Service with a given id does not exist");
|
|
363
|
+
services.remove(disclosedId);
|
|
364
|
+
|
|
365
|
+
recordUpdate();
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export circuit deactivate(): [] {
|
|
369
|
+
assertController();
|
|
370
|
+
assert(active, "DID is already inactive");
|
|
371
|
+
active = false;
|
|
372
|
+
deactivated = true;
|
|
373
|
+
|
|
374
|
+
recordUpdate();
|
|
375
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,cAAc,qBAAqB,CAAC;AACpC,OAAO,KAAK,WAAW,MAAM,iCAAiC,CAAC;AAC/D,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// This file is part of midnightntwrk/midnight-did.
|
|
2
|
+
// Copyright (C) 2025 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
|
+
export * from "./controller-key.js";
|
|
16
|
+
export * as DIDContract from "./managed/did/contract/index.js";
|
|
17
|
+
export * from "./witnesses.js";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,yCAAyC;AACzC,sCAAsC;AACtC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,qBAAqB,CAAC;AACpC,OAAO,KAAK,WAAW,MAAM,iCAAiC,CAAC;AAC/D,cAAc,gBAAgB,CAAC","sourcesContent":["// This file is part of midnightntwrk/midnight-did.\n// Copyright (C) 2025 Midnight Foundation\n// SPDX-License-Identifier: Apache-2.0\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// You may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from \"./controller-key.js\";\nexport * as DIDContract from \"./managed/did/contract/index.js\";\nexport * from \"./witnesses.js\";\n"]}
|