@veridid/kanon 0.0.0-stage → 1.0.0

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 (96) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +156 -2
  3. package/build/KanonApi.d.ts +52 -0
  4. package/build/KanonApi.d.ts.map +1 -0
  5. package/build/KanonApi.js +92 -0
  6. package/build/KanonApi.js.map +1 -0
  7. package/build/KanonModule.d.ts +15 -0
  8. package/build/KanonModule.d.ts.map +1 -0
  9. package/build/KanonModule.js +53 -0
  10. package/build/KanonModule.js.map +1 -0
  11. package/build/KanonModuleConfig.d.ts +123 -0
  12. package/build/KanonModuleConfig.d.ts.map +1 -0
  13. package/build/KanonModuleConfig.js +84 -0
  14. package/build/KanonModuleConfig.js.map +1 -0
  15. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.js +10 -0
  16. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.js +7 -0
  17. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.js +9 -0
  18. package/build/anoncreds/helpers/buildKanonCredentialAttributes.d.ts +33 -0
  19. package/build/anoncreds/helpers/buildKanonCredentialAttributes.d.ts.map +1 -0
  20. package/build/anoncreds/helpers/buildKanonCredentialAttributes.js +43 -0
  21. package/build/anoncreds/helpers/buildKanonCredentialAttributes.js.map +1 -0
  22. package/build/anoncreds/helpers/buildKanonProofRequest.d.ts +45 -0
  23. package/build/anoncreds/helpers/buildKanonProofRequest.d.ts.map +1 -0
  24. package/build/anoncreds/helpers/buildKanonProofRequest.js +45 -0
  25. package/build/anoncreds/helpers/buildKanonProofRequest.js.map +1 -0
  26. package/build/anoncreds/helpers/buildKanonSchema.d.ts +23 -0
  27. package/build/anoncreds/helpers/buildKanonSchema.d.ts.map +1 -0
  28. package/build/anoncreds/helpers/buildKanonSchema.js +27 -0
  29. package/build/anoncreds/helpers/buildKanonSchema.js.map +1 -0
  30. package/build/anoncreds/helpers/index.js +3 -0
  31. package/build/anoncreds/index.d.ts +8 -0
  32. package/build/anoncreds/index.js +9 -0
  33. package/build/anoncreds/services/KanonAnonCredsRegistry.d.ts +36 -0
  34. package/build/anoncreds/services/KanonAnonCredsRegistry.d.ts.map +1 -0
  35. package/build/anoncreds/services/KanonAnonCredsRegistry.js +298 -0
  36. package/build/anoncreds/services/KanonAnonCredsRegistry.js.map +1 -0
  37. package/build/anoncreds/services/KanonIssuanceTracker.d.ts +39 -0
  38. package/build/anoncreds/services/KanonIssuanceTracker.d.ts.map +1 -0
  39. package/build/anoncreds/services/KanonIssuanceTracker.js +141 -0
  40. package/build/anoncreds/services/KanonIssuanceTracker.js.map +1 -0
  41. package/build/anoncreds/services/KanonWrappedAnonCredsHolderService.d.ts +82 -0
  42. package/build/anoncreds/services/KanonWrappedAnonCredsHolderService.d.ts.map +1 -0
  43. package/build/anoncreds/services/KanonWrappedAnonCredsHolderService.js +316 -0
  44. package/build/anoncreds/services/KanonWrappedAnonCredsHolderService.js.map +1 -0
  45. package/build/anoncreds/services/KanonWrappedAnonCredsVerifierService.d.ts +67 -0
  46. package/build/anoncreds/services/KanonWrappedAnonCredsVerifierService.d.ts.map +1 -0
  47. package/build/anoncreds/services/KanonWrappedAnonCredsVerifierService.js +330 -0
  48. package/build/anoncreds/services/KanonWrappedAnonCredsVerifierService.js.map +1 -0
  49. package/build/anoncreds/utils/credIdHash.d.ts +2 -0
  50. package/build/anoncreds/utils/credIdHash.js +3 -0
  51. package/build/dids/KanonDidRegistrar.d.ts +47 -0
  52. package/build/dids/KanonDidRegistrar.d.ts.map +1 -0
  53. package/build/dids/KanonDidRegistrar.js +140 -0
  54. package/build/dids/KanonDidRegistrar.js.map +1 -0
  55. package/build/dids/KanonDidResolver.d.ts +18 -0
  56. package/build/dids/KanonDidResolver.d.ts.map +1 -0
  57. package/build/dids/KanonDidResolver.js +88 -0
  58. package/build/dids/KanonDidResolver.js.map +1 -0
  59. package/build/dids/didEtherUtils.d.ts +18 -0
  60. package/build/dids/didEtherUtils.d.ts.map +1 -0
  61. package/build/dids/didEtherUtils.js +47 -0
  62. package/build/dids/didEtherUtils.js.map +1 -0
  63. package/build/dids/index.js +3 -0
  64. package/build/index.d.ts +24 -0
  65. package/build/index.js +25 -0
  66. package/build/ledger/KanonClientService.d.ts +45 -0
  67. package/build/ledger/KanonClientService.d.ts.map +1 -0
  68. package/build/ledger/KanonClientService.js +111 -0
  69. package/build/ledger/KanonClientService.js.map +1 -0
  70. package/build/ledger/index.d.ts +1 -0
  71. package/build/ledger/index.js +1 -0
  72. package/build/utils/identifiers.d.ts +24 -0
  73. package/build/utils/identifiers.d.ts.map +1 -0
  74. package/build/utils/identifiers.js +39 -0
  75. package/build/utils/identifiers.js.map +1 -0
  76. package/build/zk/KanonZkApi.d.ts +186 -0
  77. package/build/zk/KanonZkApi.d.ts.map +1 -0
  78. package/build/zk/KanonZkApi.js +226 -0
  79. package/build/zk/KanonZkApi.js.map +1 -0
  80. package/build/zk/KanonZkIssuerKeyService.d.ts +107 -0
  81. package/build/zk/KanonZkIssuerKeyService.d.ts.map +1 -0
  82. package/build/zk/KanonZkIssuerKeyService.js +137 -0
  83. package/build/zk/KanonZkIssuerKeyService.js.map +1 -0
  84. package/build/zk/KanonZkPathService.d.ts +66 -0
  85. package/build/zk/KanonZkPathService.d.ts.map +1 -0
  86. package/build/zk/KanonZkPathService.js +163 -0
  87. package/build/zk/KanonZkPathService.js.map +1 -0
  88. package/build/zk/KanonZkService.d.ts +91 -0
  89. package/build/zk/KanonZkService.d.ts.map +1 -0
  90. package/build/zk/KanonZkService.js +165 -0
  91. package/build/zk/KanonZkService.js.map +1 -0
  92. package/build/zk/index.d.ts +4 -0
  93. package/build/zk/index.js +4 -0
  94. package/build/zk/modeBLeaves.js +48 -0
  95. package/build/zk/modeBLeaves.js.map +1 -0
  96. package/package.json +66 -3
@@ -0,0 +1,316 @@
1
+ import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.js";
2
+ import { __decorateMetadata } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.js";
3
+ import { __decorateParam } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.js";
4
+ import { KanonClientService } from "../../ledger/KanonClientService.js";
5
+ import "../../ledger/index.js";
6
+ import { padAttrsToCircuit } from "../../zk/KanonZkService.js";
7
+ import { KanonZkPathService } from "../../zk/KanonZkPathService.js";
8
+ import { BN254_SCALAR_FIELD, KANON_CRED_ID_ATTRIBUTE, KANON_ZK_PROOF_ATTRIBUTE, KANON_ZK_SIG_ATTRIBUTE, attrValueToFelt, computeZkLeaf, decodeZkSignature, encodeAttributesCanonical, encodeKanonZkProofAttr, kanonCredIdHash } from "@ajna-inc/kanon-sdk";
9
+ import { inject, injectable } from "@credo-ts/core";
10
+ import { ethers } from "ethers";
11
+
12
+ //#region src/anoncreds/services/KanonWrappedAnonCredsHolderService.ts
13
+ var _ref, _ref2;
14
+ /**
15
+ * DI token used by `KanonModule` to register the original
16
+ * `AnonCredsRsHolderService` so the wrapper can inject it without depending
17
+ * on a deep build path.
18
+ */
19
+ const OriginalAnonCredsHolderServiceSymbol = Symbol("OriginalAnonCredsHolderService");
20
+ /**
21
+ * Bit mask of `TIER_ZK_SNARK`. Inlined to avoid a runtime SDK import for a
22
+ * single-use constant.
23
+ */
24
+ const TIER_ZK_SNARK$1 = 2;
25
+ let KanonWrappedAnonCredsHolderService = class KanonWrappedAnonCredsHolderService {
26
+ constructor(inner, clientService, pathService) {
27
+ this.inner = inner;
28
+ this.clientService = clientService;
29
+ this.pathService = pathService;
30
+ this.policyCache = /* @__PURE__ */ new Map();
31
+ }
32
+ async createProof(agentContext, options) {
33
+ assertProofRequestDoesNotAskForKanonZkSig(agentContext, options);
34
+ const augmented = await this.augmentSelfAttested(agentContext, options);
35
+ return this.inner.createProof(agentContext, augmented);
36
+ }
37
+ createLinkSecret(agentContext, options) {
38
+ return this.inner.createLinkSecret(agentContext, options);
39
+ }
40
+ createCredentialRequest(agentContext, options) {
41
+ return this.inner.createCredentialRequest(agentContext, options);
42
+ }
43
+ storeCredential(agentContext, options, metadata) {
44
+ return this.inner.storeCredential(agentContext, options, metadata);
45
+ }
46
+ getCredential(agentContext, options) {
47
+ return this.inner.getCredential(agentContext, options);
48
+ }
49
+ getCredentials(agentContext, options) {
50
+ return this.inner.getCredentials(agentContext, options);
51
+ }
52
+ deleteCredential(agentContext, credentialId) {
53
+ return this.inner.deleteCredential(agentContext, credentialId);
54
+ }
55
+ getCredentialsForProofRequest(agentContext, options) {
56
+ return this.inner.getCredentialsForProofRequest(agentContext, options);
57
+ }
58
+ createW3cPresentation(agentContext, options) {
59
+ return this.inner.createW3cPresentation(agentContext, options);
60
+ }
61
+ w3cToLegacyCredential(agentContext, options) {
62
+ return this.inner.w3cToLegacyCredential(agentContext, options);
63
+ }
64
+ legacyToW3cCredential(agentContext, options) {
65
+ return this.inner.legacyToW3cCredential(agentContext, options);
66
+ }
67
+ generateNonce(agentContext) {
68
+ return this.inner.generateNonce(agentContext);
69
+ }
70
+ /**
71
+ * For every Mode B credential referenced in `selectedCredentials`, compute
72
+ * the SNARK proof and add it to `selfAttestedAttributes` under
73
+ * `kanon_<credDefId>_zkProof`. The original options object is left
74
+ * untouched — we return a shallow copy with augmented self-attested attrs.
75
+ */
76
+ async augmentSelfAttested(agentContext, options) {
77
+ const credDefIds = collectCredDefIds(options);
78
+ if (credDefIds.size === 0) return options;
79
+ const requestedAttrs = options.proofRequest?.requested_attributes ?? {};
80
+ const modeB = [];
81
+ for (const credDefId of credDefIds) {
82
+ if ((await this.getPolicyMask(agentContext, credDefId) & TIER_ZK_SNARK$1) === 0) continue;
83
+ const ref = kanonZkProofReferent(credDefId);
84
+ if (!(ref in requestedAttrs)) {
85
+ agentContext.config.logger.debug(`KanonWrappedAnonCredsHolderService: Mode B credDef ${credDefId} present but verifier did not request ${ref} — skipping SNARK injection (proof will be a standard AnonCreds presentation)`);
86
+ continue;
87
+ }
88
+ modeB.push(credDefId);
89
+ }
90
+ if (modeB.length === 0) return options;
91
+ const challenge = await this.challengeFromProofRequest(options);
92
+ const augmentedSelfAttested = { ...options.selectedCredentials.selfAttestedAttributes ?? {} };
93
+ for (const credDefId of modeB) try {
94
+ const credInfo = findCredentialInfoForCredDef(options, credDefId);
95
+ if (!credInfo) {
96
+ agentContext.config.logger.warn(`KanonWrappedAnonCredsHolderService: Mode B credDef ${credDefId} referenced in selection but no credentialInfo found — skipping injection (proof will likely fail)`);
97
+ continue;
98
+ }
99
+ const revealed = findRevealedAttributeForCredDef(options, credDefId);
100
+ if (!revealed) throw new Error(`kanon: Mode B credDef ${credDefId} is in the presentation but the verifier did not request any revealed attribute restricted to it. Mode B requires the SNARK's disclosed slot to be bound to an AnonCreds-revealed attribute — otherwise either the SNARK leaks something AnonCreds isn't, or every presentation shares the same disclosed slot (linkable). Have the verifier add at least one revealed requested_attribute with restrictions: [{ cred_def_id: '${credDefId}' }].`);
101
+ const referent = kanonZkProofReferent(credDefId);
102
+ augmentedSelfAttested[referent] = await this.buildZkProofAttr(agentContext, credDefId, credInfo, challenge, revealed);
103
+ agentContext.config.logger.debug(`KanonWrappedAnonCredsHolderService: injected ${referent} for credId=${credInfo.credentialId}, disclosing '${revealed.name}'`);
104
+ } catch (err) {
105
+ const message = err instanceof Error ? err.message : String(err);
106
+ agentContext.config.logger.error(`KanonWrappedAnonCredsHolderService: failed to build Mode B proof for ${credDefId}: ${message}`);
107
+ throw err;
108
+ }
109
+ return {
110
+ ...options,
111
+ selectedCredentials: {
112
+ ...options.selectedCredentials,
113
+ selfAttestedAttributes: augmentedSelfAttested
114
+ }
115
+ };
116
+ }
117
+ async buildZkProofAttr(agentContext, credDefId, credInfo, challenge, revealed) {
118
+ const attrs = credInfo.attributes;
119
+ const kanonCredId = attrs[KANON_CRED_ID_ATTRIBUTE];
120
+ const kanonZkSig = attrs[KANON_ZK_SIG_ATTRIBUTE];
121
+ if (typeof kanonCredId !== "string" || typeof kanonZkSig !== "string") throw new Error(`kanon-zk: credential ${credInfo.credentialId} for Mode B credDef ${credDefId} is missing ${KANON_CRED_ID_ATTRIBUTE} / ${KANON_ZK_SIG_ATTRIBUTE} attributes — was it issued through prepareModeBCredential?`);
122
+ const values = {};
123
+ for (const [name, value] of Object.entries(attrs)) if (typeof value === "string") values[name] = value;
124
+ const paddedAttrs = padAttrsToCircuit(encodeAttributesCanonical(values));
125
+ const sortedDomainNames = Object.keys(values).filter((n) => n !== KANON_CRED_ID_ATTRIBUTE && n !== KANON_ZK_SIG_ATTRIBUTE).sort();
126
+ const disclosedIndex = sortedDomainNames.indexOf(revealed.name);
127
+ if (disclosedIndex < 0) throw new Error(`kanon-zk: verifier asked to reveal '${revealed.name}' but the credential's domain attributes don't include it (after stripping kanon-reserved names). Available: ${sortedDomainNames.join(", ")}`);
128
+ const disclosedValue = paddedAttrs[disclosedIndex];
129
+ const expectedRevealedFelt = attrValueToFelt(revealed.value);
130
+ if (disclosedValue !== expectedRevealedFelt) throw new Error(`kanon-zk: internal felt-encoding mismatch for '${revealed.name}' — canonical slot ${disclosedIndex} holds ${disclosedValue} but the revealed value encodes to ${expectedRevealedFelt}. This indicates a bug in attribute encoding or canonical ordering.`);
131
+ const credDefFelt = BigInt(credDefIdToBytes32(credDefId)) % BN254_SCALAR_FIELD;
132
+ const credIdFelt = BigInt(kanonCredIdHash(kanonCredId)) % BN254_SCALAR_FIELD;
133
+ const leaf = await computeZkLeaf(credDefFelt, credIdFelt, paddedAttrs);
134
+ const pathInfo = await this.pathService.findPath(agentContext, credDefId, leaf);
135
+ if (!pathInfo) throw new Error(`kanon-zk: could not find Merkle path for credential ${credInfo.credentialId} in credDef ${credDefId} — credential may have been revoked or not yet published`);
136
+ const onChainKey = await this.clientService.contracts.credDefRegistry.getIssuerZkPubKey(credDefIdToBytes32(credDefId));
137
+ if (!onChainKey.set) throw new Error(`kanon-zk: credDef ${credDefId} has no Tier 2 key published`);
138
+ const sig = decodeZkSignature(kanonZkSig);
139
+ const input = {
140
+ root: pathInfo.root.toString(),
141
+ credDefId: credDefFelt.toString(),
142
+ challenge: challenge.toString(),
143
+ issuerAx: BigInt(onChainKey.ax).toString(),
144
+ issuerAy: BigInt(onChainKey.ay).toString(),
145
+ disclosedIndex: [disclosedIndex.toString()],
146
+ disclosedValue: [disclosedValue.toString()],
147
+ credId: credIdFelt.toString(),
148
+ attributes: paddedAttrs.map((a) => a.toString()),
149
+ pathElements: pathInfo.pathElements.map((p) => p.toString()),
150
+ pathIndices: pathInfo.pathIndices.map((p) => p.toString()),
151
+ sigS: sig.S.toString(),
152
+ sigR8x: sig.R8x.toString(),
153
+ sigR8y: sig.R8y.toString()
154
+ };
155
+ const snarkjs = await import("snarkjs");
156
+ const wasmPath = process.env.KANON_ZK_WASM;
157
+ const zkeyPath = process.env.KANON_ZK_ZKEY;
158
+ if (!wasmPath || !zkeyPath) throw new Error("kanon-zk: KANON_ZK_WASM and KANON_ZK_ZKEY env vars must point at the snarkjs artifacts (non_revocation.wasm + nr_final.zkey) for Mode B presentations to work");
159
+ const { proof, publicSignals } = await snarkjs.groth16.fullProve(input, wasmPath, zkeyPath);
160
+ const calldata = await snarkjs.groth16.exportSolidityCallData(proof, publicSignals);
161
+ const [a, b, c] = JSON.parse("[" + calldata + "]");
162
+ const proofBytes = ethers.AbiCoder.defaultAbiCoder().encode([
163
+ "uint256[2]",
164
+ "uint256[2][2]",
165
+ "uint256[2]"
166
+ ], [
167
+ a,
168
+ b,
169
+ c
170
+ ]);
171
+ const toBytes32 = (v) => "0x" + BigInt(v).toString(16).padStart(64, "0");
172
+ return encodeKanonZkProofAttr({
173
+ proofBytes,
174
+ publicSignals: publicSignals.map(toBytes32)
175
+ });
176
+ }
177
+ async getPolicyMask(agentContext, credDefId) {
178
+ const cached = this.policyCache.get(credDefId);
179
+ if (cached !== void 0) return cached;
180
+ try {
181
+ const mask = await this.clientService.client.getCredDefPolicy(credDefIdToBytes32(credDefId));
182
+ this.policyCache.set(credDefId, mask);
183
+ return mask;
184
+ } catch (err) {
185
+ const message = err instanceof Error ? err.message : String(err);
186
+ agentContext.config.logger.debug(`KanonWrappedAnonCredsHolderService: getCredDefPolicy(${credDefId}) failed (${message}); assuming Mode A only`);
187
+ this.policyCache.set(credDefId, 1);
188
+ return 1;
189
+ }
190
+ }
191
+ /**
192
+ * Bind the SNARK challenge to the verifier's session. We use the
193
+ * `proofRequest.nonce` directly — AnonCreds already guarantees freshness
194
+ * + binding to this exchange, which is exactly the property the verifier
195
+ * needs to detect replay.
196
+ */
197
+ async challengeFromProofRequest(options) {
198
+ const nonce = options.proofRequest?.nonce;
199
+ if (!nonce) throw new Error("kanon-zk: proofRequest is missing nonce — cannot derive Mode B challenge");
200
+ return BigInt(nonce) % BN254_SCALAR_FIELD;
201
+ }
202
+ };
203
+ KanonWrappedAnonCredsHolderService = __decorate([
204
+ injectable(),
205
+ __decorateParam(0, inject(OriginalAnonCredsHolderServiceSymbol)),
206
+ __decorateMetadata("design:paramtypes", [
207
+ Object,
208
+ KanonClientService,
209
+ KanonZkPathService
210
+ ])
211
+ ], KanonWrappedAnonCredsHolderService);
212
+ /** `kanon_<credDefId>_zkProof` — the self-attested attribute name we inject. */
213
+ function kanonZkProofReferent(credDefId) {
214
+ return `kanon_${credDefId.toLowerCase()}_zkProof`;
215
+ }
216
+ /**
217
+ * credDef on-chain key — `keccak256(utf8(credDefId))`, or pass an already
218
+ * bytes32 value through unchanged. Mirrors the SDK's `resourceIdToBytes32`
219
+ * (and `KanonApi.toBytes32CredDefId`). `getCredDefPolicy` and the other
220
+ * registry reads are keyed by this, NOT the raw AnonCreds DID URL.
221
+ */
222
+ function credDefIdToBytes32(credDefId) {
223
+ if (/^0x[0-9a-fA-F]{64}$/.test(credDefId)) return credDefId;
224
+ return ethers.keccak256(ethers.toUtf8Bytes(credDefId));
225
+ }
226
+ /**
227
+ * Throws if the proof request asks the holder to disclose the
228
+ * `kanonZkSig` attribute via any requested-attributes referent.
229
+ *
230
+ * The kanonZkSig is a per-credential constant (the issuer's BabyJubjub
231
+ * EdDSA signature over the leaf). Disclosing it across multiple
232
+ * presentations defeats the Mode B unlinkability guarantee — every
233
+ * verifier that sees it gets the same value, trivially correlating the
234
+ * holder across sessions. We treat this as a hard error rather than a
235
+ * silent acceptance: wallet UIs should surface it so the holder
236
+ * understands the request is suspicious.
237
+ *
238
+ * Matches both shapes AnonCreds supports for revealed attributes:
239
+ * - `requested_attributes[<ref>].name = "kanonZkSig"`
240
+ * - `requested_attributes[<ref>].names = [..., "kanonZkSig", ...]`
241
+ */
242
+ function assertProofRequestDoesNotAskForKanonZkSig(agentContext, options) {
243
+ const requested = options.proofRequest?.requested_attributes;
244
+ if (!requested) return;
245
+ for (const [referent, meta] of Object.entries(requested)) {
246
+ const requestedName = meta?.name;
247
+ const requestedNames = Array.isArray(meta?.names) ? meta.names : [];
248
+ if (requestedName === KANON_ZK_SIG_ATTRIBUTE || requestedNames.includes(KANON_ZK_SIG_ATTRIBUTE)) {
249
+ const msg = `kanon: refusing to disclose the reserved '${KANON_ZK_SIG_ATTRIBUTE}' attribute (proof-request referent '${referent}') — revealing it across presentations would link the holder. The verifier should NEVER request this attribute.`;
250
+ agentContext.config.logger.warn(msg);
251
+ throw new Error(msg);
252
+ }
253
+ }
254
+ }
255
+ function collectCredDefIds(options) {
256
+ const out = /* @__PURE__ */ new Set();
257
+ for (const match of Object.values(options.selectedCredentials.attributes ?? {})) {
258
+ const id = match?.credentialInfo?.credentialDefinitionId;
259
+ if (typeof id === "string") out.add(id);
260
+ }
261
+ for (const match of Object.values(options.selectedCredentials.predicates ?? {})) {
262
+ const id = match?.credentialInfo?.credentialDefinitionId;
263
+ if (typeof id === "string") out.add(id);
264
+ }
265
+ return out;
266
+ }
267
+ /**
268
+ * Find the first attribute the verifier asked the holder to REVEAL for the
269
+ * given credDef, returning its name + the value the credential holds for it.
270
+ *
271
+ * The lookup walks `selectedCredentials.attributes` for entries that are:
272
+ * 1. Backed by a credential whose credentialDefinitionId === credDefId
273
+ * 2. Set to `revealed: true` in the selection
274
+ * For each match it reads the proof request's `requested_attributes[ref]`
275
+ * to learn the attribute name (or names[0]).
276
+ *
277
+ * Reserved kanon names (`kanonCredId`, `kanonZkSig`) are NOT eligible —
278
+ * `kanonZkSig` is refused outright (see `assertProofRequestDoesNotAskForKanonZkSig`)
279
+ * and `kanonCredId` would defeat the unlinkability the SNARK is meant to
280
+ * provide. Returns `null` when no eligible revealed attribute exists, which
281
+ * the caller turns into a clear "verifier needs to request something
282
+ * revealed" error.
283
+ */
284
+ function findRevealedAttributeForCredDef(options, credDefId) {
285
+ const requested = options.proofRequest?.requested_attributes ?? {};
286
+ for (const [ref, match] of Object.entries(options.selectedCredentials.attributes ?? {})) {
287
+ if (match?.credentialInfo?.credentialDefinitionId !== credDefId) continue;
288
+ if (!match.revealed) continue;
289
+ const meta = requested[ref];
290
+ if (!meta) continue;
291
+ const candidates = meta.name ? [meta.name] : Array.isArray(meta.names) ? meta.names : [];
292
+ for (const name of candidates) {
293
+ if (name === KANON_CRED_ID_ATTRIBUTE || name === KANON_ZK_SIG_ATTRIBUTE) continue;
294
+ const value = match.credentialInfo.attributes[name];
295
+ if (typeof value === "string") return {
296
+ name,
297
+ value
298
+ };
299
+ }
300
+ }
301
+ return null;
302
+ }
303
+ /**
304
+ * Find the credentialInfo of the credential selected for `credDefId`. We pick
305
+ * the FIRST match across attributes / predicates — AnonCreds allows a single
306
+ * credential to back many referents so any match is the right one.
307
+ */
308
+ function findCredentialInfoForCredDef(options, credDefId) {
309
+ for (const match of Object.values(options.selectedCredentials.attributes ?? {})) if (match?.credentialInfo?.credentialDefinitionId === credDefId) return match.credentialInfo;
310
+ for (const match of Object.values(options.selectedCredentials.predicates ?? {})) if (match?.credentialInfo?.credentialDefinitionId === credDefId) return match.credentialInfo;
311
+ return null;
312
+ }
313
+
314
+ //#endregion
315
+ export { KanonWrappedAnonCredsHolderService, OriginalAnonCredsHolderServiceSymbol, credDefIdToBytes32, kanonZkProofReferent };
316
+ //# sourceMappingURL=KanonWrappedAnonCredsHolderService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KanonWrappedAnonCredsHolderService.js","names":["TIER_ZK_SNARK"],"sources":["../../../src/anoncreds/services/KanonWrappedAnonCredsHolderService.ts"],"sourcesContent":["import type {\n AnonCredsHolderService,\n CreateCredentialRequestOptions,\n CreateCredentialRequestReturn,\n CreateLinkSecretOptions,\n CreateLinkSecretReturn,\n CreateProofOptions,\n CreateW3cPresentationOptions,\n GetCredentialOptions,\n GetCredentialsForProofRequestOptions,\n GetCredentialsForProofRequestReturn,\n GetCredentialsOptions,\n LegacyToW3cCredentialOptions,\n StoreCredentialOptions,\n W3cToLegacyCredentialOptions,\n} from '@credo-ts/anoncreds'\nimport type { AnonCredsCredentialInfo, AnonCredsProof } from '@credo-ts/anoncreds'\nimport type {\n AgentContext,\n W3cJsonLdVerifiableCredential,\n W3cJsonLdVerifiablePresentation,\n} from '@credo-ts/core'\n\nimport {\n attrValueToFelt,\n BN254_SCALAR_FIELD,\n encodeAttributesCanonical,\n encodeKanonZkProofAttr,\n KANON_CRED_ID_ATTRIBUTE,\n KANON_ZK_PROOF_ATTRIBUTE,\n KANON_ZK_SIG_ATTRIBUTE,\n decodeZkSignature,\n kanonCredIdHash,\n computeZkLeaf,\n} from '@ajna-inc/kanon-sdk'\nimport { ethers } from 'ethers'\nimport { inject, injectable } from '@credo-ts/core'\n\nimport { KanonClientService } from '../../ledger'\nimport { padAttrsToCircuit } from '../../zk/KanonZkService'\nimport { KanonZkPathService } from '../../zk/KanonZkPathService'\n\n/**\n * DI token used by `KanonModule` to register the original\n * `AnonCredsRsHolderService` so the wrapper can inject it without depending\n * on a deep build path.\n */\nexport const OriginalAnonCredsHolderServiceSymbol = Symbol('OriginalAnonCredsHolderService')\n\n/**\n * Bit mask of `TIER_ZK_SNARK`. Inlined to avoid a runtime SDK import for a\n * single-use constant.\n */\nconst TIER_ZK_SNARK = 0b10\n\n/**\n * Wraps the AnonCredsRsHolderService so Mode B presentations are entirely\n * transparent to the application:\n *\n * - Before `createProof` runs, the wrapper inspects the selected\n * credentials. For each credentialDefinitionId that opts into\n * `TIER_ZK_SNARK` on chain, it generates the Groth16 non-revocation proof\n * and injects it as a self-attested attribute named\n * `kanon_<credDefId>_zkProof`.\n *\n * - The presentation that goes over the wire is a plain AnonCreds\n * presentation. The self-attested attribute rides as a normal\n * `requested_proof.self_attested_attrs` entry — anything that speaks\n * AnonCreds can deserialize it, and the corresponding\n * `KanonWrappedAnonCredsVerifierService` will verify it on chain.\n *\n * - For Mode-A-only and non-Kanon credentials the wrapper is a no-op; the\n * inner service handles them unchanged.\n *\n * - Other methods on `AnonCredsHolderService` (createCredentialRequest,\n * storeCredential, getCredentials, …) delegate to inner without\n * modification.\n *\n * No DIDComm message extension, no proof-format URI change, no client-side\n * coordination: the holder just calls `agent.modules.proofs.acceptRequest(…)`\n * and the wrapper does the rest.\n */\n@injectable()\nexport class KanonWrappedAnonCredsHolderService implements AnonCredsHolderService {\n /** Per-credDef on-chain policyMask cache; immutable after registration. */\n private readonly policyCache = new Map<string, number>()\n\n public constructor(\n @inject(OriginalAnonCredsHolderServiceSymbol) private readonly inner: AnonCredsHolderService,\n private readonly clientService: KanonClientService,\n private readonly pathService: KanonZkPathService\n ) {}\n\n public async createProof(\n agentContext: AgentContext,\n options: CreateProofOptions\n ): Promise<AnonCredsProof> {\n // Defensive: the BabyJubjub signature on the credential's leaf\n // (`kanonZkSig`) is a credential-unique handle. If a verifier asks the\n // holder to disclose it via a proof request, the holder would emit the\n // same value across every presentation — linkable across verifiers and\n // across time. The wrapper refuses to participate. Wallet UIs that\n // would otherwise silently include this attribute will surface this\n // error to the user.\n assertProofRequestDoesNotAskForKanonZkSig(agentContext, options)\n const augmented = await this.augmentSelfAttested(agentContext, options)\n return this.inner.createProof(agentContext, augmented)\n }\n\n // ─── transparent delegates ────────────────────────────────────────────\n\n public createLinkSecret(\n agentContext: AgentContext,\n options: CreateLinkSecretOptions\n ): Promise<CreateLinkSecretReturn> {\n return this.inner.createLinkSecret(agentContext, options)\n }\n\n public createCredentialRequest(\n agentContext: AgentContext,\n options: CreateCredentialRequestOptions\n ): Promise<CreateCredentialRequestReturn> {\n return this.inner.createCredentialRequest(agentContext, options)\n }\n\n public storeCredential(\n agentContext: AgentContext,\n options: StoreCredentialOptions,\n metadata?: Record<string, unknown>\n ): Promise<string> {\n return this.inner.storeCredential(agentContext, options, metadata)\n }\n\n public getCredential(\n agentContext: AgentContext,\n options: GetCredentialOptions\n ): Promise<AnonCredsCredentialInfo> {\n return this.inner.getCredential(agentContext, options)\n }\n\n public getCredentials(\n agentContext: AgentContext,\n options: GetCredentialsOptions\n ): Promise<AnonCredsCredentialInfo[]> {\n return this.inner.getCredentials(agentContext, options)\n }\n\n public deleteCredential(agentContext: AgentContext, credentialId: string): Promise<void> {\n return this.inner.deleteCredential(agentContext, credentialId)\n }\n\n public getCredentialsForProofRequest(\n agentContext: AgentContext,\n options: GetCredentialsForProofRequestOptions\n ): Promise<GetCredentialsForProofRequestReturn> {\n return this.inner.getCredentialsForProofRequest(agentContext, options)\n }\n\n public createW3cPresentation(\n agentContext: AgentContext,\n options: CreateW3cPresentationOptions\n ): Promise<W3cJsonLdVerifiablePresentation> {\n // W3C presentations don't route through `createProof`; Mode B over W3C is\n // a separate follow-on (the binding is different — VC subject + JSON-LD\n // proof). We delegate untouched so the W3C path stays standard.\n return this.inner.createW3cPresentation(agentContext, options)\n }\n\n public w3cToLegacyCredential(\n agentContext: AgentContext,\n options: W3cToLegacyCredentialOptions\n ): Promise<import('@credo-ts/anoncreds').AnonCredsCredential> {\n return this.inner.w3cToLegacyCredential(agentContext, options)\n }\n\n public legacyToW3cCredential(\n agentContext: AgentContext,\n options: LegacyToW3cCredentialOptions\n ): Promise<W3cJsonLdVerifiableCredential> {\n return this.inner.legacyToW3cCredential(agentContext, options)\n }\n\n public generateNonce(agentContext: AgentContext): string {\n return this.inner.generateNonce(agentContext)\n }\n\n // ─── Mode B injection ────────────────────────────────────────────────\n\n /**\n * For every Mode B credential referenced in `selectedCredentials`, compute\n * the SNARK proof and add it to `selfAttestedAttributes` under\n * `kanon_<credDefId>_zkProof`. The original options object is left\n * untouched — we return a shallow copy with augmented self-attested attrs.\n */\n private async augmentSelfAttested(\n agentContext: AgentContext,\n options: CreateProofOptions\n ): Promise<CreateProofOptions> {\n const credDefIds = collectCredDefIds(options)\n if (credDefIds.size === 0) return options\n\n // Filter to Mode B credDefs the VERIFIER actually asked for.\n //\n // Graceful degradation: anoncreds-rs verifyProof rejects any\n // `self_attested_attrs` entry that isn't declared as a\n // `requested_attribute`. So if the verifier sent a vanilla proof\n // request (no kanon referent), we silently fall back to standard\n // AnonCreds — interop with non-Kanon verifiers works at the cost of\n // skipping the on-chain non-revocation check on that one hop. The\n // verifier opts in by including `kanon_<credDefId>_zkProof` in their\n // request (via `buildKanonProofRequest`, or by hand).\n //\n // The Mode A status check has the same semantics: only Kanon-aware\n // verifiers consult the on-chain status registry. Mode B follows the\n // same opt-in pattern.\n const requestedAttrs = ((options.proofRequest as { requested_attributes?: Record<string, unknown> })\n ?.requested_attributes ?? {}) as Record<string, unknown>\n const modeB: string[] = []\n for (const credDefId of credDefIds) {\n const mask = await this.getPolicyMask(agentContext, credDefId)\n if ((mask & TIER_ZK_SNARK) === 0) continue\n const ref = kanonZkProofReferent(credDefId)\n if (!(ref in requestedAttrs)) {\n agentContext.config.logger.debug(\n `KanonWrappedAnonCredsHolderService: Mode B credDef ${credDefId} present but verifier did not request ${ref} — skipping SNARK injection (proof will be a standard AnonCreds presentation)`\n )\n continue\n }\n modeB.push(credDefId)\n }\n if (modeB.length === 0) return options\n\n const challenge = await this.challengeFromProofRequest(options)\n const augmentedSelfAttested: Record<string, string> = {\n ...(options.selectedCredentials.selfAttestedAttributes ?? {}),\n }\n\n for (const credDefId of modeB) {\n try {\n const credInfo = findCredentialInfoForCredDef(options, credDefId)\n if (!credInfo) {\n agentContext.config.logger.warn(\n `KanonWrappedAnonCredsHolderService: Mode B credDef ${credDefId} referenced in selection but no credentialInfo found — skipping injection (proof will likely fail)`\n )\n continue\n }\n // Find which credential attribute the verifier asked the holder to\n // reveal for this credDef. The SNARK's `disclosedIndex` /\n // `disclosedValue` public signals will be BOUND to exactly that\n // attribute so a verifier (a) cannot link presentations by the\n // disclosed slot — the slot mirrors what AnonCreds is already\n // revealing, never more — and (b) gets a cryptographic guarantee\n // that the AnonCreds-revealed value is the same one the SNARK saw.\n const revealed = findRevealedAttributeForCredDef(options, credDefId)\n if (!revealed) {\n throw new Error(\n `kanon: Mode B credDef ${credDefId} is in the presentation but the verifier did not request any revealed attribute restricted to it. ` +\n `Mode B requires the SNARK's disclosed slot to be bound to an AnonCreds-revealed attribute — otherwise either the SNARK leaks something AnonCreds isn't, or every presentation shares the same disclosed slot (linkable). ` +\n `Have the verifier add at least one revealed requested_attribute with restrictions: [{ cred_def_id: '${credDefId}' }].`\n )\n }\n const referent = kanonZkProofReferent(credDefId)\n const encoded = await this.buildZkProofAttr(\n agentContext,\n credDefId,\n credInfo,\n challenge,\n revealed\n )\n augmentedSelfAttested[referent] = encoded\n agentContext.config.logger.debug(\n `KanonWrappedAnonCredsHolderService: injected ${referent} for credId=${credInfo.credentialId}, disclosing '${revealed.name}'`\n )\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n agentContext.config.logger.error(\n `KanonWrappedAnonCredsHolderService: failed to build Mode B proof for ${credDefId}: ${message}`\n )\n throw err\n }\n }\n\n // No proof-request mutation needed: we already filtered above to only\n // Mode B credDefs whose `kanon_<credDefId>_zkProof` referent was\n // declared by the verifier. Adding it again would be a no-op.\n return {\n ...options,\n selectedCredentials: {\n ...options.selectedCredentials,\n selfAttestedAttributes: augmentedSelfAttested,\n },\n }\n }\n\n private async buildZkProofAttr(\n agentContext: AgentContext,\n credDefId: string,\n credInfo: AnonCredsCredentialInfo,\n challenge: bigint,\n revealed: { name: string; value: string }\n ): Promise<string> {\n const attrs = credInfo.attributes\n const kanonCredId = attrs[KANON_CRED_ID_ATTRIBUTE]\n const kanonZkSig = attrs[KANON_ZK_SIG_ATTRIBUTE]\n if (typeof kanonCredId !== 'string' || typeof kanonZkSig !== 'string') {\n throw new Error(\n `kanon-zk: credential ${credInfo.credentialId} for Mode B credDef ${credDefId} is missing ${KANON_CRED_ID_ATTRIBUTE} / ${KANON_ZK_SIG_ATTRIBUTE} attributes — was it issued through prepareModeBCredential?`\n )\n }\n\n // Felt-encode using the SDK's CANONICAL ordering (lexicographic byte\n // sort of attribute names, SDK-reserved names excluded). Same encoder\n // as `prepareModeBCredential` and `extractLeafAttributes`, so all\n // three sites produce the same leaf without depending on JS object\n // iteration order surviving anoncreds-rs serialization.\n const values: Record<string, string> = {}\n for (const [name, value] of Object.entries(attrs)) {\n if (typeof value === 'string') values[name] = value\n }\n const domainAttrFelts = encodeAttributesCanonical(values)\n const paddedAttrs = padAttrsToCircuit(domainAttrFelts)\n\n // Resolve the disclosed slot AGAINST the canonical order so the SNARK's\n // `disclosedIndex` lines up with `paddedAttrs[i]`. The slot bound here is\n // the one the verifier asked AnonCreds to reveal — the SNARK adds a\n // cryptographic guarantee that the value AnonCreds revealed is the same\n // value the SNARK saw, but it does NOT leak any attribute the verifier\n // didn't already see in the AnonCreds proof.\n const sortedDomainNames = Object.keys(values)\n .filter((n) => n !== KANON_CRED_ID_ATTRIBUTE && n !== KANON_ZK_SIG_ATTRIBUTE)\n .sort()\n const disclosedIndex = sortedDomainNames.indexOf(revealed.name)\n if (disclosedIndex < 0) {\n throw new Error(\n `kanon-zk: verifier asked to reveal '${revealed.name}' but the credential's domain attributes don't include it (after stripping kanon-reserved names). Available: ${sortedDomainNames.join(', ')}`\n )\n }\n const disclosedValue = paddedAttrs[disclosedIndex]\n // Defensive: the felt at the canonical slot MUST match the felt-encoding\n // of the revealed value the verifier sees in the AnonCreds proof. Any\n // mismatch means the holder's view of the attribute differs from the\n // verifier's — bail loudly rather than producing a proof the verifier\n // will silently reject.\n const expectedRevealedFelt = attrValueToFelt(revealed.value)\n if (disclosedValue !== expectedRevealedFelt) {\n throw new Error(\n `kanon-zk: internal felt-encoding mismatch for '${revealed.name}' — canonical slot ${disclosedIndex} holds ${disclosedValue} but the revealed value encodes to ${expectedRevealedFelt}. This indicates a bug in attribute encoding or canonical ordering.`\n )\n }\n\n // Compute the local Poseidon leaf so the path lookup can find it.\n const credDefFelt = BigInt(credDefIdToBytes32(credDefId)) % BN254_SCALAR_FIELD\n const credIdFelt = BigInt(kanonCredIdHash(kanonCredId)) % BN254_SCALAR_FIELD\n const leaf = await computeZkLeaf(credDefFelt, credIdFelt, paddedAttrs)\n\n const pathInfo = await this.pathService.findPath(agentContext, credDefId, leaf)\n if (!pathInfo) {\n throw new Error(\n `kanon-zk: could not find Merkle path for credential ${credInfo.credentialId} in credDef ${credDefId} — credential may have been revoked or not yet published`\n )\n }\n\n // Look up the on-chain issuer pubkey so the circuit and the registry\n // agree on `(Ax, Ay)`.\n const credDefRegistry = this.clientService.contracts.credDefRegistry as unknown as {\n getIssuerZkPubKey: (credDefId: string) => Promise<{ ax: bigint; ay: bigint; set: boolean }>\n }\n const onChainKey = await credDefRegistry.getIssuerZkPubKey(credDefIdToBytes32(credDefId))\n if (!onChainKey.set) {\n throw new Error(`kanon-zk: credDef ${credDefId} has no Tier 2 key published`)\n }\n\n const sig = decodeZkSignature(kanonZkSig)\n\n // Witness — exactly the layout the compiled circuit expects.\n const input = {\n root: pathInfo.root.toString(),\n credDefId: credDefFelt.toString(),\n challenge: challenge.toString(),\n issuerAx: BigInt(onChainKey.ax).toString(),\n issuerAy: BigInt(onChainKey.ay).toString(),\n // Bound to the AnonCreds-revealed attribute resolved above — same\n // canonical-sort position the leaf used, same felt value the verifier\n // sees in the AnonCreds proof. This is the privacy hinge: as long as\n // both sides only use this slot for attributes the verifier ALREADY\n // sees via AnonCreds, the SNARK's public signals don't leak anything\n // new across presentations.\n disclosedIndex: [disclosedIndex.toString()],\n disclosedValue: [disclosedValue.toString()],\n credId: credIdFelt.toString(),\n attributes: paddedAttrs.map((a) => a.toString()),\n pathElements: pathInfo.pathElements.map((p) => p.toString()),\n pathIndices: pathInfo.pathIndices.map((p) => p.toString()),\n sigS: sig.S.toString(),\n sigR8x: sig.R8x.toString(),\n sigR8y: sig.R8y.toString(),\n }\n\n // Dynamic snarkjs import (it has no types). The string-variable\n // indirection prevents tsdown from trying to resolve at build time.\n type SnarkjsModule = {\n groth16: {\n fullProve: (\n input: unknown,\n wasmPath: string,\n zkeyPath: string\n ) => Promise<{ proof: unknown; publicSignals: string[] }>\n exportSolidityCallData: (proof: unknown, publicSignals: string[]) => Promise<string>\n }\n }\n const snarkjsModuleName = 'snarkjs'\n const snarkjs = (await import(snarkjsModuleName)) as unknown as SnarkjsModule\n const wasmPath = process.env.KANON_ZK_WASM\n const zkeyPath = process.env.KANON_ZK_ZKEY\n if (!wasmPath || !zkeyPath) {\n throw new Error(\n 'kanon-zk: KANON_ZK_WASM and KANON_ZK_ZKEY env vars must point at the snarkjs artifacts (non_revocation.wasm + nr_final.zkey) for Mode B presentations to work'\n )\n }\n const { proof, publicSignals } = await snarkjs.groth16.fullProve(input, wasmPath, zkeyPath)\n const calldata = await snarkjs.groth16.exportSolidityCallData(proof, publicSignals)\n const [a, b, c] = JSON.parse('[' + calldata + ']') as [\n [string, string],\n [[string, string], [string, string]],\n [string, string],\n string[],\n ]\n const proofBytes = ethers.AbiCoder.defaultAbiCoder().encode(\n ['uint256[2]', 'uint256[2][2]', 'uint256[2]'],\n [a, b, c]\n )\n const toBytes32 = (v: string) => '0x' + BigInt(v).toString(16).padStart(64, '0')\n return encodeKanonZkProofAttr({\n proofBytes,\n publicSignals: publicSignals.map(toBytes32),\n })\n }\n\n private async getPolicyMask(agentContext: AgentContext, credDefId: string): Promise<number> {\n const cached = this.policyCache.get(credDefId)\n if (cached !== undefined) return cached\n try {\n // `getCredDefPolicy` reads the on-chain credDef, whose key is the bytes32\n // resourceId hash (keccak256(utf8(credDefId))) — NOT the raw DID URL.\n // Passing the DID URL makes ethers reject it, so the catch below silently\n // fell back to \"Mode A only\" and Mode B credentials never got a SNARK.\n const mask = await this.clientService.client.getCredDefPolicy(credDefIdToBytes32(credDefId))\n this.policyCache.set(credDefId, mask)\n return mask\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n agentContext.config.logger.debug(\n `KanonWrappedAnonCredsHolderService: getCredDefPolicy(${credDefId}) failed (${message}); assuming Mode A only`\n )\n this.policyCache.set(credDefId, 0b01)\n return 0b01\n }\n }\n\n /**\n * Bind the SNARK challenge to the verifier's session. We use the\n * `proofRequest.nonce` directly — AnonCreds already guarantees freshness\n * + binding to this exchange, which is exactly the property the verifier\n * needs to detect replay.\n */\n private async challengeFromProofRequest(options: CreateProofOptions): Promise<bigint> {\n // biome-ignore lint/suspicious/noExplicitAny: proofRequest is a permissive AnonCreds JSON\n const nonce: string | undefined = (options.proofRequest as any)?.nonce\n if (!nonce) {\n throw new Error('kanon-zk: proofRequest is missing nonce — cannot derive Mode B challenge')\n }\n // AnonCreds nonces are decimal strings; convert to felt.\n return BigInt(nonce) % BN254_SCALAR_FIELD\n }\n}\n\n/** `kanon_<credDefId>_zkProof` — the self-attested attribute name we inject. */\nexport function kanonZkProofReferent(credDefId: string): string {\n return `kanon_${credDefId.toLowerCase()}_zkProof`\n}\n\n/**\n * credDef on-chain key — `keccak256(utf8(credDefId))`, or pass an already\n * bytes32 value through unchanged. Mirrors the SDK's `resourceIdToBytes32`\n * (and `KanonApi.toBytes32CredDefId`). `getCredDefPolicy` and the other\n * registry reads are keyed by this, NOT the raw AnonCreds DID URL.\n */\nexport function credDefIdToBytes32(credDefId: string): string {\n if (/^0x[0-9a-fA-F]{64}$/.test(credDefId)) return credDefId\n return ethers.keccak256(ethers.toUtf8Bytes(credDefId))\n}\n\n/**\n * Insert the `kanon_<credDefId>_zkProof` referents into a proof request's\n * `requested_attributes` so anoncreds-rs's createProof / verifyProof accept\n * them as self-attestable. Exported so the verifier wrapper applies the\n * identical augmentation before delegating to `verifyProof` — keeping the\n * referent set symmetric on both sides.\n *\n * `name` is set to the SDK-reserved `kanonZkProof` constant — the value is\n * the base64 SNARK blob; nothing else looks at the name once anoncreds-rs\n * accepts the referent. `restrictions` is intentionally omitted, which is\n * how anoncreds marks an attribute as self-attestable.\n *\n * No-ops when the referent is already declared (caller might have used\n * `buildKanonProofRequest` which adds them up-front).\n */\nexport function augmentProofRequestForKanon<T extends Record<string, unknown>>(\n proofRequest: T,\n credDefIds: Iterable<string>\n): T {\n const requested = {\n ...((proofRequest as { requested_attributes?: Record<string, unknown> }).requested_attributes ?? {}),\n }\n let mutated = false\n for (const credDefId of credDefIds) {\n const ref = kanonZkProofReferent(credDefId)\n if (ref in requested) continue\n requested[ref] = { name: KANON_ZK_PROOF_ATTRIBUTE }\n mutated = true\n }\n if (!mutated) return proofRequest\n return { ...proofRequest, requested_attributes: requested }\n}\n\n// ─── helpers ────────────────────────────────────────────────────────────\n\n/**\n * Throws if the proof request asks the holder to disclose the\n * `kanonZkSig` attribute via any requested-attributes referent.\n *\n * The kanonZkSig is a per-credential constant (the issuer's BabyJubjub\n * EdDSA signature over the leaf). Disclosing it across multiple\n * presentations defeats the Mode B unlinkability guarantee — every\n * verifier that sees it gets the same value, trivially correlating the\n * holder across sessions. We treat this as a hard error rather than a\n * silent acceptance: wallet UIs should surface it so the holder\n * understands the request is suspicious.\n *\n * Matches both shapes AnonCreds supports for revealed attributes:\n * - `requested_attributes[<ref>].name = \"kanonZkSig\"`\n * - `requested_attributes[<ref>].names = [..., \"kanonZkSig\", ...]`\n */\nfunction assertProofRequestDoesNotAskForKanonZkSig(\n agentContext: AgentContext,\n options: CreateProofOptions\n): void {\n const requested = (options.proofRequest as { requested_attributes?: Record<string, unknown> })\n ?.requested_attributes\n if (!requested) return\n for (const [referent, meta] of Object.entries(requested)) {\n const requestedName = (meta as { name?: string })?.name\n const requestedNames = Array.isArray((meta as { names?: string[] })?.names)\n ? ((meta as { names: string[] }).names as string[])\n : []\n const asksForKanonZkSig =\n requestedName === KANON_ZK_SIG_ATTRIBUTE ||\n requestedNames.includes(KANON_ZK_SIG_ATTRIBUTE)\n if (asksForKanonZkSig) {\n const msg = `kanon: refusing to disclose the reserved '${KANON_ZK_SIG_ATTRIBUTE}' attribute (proof-request referent '${referent}') — revealing it across presentations would link the holder. The verifier should NEVER request this attribute.`\n agentContext.config.logger.warn(msg)\n throw new Error(msg)\n }\n }\n}\n\nfunction collectCredDefIds(options: CreateProofOptions): Set<string> {\n const out = new Set<string>()\n for (const match of Object.values(options.selectedCredentials.attributes ?? {})) {\n const id = match?.credentialInfo?.credentialDefinitionId\n if (typeof id === 'string') out.add(id)\n }\n for (const match of Object.values(options.selectedCredentials.predicates ?? {})) {\n const id = match?.credentialInfo?.credentialDefinitionId\n if (typeof id === 'string') out.add(id)\n }\n return out\n}\n\n/**\n * Find the first attribute the verifier asked the holder to REVEAL for the\n * given credDef, returning its name + the value the credential holds for it.\n *\n * The lookup walks `selectedCredentials.attributes` for entries that are:\n * 1. Backed by a credential whose credentialDefinitionId === credDefId\n * 2. Set to `revealed: true` in the selection\n * For each match it reads the proof request's `requested_attributes[ref]`\n * to learn the attribute name (or names[0]).\n *\n * Reserved kanon names (`kanonCredId`, `kanonZkSig`) are NOT eligible —\n * `kanonZkSig` is refused outright (see `assertProofRequestDoesNotAskForKanonZkSig`)\n * and `kanonCredId` would defeat the unlinkability the SNARK is meant to\n * provide. Returns `null` when no eligible revealed attribute exists, which\n * the caller turns into a clear \"verifier needs to request something\n * revealed\" error.\n */\nfunction findRevealedAttributeForCredDef(\n options: CreateProofOptions,\n credDefId: string\n): { name: string; value: string } | null {\n const requested = (options.proofRequest as { requested_attributes?: Record<string, unknown> })\n ?.requested_attributes ?? {}\n for (const [ref, match] of Object.entries(options.selectedCredentials.attributes ?? {})) {\n if (match?.credentialInfo?.credentialDefinitionId !== credDefId) continue\n if (!match.revealed) continue\n const meta = requested[ref] as { name?: string; names?: string[] } | undefined\n if (!meta) continue\n const candidates: string[] = meta.name\n ? [meta.name]\n : Array.isArray(meta.names)\n ? meta.names\n : []\n for (const name of candidates) {\n if (name === KANON_CRED_ID_ATTRIBUTE || name === KANON_ZK_SIG_ATTRIBUTE) continue\n const value = match.credentialInfo.attributes[name]\n if (typeof value === 'string') return { name, value }\n }\n }\n return null\n}\n\n/**\n * Find the credentialInfo of the credential selected for `credDefId`. We pick\n * the FIRST match across attributes / predicates — AnonCreds allows a single\n * credential to back many referents so any match is the right one.\n */\nfunction findCredentialInfoForCredDef(\n options: CreateProofOptions,\n credDefId: string\n): AnonCredsCredentialInfo | null {\n for (const match of Object.values(options.selectedCredentials.attributes ?? {})) {\n if (match?.credentialInfo?.credentialDefinitionId === credDefId) {\n return match.credentialInfo\n }\n }\n for (const match of Object.values(options.selectedCredentials.predicates ?? {})) {\n if (match?.credentialInfo?.credentialDefinitionId === credDefId) {\n return match.credentialInfo\n }\n }\n return null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+CA,MAAa,uCAAuC,OAAO,iCAAiC;;;;;AAM5F,MAAMA,kBAAgB;AA8Bf,+CAAM,mCAAqE;CAIhF,AAAO,YACL,AAA+D,OAC/D,AAAiB,eACjB,AAAiB,aACjB;EAH+D;EAC9C;EACA;OALF,8BAAc,IAAI,KAAqB;;CAQxD,MAAa,YACX,cACA,SACyB;AAQzB,4CAA0C,cAAc,QAAQ;EAChE,MAAM,YAAY,MAAM,KAAK,oBAAoB,cAAc,QAAQ;AACvE,SAAO,KAAK,MAAM,YAAY,cAAc,UAAU;;CAKxD,AAAO,iBACL,cACA,SACiC;AACjC,SAAO,KAAK,MAAM,iBAAiB,cAAc,QAAQ;;CAG3D,AAAO,wBACL,cACA,SACwC;AACxC,SAAO,KAAK,MAAM,wBAAwB,cAAc,QAAQ;;CAGlE,AAAO,gBACL,cACA,SACA,UACiB;AACjB,SAAO,KAAK,MAAM,gBAAgB,cAAc,SAAS,SAAS;;CAGpE,AAAO,cACL,cACA,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AAK,UAAU,OAAO,QAAQ,QAAQ,oBAAoB,cAAc,EAAE,CAAC,EAAE;AACvF,MAAI,OAAO,gBAAgB,2BAA2B,UAAW;AACjE,MAAI,CAAC,MAAM,SAAU;EACrB,MAAM,OAAO,UAAU;AACvB,MAAI,CAAC,KAAM;EACX,MAAM,aAAuB,KAAK,OAC9B,CAAC,KAAK,KAAK,GACX,MAAM,QAAQ,KAAK,MAAM,GACvB,KAAK,QACL,EAAE;AACR,OAAK,MAAM,QAAQ,YAAY;AAC7B,OAAI,SAAS,2BAA2B,SAAS,uBAAwB;GACzE,MAAM,QAAQ,MAAM,eAAe,WAAW;AAC9C,OAAI,OAAO,UAAU,SAAU,QAAO;IAAE;IAAM;IAAO;;;AAGzD,QAAO;;;;;;;AAQT,SAAS,6BACP,SACA,WACgC;AAChC,MAAK,MAAM,SAAS,OAAO,OAAO,QAAQ,oBAAoB,cAAc,EAAE,CAAC,CAC7E,KAAI,OAAO,gBAAgB,2BAA2B,UACpD,QAAO,MAAM;AAGjB,MAAK,MAAM,SAAS,OAAO,OAAO,QAAQ,oBAAoB,cAAc,EAAE,CAAC,CAC7E,KAAI,OAAO,gBAAgB,2BAA2B,UACpD,QAAO,MAAM;AAGjB,QAAO"}
@@ -0,0 +1,67 @@
1
+ import { KanonClientService } from "../../ledger/KanonClientService.js";
2
+ import "../../ledger/index.js";
3
+ import { AgentContext } from "@credo-ts/core";
4
+ import { AnonCredsVerifierService, VerifyProofOptions, VerifyW3cPresentationOptions } from "@credo-ts/anoncreds";
5
+
6
+ //#region src/anoncreds/services/KanonWrappedAnonCredsVerifierService.d.ts
7
+ /**
8
+ * Injection token used by {@link KanonModule} to register the original
9
+ * `AnonCredsRsVerifierService` so the {@link KanonWrappedAnonCredsVerifierService}
10
+ * can inject it without pulling in a deep `@credo-ts/anoncreds/build/...` import.
11
+ *
12
+ * The module registers the original verifier under this symbol, then overrides
13
+ * the public `AnonCredsVerifierServiceSymbol` binding with the wrapper.
14
+ */
15
+ declare const OriginalAnonCredsVerifierServiceSymbol: unique symbol;
16
+ /**
17
+ * Wraps Credo's default `AnonCredsVerifierService` so that, after the standard
18
+ * AnonCreds proof verifies, the verifier additionally checks the on-chain
19
+ * `AnonCredsStatusRegistry` for revocation. Both checks must pass.
20
+ *
21
+ * Privacy model: the credential schema must include the canonical `kanonCredId`
22
+ * attribute and the verifier proof request must mark it as revealed. The verifier
23
+ * extracts the disclosed value, hashes it with `kanonCredIdHash`, and looks up
24
+ * the (credDefId, credIdHash) status.
25
+ *
26
+ * If no AnonCredsStatusRegistry is configured on the Kanon module, this wrapper
27
+ * skips the on-chain check and returns whatever the inner verifier returned —
28
+ * useful for tests and for credentials not under kanon governance.
29
+ */
30
+ declare class KanonWrappedAnonCredsVerifierService implements AnonCredsVerifierService {
31
+ private readonly inner;
32
+ private readonly ledgerService;
33
+ constructor(inner: AnonCredsVerifierService, ledgerService: KanonClientService);
34
+ verifyProof(agentContext: AgentContext, options: VerifyProofOptions): Promise<boolean>;
35
+ /**
36
+ * Verify the Mode B SNARK proof carried by each Tier-2 credDef in the
37
+ * presentation.
38
+ *
39
+ * For every credDef referenced in `proof.identifiers` whose on-chain
40
+ * policyMask includes `TIER_ZK_SNARK`, we look for
41
+ * `proof.requested_proof.self_attested_attrs[kanon_<credDefId>_zkProof]`,
42
+ * decode it, and submit to `MerkleStateRegistry.verifyZKMembership`. Any
43
+ * missing or rejected proof fails the whole presentation.
44
+ *
45
+ * Mode A-only credDefs are unaffected — their presentations don't carry a
46
+ * `kanonZkProof` referent and this check is a no-op for them.
47
+ */
48
+ /**
49
+ * Scan `proof.identifiers` for credDefs that satisfy BOTH:
50
+ *
51
+ * 1. On-chain policyMask includes `TIER_ZK_SNARK` (the credDef opted into
52
+ * Mode B at registration).
53
+ * 2. This verifier's proof request DECLARED the
54
+ * `kanon_<credDefId>_zkProof` referent (the verifier opted in to
55
+ * checking it here).
56
+ *
57
+ * Both conditions must hold — Mode B is opt-in per-verifier-per-request.
58
+ */
59
+ private collectModeBCredDefIds;
60
+ private verifyModeBProofs;
61
+ private readonly policyCache;
62
+ private getPolicyMask;
63
+ verifyW3cPresentation(agentContext: AgentContext, options: VerifyW3cPresentationOptions): Promise<boolean>;
64
+ }
65
+ //#endregion
66
+ export { KanonWrappedAnonCredsVerifierService, OriginalAnonCredsVerifierServiceSymbol };
67
+ //# sourceMappingURL=KanonWrappedAnonCredsVerifierService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KanonWrappedAnonCredsVerifierService.d.ts","names":[],"sources":["../../../src/anoncreds/services/KanonWrappedAnonCredsVerifierService.ts"],"mappings":";;;;;;;;;AA4BA;;;;;cAAa,sCAAA;;;;;;;;;;;;;;;cAiBA,oCAAA,YAAgD,wBAAA;EAAA,iBAEQ,KAAA;EAAA,iBAChD,aAAA;cADgD,KAAA,EAAO,wBAAA,EACvD,aAAA,EAAe,kBAAA;EAGrB,WAAA,CAAY,YAAA,EAAc,YAAA,EAAc,OAAA,EAAS,kBAAA,GAAqB,OAAA;EAHjD;;;;;;;;;;;;;EAgRlB;;;;;;;;;;;EAAA,QAzKF,sBAAA;EAAA,QA0BA,iBAAA;EAAA,iBAwHG,WAAA;EAAA,QAEH,aAAA;EAoBD,qBAAA,CACX,YAAA,EAAc,YAAA,EACd,OAAA,EAAS,4BAAA,GACR,OAAA;AAAA"}