@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.
- package/LICENSE +201 -0
- package/README.md +156 -2
- package/build/KanonApi.d.ts +52 -0
- package/build/KanonApi.d.ts.map +1 -0
- package/build/KanonApi.js +92 -0
- package/build/KanonApi.js.map +1 -0
- package/build/KanonModule.d.ts +15 -0
- package/build/KanonModule.d.ts.map +1 -0
- package/build/KanonModule.js +53 -0
- package/build/KanonModule.js.map +1 -0
- package/build/KanonModuleConfig.d.ts +123 -0
- package/build/KanonModuleConfig.d.ts.map +1 -0
- package/build/KanonModuleConfig.js +84 -0
- package/build/KanonModuleConfig.js.map +1 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.js +10 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.js +7 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.js +9 -0
- package/build/anoncreds/helpers/buildKanonCredentialAttributes.d.ts +33 -0
- package/build/anoncreds/helpers/buildKanonCredentialAttributes.d.ts.map +1 -0
- package/build/anoncreds/helpers/buildKanonCredentialAttributes.js +43 -0
- package/build/anoncreds/helpers/buildKanonCredentialAttributes.js.map +1 -0
- package/build/anoncreds/helpers/buildKanonProofRequest.d.ts +45 -0
- package/build/anoncreds/helpers/buildKanonProofRequest.d.ts.map +1 -0
- package/build/anoncreds/helpers/buildKanonProofRequest.js +45 -0
- package/build/anoncreds/helpers/buildKanonProofRequest.js.map +1 -0
- package/build/anoncreds/helpers/buildKanonSchema.d.ts +23 -0
- package/build/anoncreds/helpers/buildKanonSchema.d.ts.map +1 -0
- package/build/anoncreds/helpers/buildKanonSchema.js +27 -0
- package/build/anoncreds/helpers/buildKanonSchema.js.map +1 -0
- package/build/anoncreds/helpers/index.js +3 -0
- package/build/anoncreds/index.d.ts +8 -0
- package/build/anoncreds/index.js +9 -0
- package/build/anoncreds/services/KanonAnonCredsRegistry.d.ts +36 -0
- package/build/anoncreds/services/KanonAnonCredsRegistry.d.ts.map +1 -0
- package/build/anoncreds/services/KanonAnonCredsRegistry.js +298 -0
- package/build/anoncreds/services/KanonAnonCredsRegistry.js.map +1 -0
- package/build/anoncreds/services/KanonIssuanceTracker.d.ts +39 -0
- package/build/anoncreds/services/KanonIssuanceTracker.d.ts.map +1 -0
- package/build/anoncreds/services/KanonIssuanceTracker.js +141 -0
- package/build/anoncreds/services/KanonIssuanceTracker.js.map +1 -0
- package/build/anoncreds/services/KanonWrappedAnonCredsHolderService.d.ts +82 -0
- package/build/anoncreds/services/KanonWrappedAnonCredsHolderService.d.ts.map +1 -0
- package/build/anoncreds/services/KanonWrappedAnonCredsHolderService.js +316 -0
- package/build/anoncreds/services/KanonWrappedAnonCredsHolderService.js.map +1 -0
- package/build/anoncreds/services/KanonWrappedAnonCredsVerifierService.d.ts +67 -0
- package/build/anoncreds/services/KanonWrappedAnonCredsVerifierService.d.ts.map +1 -0
- package/build/anoncreds/services/KanonWrappedAnonCredsVerifierService.js +330 -0
- package/build/anoncreds/services/KanonWrappedAnonCredsVerifierService.js.map +1 -0
- package/build/anoncreds/utils/credIdHash.d.ts +2 -0
- package/build/anoncreds/utils/credIdHash.js +3 -0
- package/build/dids/KanonDidRegistrar.d.ts +47 -0
- package/build/dids/KanonDidRegistrar.d.ts.map +1 -0
- package/build/dids/KanonDidRegistrar.js +140 -0
- package/build/dids/KanonDidRegistrar.js.map +1 -0
- package/build/dids/KanonDidResolver.d.ts +18 -0
- package/build/dids/KanonDidResolver.d.ts.map +1 -0
- package/build/dids/KanonDidResolver.js +88 -0
- package/build/dids/KanonDidResolver.js.map +1 -0
- package/build/dids/didEtherUtils.d.ts +18 -0
- package/build/dids/didEtherUtils.d.ts.map +1 -0
- package/build/dids/didEtherUtils.js +47 -0
- package/build/dids/didEtherUtils.js.map +1 -0
- package/build/dids/index.js +3 -0
- package/build/index.d.ts +24 -0
- package/build/index.js +25 -0
- package/build/ledger/KanonClientService.d.ts +45 -0
- package/build/ledger/KanonClientService.d.ts.map +1 -0
- package/build/ledger/KanonClientService.js +111 -0
- package/build/ledger/KanonClientService.js.map +1 -0
- package/build/ledger/index.d.ts +1 -0
- package/build/ledger/index.js +1 -0
- package/build/utils/identifiers.d.ts +24 -0
- package/build/utils/identifiers.d.ts.map +1 -0
- package/build/utils/identifiers.js +39 -0
- package/build/utils/identifiers.js.map +1 -0
- package/build/zk/KanonZkApi.d.ts +186 -0
- package/build/zk/KanonZkApi.d.ts.map +1 -0
- package/build/zk/KanonZkApi.js +226 -0
- package/build/zk/KanonZkApi.js.map +1 -0
- package/build/zk/KanonZkIssuerKeyService.d.ts +107 -0
- package/build/zk/KanonZkIssuerKeyService.d.ts.map +1 -0
- package/build/zk/KanonZkIssuerKeyService.js +137 -0
- package/build/zk/KanonZkIssuerKeyService.js.map +1 -0
- package/build/zk/KanonZkPathService.d.ts +66 -0
- package/build/zk/KanonZkPathService.d.ts.map +1 -0
- package/build/zk/KanonZkPathService.js +163 -0
- package/build/zk/KanonZkPathService.js.map +1 -0
- package/build/zk/KanonZkService.d.ts +91 -0
- package/build/zk/KanonZkService.d.ts.map +1 -0
- package/build/zk/KanonZkService.js +165 -0
- package/build/zk/KanonZkService.js.map +1 -0
- package/build/zk/index.d.ts +4 -0
- package/build/zk/index.js +4 -0
- package/build/zk/modeBLeaves.js +48 -0
- package/build/zk/modeBLeaves.js.map +1 -0
- package/package.json +66 -3
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.js";
|
|
2
|
+
import { generateZkIssuerKey, restoreZkIssuerKey } from "@ajna-inc/kanon-sdk";
|
|
3
|
+
import { GenericRecordsApi, injectable } from "@credo-ts/core";
|
|
4
|
+
|
|
5
|
+
//#region src/zk/KanonZkIssuerKeyService.ts
|
|
6
|
+
let KanonZkIssuerKeyService = class KanonZkIssuerKeyService {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.publicKeyCache = /* @__PURE__ */ new Map();
|
|
9
|
+
this.provisionQueues = /* @__PURE__ */ new Map();
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Generate a fresh BJJ keypair for `credDefId` if one isn't persisted yet,
|
|
13
|
+
* and return it. Pass `(key.publicKey.Ax, key.publicKey.Ay)` to
|
|
14
|
+
* `registerCredentialDefinition` in the same flow.
|
|
15
|
+
*
|
|
16
|
+
* Concurrent calls for the same credDef serialize — only ONE generates a
|
|
17
|
+
* fresh key; the rest observe the persisted record.
|
|
18
|
+
*/
|
|
19
|
+
async provision(agentContext, credDefId) {
|
|
20
|
+
return this.withProvisionLock(credDefId, async () => {
|
|
21
|
+
const records = agentContext.dependencyManager.resolve(GenericRecordsApi);
|
|
22
|
+
const existing = await records.findById(this.recordId(credDefId)).catch(() => null);
|
|
23
|
+
if (existing) {
|
|
24
|
+
const restored = await this.restore(existing.content);
|
|
25
|
+
this.publicKeyCache.set(credDefId.toLowerCase(), restored.publicKey);
|
|
26
|
+
return restored;
|
|
27
|
+
}
|
|
28
|
+
const fresh = await generateZkIssuerKey();
|
|
29
|
+
await records.save({
|
|
30
|
+
id: this.recordId(credDefId),
|
|
31
|
+
content: {
|
|
32
|
+
privateKeyHex: fresh.privateKeyHex,
|
|
33
|
+
ax: fresh.publicKey.Ax.toString(),
|
|
34
|
+
ay: fresh.publicKey.Ay.toString()
|
|
35
|
+
},
|
|
36
|
+
tags: {
|
|
37
|
+
type: "kanon-zk-issuer-key",
|
|
38
|
+
credDefId: credDefId.toLowerCase()
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
this.publicKeyCache.set(credDefId.toLowerCase(), fresh.publicKey);
|
|
42
|
+
return fresh;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Public-key-only accessor. Hits the in-process cache when warm; otherwise
|
|
47
|
+
* reads from the wallet but discards the privkey hex on return. Used by
|
|
48
|
+
* Mode B presentation flow (which needs `(Ax, Ay)` as a public input).
|
|
49
|
+
*/
|
|
50
|
+
async loadPublicKey(agentContext, credDefId) {
|
|
51
|
+
const cacheKey = credDefId.toLowerCase();
|
|
52
|
+
const cached = this.publicKeyCache.get(cacheKey);
|
|
53
|
+
if (cached) return cached;
|
|
54
|
+
const existing = await agentContext.dependencyManager.resolve(GenericRecordsApi).findById(this.recordId(credDefId)).catch(() => null);
|
|
55
|
+
if (!existing) throw new Error(`KanonZkIssuerKeyService: no issuer key persisted for ${credDefId} — call provision() during credDef registration`);
|
|
56
|
+
const content = existing.content;
|
|
57
|
+
const ax = typeof content.ax === "string" ? BigInt(content.ax) : void 0;
|
|
58
|
+
const ay = typeof content.ay === "string" ? BigInt(content.ay) : void 0;
|
|
59
|
+
if (ax !== void 0 && ay !== void 0) {
|
|
60
|
+
const pub = {
|
|
61
|
+
Ax: ax,
|
|
62
|
+
Ay: ay
|
|
63
|
+
};
|
|
64
|
+
this.publicKeyCache.set(cacheKey, pub);
|
|
65
|
+
return pub;
|
|
66
|
+
}
|
|
67
|
+
const restored = await this.restore(existing.content);
|
|
68
|
+
this.publicKeyCache.set(cacheKey, restored.publicKey);
|
|
69
|
+
return restored.publicKey;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Run `fn` with the issuer's BabyJubjub private key for `credDefId`.
|
|
73
|
+
*
|
|
74
|
+
* The privkey is loaded from the wallet, passed to `fn`, and the local
|
|
75
|
+
* reference dropped on return. Callers MUST do their signing inside `fn`
|
|
76
|
+
* and not stash the hex string elsewhere — the entire point is to keep
|
|
77
|
+
* the strong reference scoped tightly.
|
|
78
|
+
*
|
|
79
|
+
* We make a best-effort attempt to overwrite the hex string buffer before
|
|
80
|
+
* returning. JavaScript doesn't guarantee deletion (the GC may have copied
|
|
81
|
+
* the string elsewhere) but removing the obvious reference reduces the
|
|
82
|
+
* window for a heap-dump attacker.
|
|
83
|
+
*/
|
|
84
|
+
async withPrivateKey(agentContext, credDefId, fn) {
|
|
85
|
+
const existing = await agentContext.dependencyManager.resolve(GenericRecordsApi).findById(this.recordId(credDefId)).catch(() => null);
|
|
86
|
+
if (!existing) throw new Error(`KanonZkIssuerKeyService: no issuer key persisted for ${credDefId} — call provision() during credDef registration`);
|
|
87
|
+
const privateKeyHex = existing.content.privateKeyHex;
|
|
88
|
+
if (typeof privateKeyHex !== "string") throw new Error("KanonZkIssuerKeyService: corrupt key record (no privateKeyHex)");
|
|
89
|
+
const restored = await restoreZkIssuerKey(privateKeyHex);
|
|
90
|
+
try {
|
|
91
|
+
return await fn(restored);
|
|
92
|
+
} finally {
|
|
93
|
+
try {
|
|
94
|
+
restored.privateKeyHex = "";
|
|
95
|
+
} catch {}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Legacy method retained for transition. Now equivalent to
|
|
100
|
+
* `loadPublicKey` for the public coords + best-effort drop of the privkey
|
|
101
|
+
* reference immediately. Prefer `loadPublicKey` (read-only fast path) or
|
|
102
|
+
* `withPrivateKey(fn)` (scoped signing) directly.
|
|
103
|
+
*
|
|
104
|
+
* @deprecated use `loadPublicKey` or `withPrivateKey` instead.
|
|
105
|
+
*/
|
|
106
|
+
async load(agentContext, credDefId) {
|
|
107
|
+
const existing = await agentContext.dependencyManager.resolve(GenericRecordsApi).findById(this.recordId(credDefId)).catch(() => null);
|
|
108
|
+
if (!existing) throw new Error(`KanonZkIssuerKeyService: no issuer key persisted for ${credDefId} — call provision() during credDef registration`);
|
|
109
|
+
const restored = await this.restore(existing.content);
|
|
110
|
+
this.publicKeyCache.set(credDefId.toLowerCase(), restored.publicKey);
|
|
111
|
+
return restored;
|
|
112
|
+
}
|
|
113
|
+
async restore(content) {
|
|
114
|
+
const privateKeyHex = content.privateKeyHex;
|
|
115
|
+
if (typeof privateKeyHex !== "string") throw new Error("KanonZkIssuerKeyService: corrupt key record (no privateKeyHex)");
|
|
116
|
+
return restoreZkIssuerKey(privateKeyHex);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Per-credDef single-flight queue. Each `provision` call chains onto the
|
|
120
|
+
* previous one for the same credDef. Failure in one doesn't poison the
|
|
121
|
+
* queue for the next caller — `.catch(() => undefined)` keeps it moving.
|
|
122
|
+
*/
|
|
123
|
+
withProvisionLock(credDefId, fn) {
|
|
124
|
+
const key = credDefId.toLowerCase();
|
|
125
|
+
const next = (this.provisionQueues.get(key) ?? Promise.resolve()).catch(() => void 0).then(fn);
|
|
126
|
+
this.provisionQueues.set(key, next.catch(() => void 0));
|
|
127
|
+
return next;
|
|
128
|
+
}
|
|
129
|
+
recordId(credDefId) {
|
|
130
|
+
return `kanon-zk-issuer-key:${credDefId.toLowerCase()}`;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
KanonZkIssuerKeyService = __decorate([injectable()], KanonZkIssuerKeyService);
|
|
134
|
+
|
|
135
|
+
//#endregion
|
|
136
|
+
export { KanonZkIssuerKeyService };
|
|
137
|
+
//# sourceMappingURL=KanonZkIssuerKeyService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KanonZkIssuerKeyService.js","names":[],"sources":["../../src/zk/KanonZkIssuerKeyService.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\nimport type { KanonZkIssuerKey } from '@ajna-inc/kanon-sdk'\n\nimport { GenericRecordsApi, injectable } from '@credo-ts/core'\nimport {\n generateZkIssuerKey,\n restoreZkIssuerKey,\n} from '@ajna-inc/kanon-sdk'\n\n/**\n * Tier-2 BabyJubjub issuer key lifecycle (off-chain only).\n *\n * Mode B requires the issuer's BabyJubjub public key to be published on chain\n * via `CredentialDefinitionRegistry.registerCredentialDefinition(..., ax, ay)`\n * — registration and key publication happen atomically in one transaction. So\n * this service does NOT touch chain: it just generates + persists the keypair\n * so the registration caller can read `(ax, ay)` to pass through and so the\n * issuance side can later read the private key to sign credential leaves.\n *\n * Persistence: `GenericRecordsApi`, one record per credDef, keyed by\n * `kanon-zk-issuer-key:<lowercased credDefId>`. The wallet encrypts records at\n * rest, so the on-disk form is safe; the in-memory exposure surface is the\n * hex string between load + use.\n *\n * Hardening choices in this implementation:\n *\n * - We cache ONLY the public key (`Ax`, `Ay`). Public coords are safe to\n * keep — they're literally published on chain. The PRIVATE key is loaded\n * from the wallet on every signing operation and discarded immediately\n * after.\n *\n * - `withPrivateKey(fn)` lets callers compute with the privkey in a tight\n * scope. The privkey buffer is best-effort overwritten before returning,\n * mitigating heap-dump exposure (JS doesn't guarantee zeroing — GC may\n * have copied it — but this still removes the strong reference).\n *\n * - `provision()` is serialized per credDef via a single-flight lock. Two\n * concurrent calls for the same credDef can't both generate fresh keys\n * and race on the GenericRecords write — the second caller blocks on the\n * first and observes the persisted result.\n *\n * Idempotent: `provision` returns the existing key if already persisted.\n * Rotating is unsupported — it would silently break every previously-issued\n * Mode B proof.\n */\n@injectable()\nexport class KanonZkIssuerKeyService {\n /**\n * In-process cache for the PUBLIC key only. The public coords are safe to\n * cache — they're on chain anyway. We deliberately do NOT cache the\n * private key; it's loaded from the wallet on every use and the hex\n * string is dropped as soon as the closure that uses it returns.\n */\n private readonly publicKeyCache = new Map<string, { Ax: bigint; Ay: bigint }>()\n\n /**\n * Per-credDef single-flight queue so two concurrent `provision()` calls\n * for the same credDef can't both generate fresh keys and race on the\n * GenericRecords write. Same pattern as `KanonZkPathService.withLock`.\n */\n private readonly provisionQueues = new Map<string, Promise<unknown>>()\n\n /**\n * Generate a fresh BJJ keypair for `credDefId` if one isn't persisted yet,\n * and return it. Pass `(key.publicKey.Ax, key.publicKey.Ay)` to\n * `registerCredentialDefinition` in the same flow.\n *\n * Concurrent calls for the same credDef serialize — only ONE generates a\n * fresh key; the rest observe the persisted record.\n */\n public async provision(\n agentContext: AgentContext,\n credDefId: string\n ): Promise<KanonZkIssuerKey> {\n return this.withProvisionLock(credDefId, async () => {\n const records = agentContext.dependencyManager.resolve(GenericRecordsApi)\n const existing = await records.findById(this.recordId(credDefId)).catch(() => null)\n if (existing) {\n const restored = await this.restore(existing.content)\n this.publicKeyCache.set(credDefId.toLowerCase(), restored.publicKey)\n return restored\n }\n\n const fresh = await generateZkIssuerKey()\n await records.save({\n id: this.recordId(credDefId),\n content: {\n privateKeyHex: fresh.privateKeyHex,\n ax: fresh.publicKey.Ax.toString(),\n ay: fresh.publicKey.Ay.toString(),\n },\n tags: { type: 'kanon-zk-issuer-key', credDefId: credDefId.toLowerCase() },\n })\n this.publicKeyCache.set(credDefId.toLowerCase(), fresh.publicKey)\n return fresh\n })\n }\n\n /**\n * Public-key-only accessor. Hits the in-process cache when warm; otherwise\n * reads from the wallet but discards the privkey hex on return. Used by\n * Mode B presentation flow (which needs `(Ax, Ay)` as a public input).\n */\n public async loadPublicKey(\n agentContext: AgentContext,\n credDefId: string\n ): Promise<{ Ax: bigint; Ay: bigint }> {\n const cacheKey = credDefId.toLowerCase()\n const cached = this.publicKeyCache.get(cacheKey)\n if (cached) return cached\n const records = agentContext.dependencyManager.resolve(GenericRecordsApi)\n const existing = await records.findById(this.recordId(credDefId)).catch(() => null)\n if (!existing) {\n throw new Error(\n `KanonZkIssuerKeyService: no issuer key persisted for ${credDefId} — call provision() during credDef registration`\n )\n }\n const content = existing.content as Record<string, unknown>\n // Prefer the stored ax/ay strings (avoid touching the privkey) when\n // present. Fall back to deriving from privkey if the record was written\n // by an older version of the service.\n const ax =\n typeof content.ax === 'string' ? BigInt(content.ax) : undefined\n const ay =\n typeof content.ay === 'string' ? BigInt(content.ay) : undefined\n if (ax !== undefined && ay !== undefined) {\n const pub = { Ax: ax, Ay: ay }\n this.publicKeyCache.set(cacheKey, pub)\n return pub\n }\n const restored = await this.restore(existing.content)\n this.publicKeyCache.set(cacheKey, restored.publicKey)\n return restored.publicKey\n }\n\n /**\n * Run `fn` with the issuer's BabyJubjub private key for `credDefId`.\n *\n * The privkey is loaded from the wallet, passed to `fn`, and the local\n * reference dropped on return. Callers MUST do their signing inside `fn`\n * and not stash the hex string elsewhere — the entire point is to keep\n * the strong reference scoped tightly.\n *\n * We make a best-effort attempt to overwrite the hex string buffer before\n * returning. JavaScript doesn't guarantee deletion (the GC may have copied\n * the string elsewhere) but removing the obvious reference reduces the\n * window for a heap-dump attacker.\n */\n public async withPrivateKey<T>(\n agentContext: AgentContext,\n credDefId: string,\n fn: (key: KanonZkIssuerKey) => Promise<T>\n ): Promise<T> {\n const records = agentContext.dependencyManager.resolve(GenericRecordsApi)\n const existing = await records.findById(this.recordId(credDefId)).catch(() => null)\n if (!existing) {\n throw new Error(\n `KanonZkIssuerKeyService: no issuer key persisted for ${credDefId} — call provision() during credDef registration`\n )\n }\n const content = existing.content as Record<string, unknown>\n const privateKeyHex = content.privateKeyHex\n if (typeof privateKeyHex !== 'string') {\n throw new Error('KanonZkIssuerKeyService: corrupt key record (no privateKeyHex)')\n }\n const restored = await restoreZkIssuerKey(privateKeyHex)\n try {\n return await fn(restored)\n } finally {\n // Best-effort zeroize: strings are immutable in JS so we can't actually\n // overwrite the existing hex chars, but blanking the property removes\n // the strong reference held by `restored`. The GC will collect when no\n // other reference is held — typically right after this finally block.\n try {\n ;(restored as { privateKeyHex?: string }).privateKeyHex = ''\n } catch {\n /* not strict-mode-locked, ignored */\n }\n }\n }\n\n /**\n * Legacy method retained for transition. Now equivalent to\n * `loadPublicKey` for the public coords + best-effort drop of the privkey\n * reference immediately. Prefer `loadPublicKey` (read-only fast path) or\n * `withPrivateKey(fn)` (scoped signing) directly.\n *\n * @deprecated use `loadPublicKey` or `withPrivateKey` instead.\n */\n public async load(\n agentContext: AgentContext,\n credDefId: string\n ): Promise<KanonZkIssuerKey> {\n const records = agentContext.dependencyManager.resolve(GenericRecordsApi)\n const existing = await records.findById(this.recordId(credDefId)).catch(() => null)\n if (!existing) {\n throw new Error(\n `KanonZkIssuerKeyService: no issuer key persisted for ${credDefId} — call provision() during credDef registration`\n )\n }\n const restored = await this.restore(existing.content)\n this.publicKeyCache.set(credDefId.toLowerCase(), restored.publicKey)\n return restored\n }\n\n // ─── internals ────────────────────────────────────────────────────────\n\n private async restore(content: unknown): Promise<KanonZkIssuerKey> {\n const record = content as Record<string, unknown>\n const privateKeyHex = record.privateKeyHex\n if (typeof privateKeyHex !== 'string') {\n throw new Error('KanonZkIssuerKeyService: corrupt key record (no privateKeyHex)')\n }\n return restoreZkIssuerKey(privateKeyHex)\n }\n\n /**\n * Per-credDef single-flight queue. Each `provision` call chains onto the\n * previous one for the same credDef. Failure in one doesn't poison the\n * queue for the next caller — `.catch(() => undefined)` keeps it moving.\n */\n private withProvisionLock<T>(credDefId: string, fn: () => Promise<T>): Promise<T> {\n const key = credDefId.toLowerCase()\n const last = this.provisionQueues.get(key) ?? Promise.resolve()\n const next = last.catch(() => undefined).then(fn)\n this.provisionQueues.set(key, next.catch(() => undefined))\n return next\n }\n\n private recordId(credDefId: string): string {\n return `kanon-zk-issuer-key:${credDefId.toLowerCase()}`\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { KanonClientService } from "../ledger/KanonClientService.js";
|
|
2
|
+
import "../ledger/index.js";
|
|
3
|
+
import { AgentContext } from "@credo-ts/core";
|
|
4
|
+
|
|
5
|
+
//#region src/zk/KanonZkPathService.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Merkle path discovery for Mode B presentations.
|
|
8
|
+
*
|
|
9
|
+
* The holder needs `(pathElements, pathIndices, root)` for the credential's
|
|
10
|
+
* Poseidon leaf so the SNARK can prove non-revocation. The tree is rebuilt by
|
|
11
|
+
* replaying every `CredentialAdded` / `CredentialRevoked` event the issuer
|
|
12
|
+
* has published under `credDefId`, then constructing the tagged `PoseidonTree`
|
|
13
|
+
* the circuit verifies against.
|
|
14
|
+
*
|
|
15
|
+
* Persistence: the replayed active-leaf list is cached per credDef in
|
|
16
|
+
* `GenericRecordsApi` so subsequent presentations don't re-scan the chain
|
|
17
|
+
* from genesis — only `(lastSyncedBlock, currentBlock]` is replayed. The
|
|
18
|
+
* cache survives agent restarts and is keyed by `kanon-zk-path-cache:<credDefId>`.
|
|
19
|
+
*
|
|
20
|
+
* Concurrency: a per-credDef in-process lock prevents two concurrent
|
|
21
|
+
* `findPath` calls from racing on the same cache record. The lock is
|
|
22
|
+
* advisory; if your agent runs multiple instances with shared storage you
|
|
23
|
+
* should fence at the storage layer instead.
|
|
24
|
+
*/
|
|
25
|
+
declare class KanonZkPathService {
|
|
26
|
+
private readonly clientService;
|
|
27
|
+
/**
|
|
28
|
+
* Per-credDef serialization queue. Each `findPath` call chains onto the
|
|
29
|
+
* previous one for the same credDef so two concurrent presentations don't
|
|
30
|
+
* race on the GenericRecords-backed cache record. The previous "acquire /
|
|
31
|
+
* release" lock had a window between `await existing` and `locks.set` that
|
|
32
|
+
* let two callers both proceed — this single-flight chain closes it.
|
|
33
|
+
*/
|
|
34
|
+
private readonly queues;
|
|
35
|
+
constructor(clientService: KanonClientService);
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the Merkle inclusion proof for `poseidonLeaf` under `credDefId`.
|
|
38
|
+
*
|
|
39
|
+
* Returns `null` if the leaf isn't in the current active set (e.g. it was
|
|
40
|
+
* revoked, or it was never published — most often a sign the holder fired
|
|
41
|
+
* a presentation before the issuance batch landed on chain).
|
|
42
|
+
*
|
|
43
|
+
* `wantRoot` shouldn't usually be supplied; it's there for tests that need
|
|
44
|
+
* to pin against a specific historical root.
|
|
45
|
+
*/
|
|
46
|
+
findPath(agentContext: AgentContext, credDefId: string, poseidonLeaf: bigint, wantRoot?: bigint): Promise<{
|
|
47
|
+
pathElements: bigint[];
|
|
48
|
+
pathIndices: number[];
|
|
49
|
+
root: bigint;
|
|
50
|
+
leafIndex: number;
|
|
51
|
+
} | null>;
|
|
52
|
+
/**
|
|
53
|
+
* Run `fn` exclusively for `credDefId`. Concurrent calls for the same
|
|
54
|
+
* credDef execute one-at-a-time in FIFO order; calls for different credDefs
|
|
55
|
+
* are independent. Failures are isolated — a thrown `fn` doesn't poison the
|
|
56
|
+
* queue for the next caller.
|
|
57
|
+
*/
|
|
58
|
+
private withLock;
|
|
59
|
+
/** Drop the cached active set for a credDef so the next call re-scans from genesis. */
|
|
60
|
+
invalidate(agentContext: AgentContext, credDefId: string): Promise<void>;
|
|
61
|
+
private replayActive;
|
|
62
|
+
private cacheRecordId;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { KanonZkPathService };
|
|
66
|
+
//# sourceMappingURL=KanonZkPathService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KanonZkPathService.d.ts","names":[],"sources":["../../src/zk/KanonZkPathService.ts"],"mappings":";;;;;;;;AA4BA;;;;;;;;;;;;;;;;cACa,kBAAA;EAAA,iBAUyB,aAAA;EAclC;;;;;;;EAAA,iBAhBe,MAAA;cAEmB,aAAA,EAAe,kBAAA;EA+DtC;;;;;;;;;;EAnDA,QAAA,CACX,YAAA,EAAc,YAAA,EACd,SAAA,UACA,YAAA,UACA,QAAA,YACC,OAAA;IACD,YAAA;IACA,WAAA;IACA,IAAA;IACA,SAAA;EAAA;;;;;;;UA8BM,QAAA;;EAYK,UAAA,CAAW,YAAA,EAAc,YAAA,EAAc,SAAA,WAAoB,OAAA;EAAA,QAQ1D,YAAA;EAAA,QAqKN,aAAA;AAAA"}
|
|
@@ -0,0 +1,163 @@
|
|
|
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 { KanonClientService } from "../ledger/KanonClientService.js";
|
|
4
|
+
import "../ledger/index.js";
|
|
5
|
+
import { fetchModeBLeaves, resolveModeBLeavesBaseUrl } from "./modeBLeaves.js";
|
|
6
|
+
import { GenericRecordsApi, injectable } from "@credo-ts/core";
|
|
7
|
+
import { resourceIdToBytes32 } from "@ajna-inc/kanon-sdk/anoncreds";
|
|
8
|
+
import { ethers } from "ethers";
|
|
9
|
+
|
|
10
|
+
//#region src/zk/KanonZkPathService.ts
|
|
11
|
+
var _ref;
|
|
12
|
+
let KanonZkPathService = class KanonZkPathService {
|
|
13
|
+
constructor(clientService) {
|
|
14
|
+
this.clientService = clientService;
|
|
15
|
+
this.queues = /* @__PURE__ */ new Map();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the Merkle inclusion proof for `poseidonLeaf` under `credDefId`.
|
|
19
|
+
*
|
|
20
|
+
* Returns `null` if the leaf isn't in the current active set (e.g. it was
|
|
21
|
+
* revoked, or it was never published — most often a sign the holder fired
|
|
22
|
+
* a presentation before the issuance batch landed on chain).
|
|
23
|
+
*
|
|
24
|
+
* `wantRoot` shouldn't usually be supplied; it's there for tests that need
|
|
25
|
+
* to pin against a specific historical root.
|
|
26
|
+
*/
|
|
27
|
+
async findPath(agentContext, credDefId, poseidonLeaf, wantRoot) {
|
|
28
|
+
return this.withLock(credDefId, async () => {
|
|
29
|
+
const active = await this.replayActive(agentContext, credDefId);
|
|
30
|
+
const leafIndex = active.findIndex((v) => v === poseidonLeaf);
|
|
31
|
+
if (leafIndex < 0) return null;
|
|
32
|
+
const sdk = await import("@ajna-inc/kanon-sdk");
|
|
33
|
+
await sdk.zk.initPoseidon();
|
|
34
|
+
const tree = new sdk.zk.PoseidonTree(26, active);
|
|
35
|
+
const root = tree.root;
|
|
36
|
+
if (wantRoot !== void 0 && root !== wantRoot) return null;
|
|
37
|
+
const { pathElements, pathIndices } = tree.proof(leafIndex);
|
|
38
|
+
return {
|
|
39
|
+
pathElements,
|
|
40
|
+
pathIndices,
|
|
41
|
+
root,
|
|
42
|
+
leafIndex
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Run `fn` exclusively for `credDefId`. Concurrent calls for the same
|
|
48
|
+
* credDef execute one-at-a-time in FIFO order; calls for different credDefs
|
|
49
|
+
* are independent. Failures are isolated — a thrown `fn` doesn't poison the
|
|
50
|
+
* queue for the next caller.
|
|
51
|
+
*/
|
|
52
|
+
withLock(credDefId, fn) {
|
|
53
|
+
const key = credDefId.toLowerCase();
|
|
54
|
+
const next = (this.queues.get(key) ?? Promise.resolve()).catch(() => void 0).then(fn);
|
|
55
|
+
this.queues.set(key, next.catch(() => void 0));
|
|
56
|
+
return next;
|
|
57
|
+
}
|
|
58
|
+
/** Drop the cached active set for a credDef so the next call re-scans from genesis. */
|
|
59
|
+
async invalidate(agentContext, credDefId) {
|
|
60
|
+
const records = agentContext.dependencyManager.resolve(GenericRecordsApi);
|
|
61
|
+
const existing = await records.findById(this.cacheRecordId(credDefId)).catch(() => null);
|
|
62
|
+
if (existing) await records.delete(existing);
|
|
63
|
+
}
|
|
64
|
+
async replayActive(agentContext, credDefId) {
|
|
65
|
+
try {
|
|
66
|
+
const base = await resolveModeBLeavesBaseUrl(credDefId, this.clientService.resolveLeavesBaseUrl);
|
|
67
|
+
if (base) {
|
|
68
|
+
const result = await fetchModeBLeaves(base, credDefId);
|
|
69
|
+
if (result.leaves) {
|
|
70
|
+
agentContext.config.logger.info(`KanonZkPathService: loaded ${result.leaves.length} Mode B leaves from CrMS ${base}`);
|
|
71
|
+
return result.leaves;
|
|
72
|
+
}
|
|
73
|
+
agentContext.config.logger.warn(`KanonZkPathService: CrMS leaves ${result.status ?? "missing"} for ${credDefId} — falling back to chain scan`);
|
|
74
|
+
}
|
|
75
|
+
} catch (e) {
|
|
76
|
+
agentContext.config.logger.warn(`KanonZkPathService: CrMS leaf fetch failed (${e instanceof Error ? e.message : String(e)}) — falling back to chain scan`);
|
|
77
|
+
}
|
|
78
|
+
const records = agentContext.dependencyManager.resolve(GenericRecordsApi);
|
|
79
|
+
const recordId = this.cacheRecordId(credDefId);
|
|
80
|
+
const cached = await records.findById(recordId).catch(() => null);
|
|
81
|
+
let lastSyncedBlock = 0;
|
|
82
|
+
const active = [];
|
|
83
|
+
if (cached) {
|
|
84
|
+
const content = cached.content;
|
|
85
|
+
lastSyncedBlock = content.lastSyncedBlock ?? 0;
|
|
86
|
+
const seeds = content.poseidon ?? [];
|
|
87
|
+
for (const hex of seeds) active.push(BigInt(hex));
|
|
88
|
+
}
|
|
89
|
+
const registry = this.clientService.contracts.merkleStateRegistry;
|
|
90
|
+
const provider = this.clientService.getSigner().provider;
|
|
91
|
+
if (!provider) throw new Error("KanonZkPathService: no provider on signer — agent must have an RPC URL configured");
|
|
92
|
+
const currentBlock = await provider.getBlockNumber();
|
|
93
|
+
if (currentBlock < lastSyncedBlock) return active;
|
|
94
|
+
const addedTopic = registry.filters?.CredentialAdded?.(resourceIdToBytes32(credDefId));
|
|
95
|
+
const revokedTopic = registry.filters?.CredentialRevoked?.(resourceIdToBytes32(credDefId));
|
|
96
|
+
const FROM = lastSyncedBlock + 1;
|
|
97
|
+
const TO = currentBlock;
|
|
98
|
+
const fromBlockSafe = FROM > TO ? TO : FROM;
|
|
99
|
+
const queryFilter = registry.queryFilter;
|
|
100
|
+
const LOGS_RANGE = 5e3;
|
|
101
|
+
const queryChunked = async (topic) => {
|
|
102
|
+
if (!topic) return [];
|
|
103
|
+
const out = [];
|
|
104
|
+
for (let lo = fromBlockSafe; lo <= TO; lo += LOGS_RANGE) {
|
|
105
|
+
const hi = Math.min(lo + LOGS_RANGE - 1, TO);
|
|
106
|
+
const part = await queryFilter.call(registry, topic, lo, hi);
|
|
107
|
+
for (const e of part) out.push(e);
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
};
|
|
111
|
+
const addedEvents = await queryChunked(addedTopic);
|
|
112
|
+
const revokedEvents = await queryChunked(revokedTopic);
|
|
113
|
+
const combined = [];
|
|
114
|
+
for (const e of addedEvents) combined.push({
|
|
115
|
+
kind: "add",
|
|
116
|
+
poseidon: BigInt(e.args.leafPoseidon),
|
|
117
|
+
block: e.blockNumber,
|
|
118
|
+
txIndex: e.transactionIndex,
|
|
119
|
+
logIndex: e.logIndex
|
|
120
|
+
});
|
|
121
|
+
for (const e of revokedEvents) combined.push({
|
|
122
|
+
kind: "remove",
|
|
123
|
+
poseidon: BigInt(e.args.leafPoseidon),
|
|
124
|
+
block: e.blockNumber,
|
|
125
|
+
txIndex: e.transactionIndex,
|
|
126
|
+
logIndex: e.logIndex
|
|
127
|
+
});
|
|
128
|
+
combined.sort((a, b) => {
|
|
129
|
+
if (a.block !== b.block) return a.block - b.block;
|
|
130
|
+
if (a.txIndex !== b.txIndex) return a.txIndex - b.txIndex;
|
|
131
|
+
return a.logIndex - b.logIndex;
|
|
132
|
+
});
|
|
133
|
+
for (const e of combined) if (e.kind === "add") active.push(e.poseidon);
|
|
134
|
+
else {
|
|
135
|
+
const idx = active.findIndex((v) => v === e.poseidon);
|
|
136
|
+
if (idx >= 0) active.splice(idx, 1);
|
|
137
|
+
}
|
|
138
|
+
const newRecord = {
|
|
139
|
+
lastSyncedBlock: TO,
|
|
140
|
+
poseidon: active.map((v) => "0x" + v.toString(16).padStart(64, "0"))
|
|
141
|
+
};
|
|
142
|
+
if (cached) {
|
|
143
|
+
cached.content = newRecord;
|
|
144
|
+
await records.update(cached);
|
|
145
|
+
} else await records.save({
|
|
146
|
+
id: recordId,
|
|
147
|
+
content: newRecord,
|
|
148
|
+
tags: {
|
|
149
|
+
type: "kanon-zk-path-cache",
|
|
150
|
+
credDefId: credDefId.toLowerCase()
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return active;
|
|
154
|
+
}
|
|
155
|
+
cacheRecordId(credDefId) {
|
|
156
|
+
return `kanon-zk-path-cache:${credDefId.toLowerCase()}`;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
KanonZkPathService = __decorate([injectable(), __decorateMetadata("design:paramtypes", [KanonClientService])], KanonZkPathService);
|
|
160
|
+
|
|
161
|
+
//#endregion
|
|
162
|
+
export { KanonZkPathService };
|
|
163
|
+
//# sourceMappingURL=KanonZkPathService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KanonZkPathService.js","names":[],"sources":["../../src/zk/KanonZkPathService.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\n\nimport { GenericRecordsApi, injectable } from '@credo-ts/core'\nimport { resourceIdToBytes32 } from '@ajna-inc/kanon-sdk/anoncreds'\nimport { ethers } from 'ethers'\n\nimport { KanonClientService } from '../ledger'\nimport { fetchModeBLeaves, resolveModeBLeavesBaseUrl } from './modeBLeaves'\n\n/**\n * Merkle path discovery for Mode B presentations.\n *\n * The holder needs `(pathElements, pathIndices, root)` for the credential's\n * Poseidon leaf so the SNARK can prove non-revocation. The tree is rebuilt by\n * replaying every `CredentialAdded` / `CredentialRevoked` event the issuer\n * has published under `credDefId`, then constructing the tagged `PoseidonTree`\n * the circuit verifies against.\n *\n * Persistence: the replayed active-leaf list is cached per credDef in\n * `GenericRecordsApi` so subsequent presentations don't re-scan the chain\n * from genesis — only `(lastSyncedBlock, currentBlock]` is replayed. The\n * cache survives agent restarts and is keyed by `kanon-zk-path-cache:<credDefId>`.\n *\n * Concurrency: a per-credDef in-process lock prevents two concurrent\n * `findPath` calls from racing on the same cache record. The lock is\n * advisory; if your agent runs multiple instances with shared storage you\n * should fence at the storage layer instead.\n */\n@injectable()\nexport class KanonZkPathService {\n /**\n * Per-credDef serialization queue. Each `findPath` call chains onto the\n * previous one for the same credDef so two concurrent presentations don't\n * race on the GenericRecords-backed cache record. The previous \"acquire /\n * release\" lock had a window between `await existing` and `locks.set` that\n * let two callers both proceed — this single-flight chain closes it.\n */\n private readonly queues = new Map<string, Promise<unknown>>()\n\n public constructor(private readonly clientService: KanonClientService) {}\n\n /**\n * Resolve the Merkle inclusion proof for `poseidonLeaf` under `credDefId`.\n *\n * Returns `null` if the leaf isn't in the current active set (e.g. it was\n * revoked, or it was never published — most often a sign the holder fired\n * a presentation before the issuance batch landed on chain).\n *\n * `wantRoot` shouldn't usually be supplied; it's there for tests that need\n * to pin against a specific historical root.\n */\n public async findPath(\n agentContext: AgentContext,\n credDefId: string,\n poseidonLeaf: bigint,\n wantRoot?: bigint\n ): Promise<{\n pathElements: bigint[]\n pathIndices: number[]\n root: bigint\n leafIndex: number\n } | null> {\n return this.withLock(credDefId, async () => {\n const active = await this.replayActive(agentContext, credDefId)\n const leafIndex = active.findIndex((v) => v === poseidonLeaf)\n if (leafIndex < 0) return null\n\n const sdk = await import('@ajna-inc/kanon-sdk')\n await sdk.zk.initPoseidon()\n // 26 = the compiled circuit depth. Mirrors `non_revocation.circom`'s\n // `MerkleInclusion(26)` so the path the prover supplies has the same\n // length the circuit consumes.\n const tree = new sdk.zk.PoseidonTree(26, active)\n const root = tree.root\n if (wantRoot !== undefined && root !== wantRoot) {\n // Caller pinned a root and we didn't reproduce it — the local cache\n // is stale relative to whatever they expected.\n return null\n }\n const { pathElements, pathIndices } = tree.proof(leafIndex)\n return { pathElements, pathIndices, root, leafIndex }\n })\n }\n\n /**\n * Run `fn` exclusively for `credDefId`. Concurrent calls for the same\n * credDef execute one-at-a-time in FIFO order; calls for different credDefs\n * are independent. Failures are isolated — a thrown `fn` doesn't poison the\n * queue for the next caller.\n */\n private withLock<T>(credDefId: string, fn: () => Promise<T>): Promise<T> {\n const key = credDefId.toLowerCase()\n const last = this.queues.get(key) ?? Promise.resolve()\n // Recover from previous failure with `.catch(() => {})` so the queue\n // keeps moving. The returned promise still rejects with the original\n // error so the caller sees it.\n const next = last.catch(() => undefined).then(fn)\n this.queues.set(key, next.catch(() => undefined))\n return next\n }\n\n /** Drop the cached active set for a credDef so the next call re-scans from genesis. */\n public async invalidate(agentContext: AgentContext, credDefId: string): Promise<void> {\n const records = agentContext.dependencyManager.resolve(GenericRecordsApi)\n const existing = await records.findById(this.cacheRecordId(credDefId)).catch(() => null)\n if (existing) await records.delete(existing)\n }\n\n // ─── internals ────────────────────────────────────────────────────────\n\n private async replayActive(\n agentContext: AgentContext,\n credDefId: string\n ): Promise<bigint[]> {\n // Prefer the issuing org's CrMS leaf-set endpoint over an eth_getLogs chain\n // scan (which blows past the RPC's block-range cap on a long-lived chain).\n // Leaves are public and the proof is bound to the on-chain Poseidon root,\n // so trusting the CrMS here is safe. Any miss/error falls through to the\n // chain scan below.\n try {\n const base = await resolveModeBLeavesBaseUrl(credDefId, this.clientService.resolveLeavesBaseUrl)\n if (base) {\n const result = await fetchModeBLeaves(base, credDefId)\n if (result.leaves) {\n agentContext.config.logger.info(\n `KanonZkPathService: loaded ${result.leaves.length} Mode B leaves from CrMS ${base}`\n )\n return result.leaves\n }\n agentContext.config.logger.warn(\n `KanonZkPathService: CrMS leaves ${result.status ?? 'missing'} for ${credDefId} — falling back to chain scan`\n )\n }\n } catch (e) {\n agentContext.config.logger.warn(\n `KanonZkPathService: CrMS leaf fetch failed (${e instanceof Error ? e.message : String(e)}) — falling back to chain scan`\n )\n }\n\n const records = agentContext.dependencyManager.resolve(GenericRecordsApi)\n const recordId = this.cacheRecordId(credDefId)\n const cached = await records.findById(recordId).catch(() => null)\n\n let lastSyncedBlock = 0\n const active: bigint[] = []\n if (cached) {\n const content = cached.content as { lastSyncedBlock?: number; poseidon?: string[] }\n lastSyncedBlock = content.lastSyncedBlock ?? 0\n const seeds = content.poseidon ?? []\n for (const hex of seeds) active.push(BigInt(hex))\n }\n\n const registry = this.clientService.contracts.merkleStateRegistry\n const provider = this.clientService.getSigner().provider\n if (!provider) {\n throw new Error('KanonZkPathService: no provider on signer — agent must have an RPC URL configured')\n }\n const currentBlock = await provider.getBlockNumber()\n if (currentBlock < lastSyncedBlock) return active // local clock-skew safety\n\n // Replay both event topics under the credDef. We can't rely on getEvents\n // helpers in the SDK at this level — go direct via ethers so we don't\n // pull in additional indirection.\n // Every on-chain boundary keys `credDefId` as bytes32 (keccak256(utf8(id))),\n // so the event-topic filter must too — the raw DID-URL never matches.\n const addedTopic = (registry as unknown as ethers.BaseContract).filters?.CredentialAdded?.(\n resourceIdToBytes32(credDefId)\n )\n const revokedTopic = (registry as unknown as ethers.BaseContract).filters?.CredentialRevoked?.(\n resourceIdToBytes32(credDefId)\n )\n\n const FROM = lastSyncedBlock + 1\n const TO = currentBlock\n\n const fromBlockSafe = FROM > TO ? TO : FROM\n\n // Pull `blockNumber`, `transactionIndex` and `logIndex` per event so\n // adds + revokes that land in the same `batchUpdate` tx replay in\n // chain order. `queryFilter` returns events per-filter, so concat'ing\n // without these tie-breakers would lose within-block ordering — fine\n // when only one event type fires per block, broken on the common case\n // where `batchUpdate` adds AND revokes in the same tx.\n type EventQuery = (\n filter: ethers.DeferredTopicFilter,\n fromBlock: number,\n toBlock: number\n ) => Promise<\n Array<{\n args: { leafKeccak: string; leafPoseidon: string }\n blockNumber: number\n transactionIndex: number\n logIndex: number\n }>\n >\n const queryFilter = (registry as unknown as { queryFilter: EventQuery }).queryFilter\n\n // The Kanon RPC caps eth_getLogs to a small block span (rejects >~5000 with\n // -32005 \"Requested range exceeds maximum RPC range limit\"). The first sync\n // spans block 1 -> chain head (~millions), so page the query in fixed\n // windows and concat the results.\n const LOGS_RANGE = 5000\n const queryChunked = async (\n topic: ethers.DeferredTopicFilter | undefined\n ): Promise<Awaited<ReturnType<EventQuery>>> => {\n if (!topic) return []\n const out: Awaited<ReturnType<EventQuery>> = []\n for (let lo = fromBlockSafe; lo <= TO; lo += LOGS_RANGE) {\n const hi = Math.min(lo + LOGS_RANGE - 1, TO)\n const part = await queryFilter.call(registry, topic, lo, hi)\n for (const e of part) out.push(e)\n }\n return out\n }\n const addedEvents = await queryChunked(addedTopic)\n const revokedEvents = await queryChunked(revokedTopic)\n\n interface ReplayEvent {\n kind: 'add' | 'remove'\n poseidon: bigint\n block: number\n txIndex: number\n logIndex: number\n }\n const combined: ReplayEvent[] = []\n for (const e of addedEvents) {\n combined.push({\n kind: 'add',\n poseidon: BigInt(e.args.leafPoseidon),\n block: e.blockNumber,\n txIndex: e.transactionIndex,\n logIndex: e.logIndex,\n })\n }\n for (const e of revokedEvents) {\n combined.push({\n kind: 'remove',\n poseidon: BigInt(e.args.leafPoseidon),\n block: e.blockNumber,\n txIndex: e.transactionIndex,\n logIndex: e.logIndex,\n })\n }\n combined.sort((a, b) => {\n if (a.block !== b.block) return a.block - b.block\n if (a.txIndex !== b.txIndex) return a.txIndex - b.txIndex\n return a.logIndex - b.logIndex\n })\n\n for (const e of combined) {\n if (e.kind === 'add') {\n active.push(e.poseidon)\n } else {\n const idx = active.findIndex((v) => v === e.poseidon)\n if (idx >= 0) active.splice(idx, 1)\n }\n }\n\n const newRecord = {\n lastSyncedBlock: TO,\n poseidon: active.map((v) => '0x' + v.toString(16).padStart(64, '0')),\n }\n if (cached) {\n cached.content = newRecord as unknown as Record<string, unknown>\n await records.update(cached)\n } else {\n await records.save({\n id: recordId,\n content: newRecord as unknown as Record<string, unknown>,\n tags: { type: 'kanon-zk-path-cache', credDefId: credDefId.toLowerCase() },\n })\n }\n return active\n }\n\n private cacheRecordId(credDefId: string): string {\n return `kanon-zk-path-cache:${credDefId.toLowerCase()}`\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { KanonClientService } from "../ledger/KanonClientService.js";
|
|
2
|
+
import "../ledger/index.js";
|
|
3
|
+
import { KanonZkIssuerKeyService } from "./KanonZkIssuerKeyService.js";
|
|
4
|
+
import { IssuerService, IssuerSyncCheckpoint } from "@ajna-inc/kanon-sdk";
|
|
5
|
+
import { AgentContext } from "@credo-ts/core";
|
|
6
|
+
|
|
7
|
+
//#region src/zk/KanonZkService.d.ts
|
|
8
|
+
/** Circuit-fixed attribute count. Mirrors `nAttr` in `non_revocation.circom`. */
|
|
9
|
+
declare const KANON_ZK_CIRCUIT_ATTRS = 16;
|
|
10
|
+
/**
|
|
11
|
+
* Pad / truncate a felt array to the circuit's 16-felt attribute width.
|
|
12
|
+
* Throws when the caller has more attributes than the circuit supports — that
|
|
13
|
+
* is a schema-design problem the caller has to fix, not a silent truncation.
|
|
14
|
+
*/
|
|
15
|
+
declare function padAttrsToCircuit(attrs: bigint[]): bigint[];
|
|
16
|
+
/**
|
|
17
|
+
* Restart-survivable Mode B (Groth16 non-revocation) facade for the credo
|
|
18
|
+
* plugin. Maintains a lazy-initialised `IssuerService` per credDef.
|
|
19
|
+
*
|
|
20
|
+
* Cold start:
|
|
21
|
+
*
|
|
22
|
+
* 1. Caller asks for `getOrInit(credDefId)`.
|
|
23
|
+
* 2. The service looks up a persisted checkpoint in `GenericRecordsApi`.
|
|
24
|
+
* 3. If present, `loadCheckpoint` rehydrates the local active leaf set + the
|
|
25
|
+
* keccak↔poseidon companion map without touching chain.
|
|
26
|
+
* 4. `reconstructFromChain(lastSyncedBlock)` then folds in any events that
|
|
27
|
+
* arrived since the snapshot.
|
|
28
|
+
* 5. The updated checkpoint is persisted.
|
|
29
|
+
*
|
|
30
|
+
* Subsequent calls reuse the cached `IssuerService` in-process. Plugin reload
|
|
31
|
+
* (agent shutdown) is survived by the persisted checkpoint.
|
|
32
|
+
*/
|
|
33
|
+
declare class KanonZkService {
|
|
34
|
+
private readonly clientService;
|
|
35
|
+
private readonly issuerKeyService;
|
|
36
|
+
private readonly cache;
|
|
37
|
+
constructor(clientService: KanonClientService, issuerKeyService: KanonZkIssuerKeyService);
|
|
38
|
+
/**
|
|
39
|
+
* Get the issuer service for `credDefId`. Idempotent — subsequent calls
|
|
40
|
+
* return the cached instance. The caller must ensure `clientService.init()`
|
|
41
|
+
* has completed before invoking this.
|
|
42
|
+
*/
|
|
43
|
+
getOrInit(agentContext: AgentContext, credDefId: string): Promise<IssuerService>;
|
|
44
|
+
/**
|
|
45
|
+
* Revoke `credIds` for `credDefId`. Lazy-initialises the issuer service if
|
|
46
|
+
* needed, derives keccak leaves via the SDK, publishes `batchUpdate` to
|
|
47
|
+
* MerkleStateRegistry, and re-persists the checkpoint so the local state
|
|
48
|
+
* survives the next restart.
|
|
49
|
+
*/
|
|
50
|
+
revoke(agentContext: AgentContext, credDefId: string, credIds: string[]): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Add issued credentials to the on-chain Merkle roots.
|
|
53
|
+
*
|
|
54
|
+
* For each `{credId, attributes}` we compute:
|
|
55
|
+
*
|
|
56
|
+
* - Mode A leaf: `deriveLeaf(keccak256(utf8(credId)))` — the OZ-keccak
|
|
57
|
+
* tree leaf used by the nullifier path. Always computed
|
|
58
|
+
* so revocation works even on Mode B-only credDefs (the
|
|
59
|
+
* contract just won't accept Mode A consume on them).
|
|
60
|
+
* - Mode B leaf: `Poseidon(LEAF_TAG, credDefId, credId, Poseidon(attrs))`
|
|
61
|
+
* — the tagged leaf the `non_revocation.circom` circuit
|
|
62
|
+
* recomputes from its inputs. Same value the issuer's
|
|
63
|
+
* BabyJubjub signature was computed over inside
|
|
64
|
+
* `KanonZkApi.prepareModeBCredential`.
|
|
65
|
+
*
|
|
66
|
+
* The credDefId and credId felts are `uint256(bytes32) mod p`, matching
|
|
67
|
+
* the on-chain registry's `publicSignals[1]` binding. `attributes` MUST be
|
|
68
|
+
* the same felt array (in the same order) the prep step used — see the
|
|
69
|
+
* docstring on `prepareModeBCredential` for the canonical encoding.
|
|
70
|
+
*/
|
|
71
|
+
addIssued(agentContext: AgentContext, credDefId: string, credentials: Array<{
|
|
72
|
+
credId: string;
|
|
73
|
+
attributes: bigint[];
|
|
74
|
+
}>): Promise<void>;
|
|
75
|
+
/** Snapshot the current active-leaf set for a credDef (mostly for tests). */
|
|
76
|
+
getCheckpoint(agentContext: AgentContext, credDefId: string): Promise<IssuerSyncCheckpoint>;
|
|
77
|
+
/** Drop the in-process cache for a credDef. Forces re-init on next call. */
|
|
78
|
+
invalidate(credDefId: string): void;
|
|
79
|
+
/**
|
|
80
|
+
* Pad / truncate a `bigint[]` to the circuit-fixed 16-felt input width.
|
|
81
|
+
*
|
|
82
|
+
* The compiled `non_revocation.circom` consumes EXACTLY 16 attribute felts.
|
|
83
|
+
* Real schemas have fewer, so we right-pad with `0n`. Schemas with more than
|
|
84
|
+
* 16 attrs do NOT fit in this circuit and are caught at the boundary —
|
|
85
|
+
* surfacing the constraint to the caller rather than silently truncating.
|
|
86
|
+
*/
|
|
87
|
+
private persistCheckpoint;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { KANON_ZK_CIRCUIT_ATTRS, KanonZkService, padAttrsToCircuit };
|
|
91
|
+
//# sourceMappingURL=KanonZkService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KanonZkService.d.ts","names":[],"sources":["../../src/zk/KanonZkService.ts"],"mappings":";;;;;;;;cAmBa,sBAAA;AAAb;;;;;AAAA,iBAOgB,iBAAA,CAAkB,KAAA;;;;;AA4BlC;;;;;;;;;;;;;cACa,cAAA;EAAA,iBAIQ,aAAA;EAAA,iBACA,gBAAA;EAAA,iBAJF,KAAA;cAGE,aAAA,EAAe,kBAAA,EACf,gBAAA,EAAkB,uBAAA;EADlB;;;;;EASN,SAAA,CAAU,YAAA,EAAc,YAAA,EAAc,SAAA,WAAoB,OAAA,CAAQ,aAAA;EAR1C;;;;;;EAyDxB,MAAA,CACX,YAAA,EAAc,YAAA,EACd,SAAA,UACA,OAAA,aACC,OAAA;EArD4E;;;;;;;;;;;;;;;;;;;;EAgFlE,SAAA,CACX,YAAA,EAAc,YAAA,EACd,SAAA,UACA,WAAA,EAAa,KAAA;IAAQ,MAAA;IAAgB,UAAA;EAAA,KACpC,OAAA;EAoGW;EAtBD,aAAA,CACX,YAAA,EAAc,YAAA,EACd,SAAA,WACC,OAAA,CAAQ,oBAAA;EAmBoB;EAbxB,UAAA,CAAW,SAAA;;;;;;;;;UAaJ,iBAAA;AAAA"}
|