@nekzus/liop 2.4.0-alpha.21 → 2.4.0-alpha.23

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 (67) hide show
  1. package/README.md +72 -36
  2. package/dist/bin/agent.js +8 -7
  3. package/dist/bin/agent.js.map +1 -1
  4. package/dist/bridge.d.ts +4 -3
  5. package/dist/bridge.js +3 -2
  6. package/dist/{chunk-FCFTYOAS.js → chunk-3WKFZQ34.js} +22 -12
  7. package/dist/chunk-3WKFZQ34.js.map +1 -0
  8. package/dist/{chunk-VRB5HUYU.js → chunk-AMSFSS2I.js} +14 -9
  9. package/dist/chunk-AMSFSS2I.js.map +1 -0
  10. package/dist/{chunk-VRDZ5IKE.js → chunk-E2CFIWD6.js} +15 -9
  11. package/dist/chunk-E2CFIWD6.js.map +1 -0
  12. package/dist/{chunk-EJ426URA.js → chunk-E7RSX476.js} +4 -4
  13. package/dist/{chunk-EJ426URA.js.map → chunk-E7RSX476.js.map} +1 -1
  14. package/dist/{chunk-UJFWPRDM.js → chunk-GFGSHQN5.js} +3 -3
  15. package/dist/{chunk-UJFWPRDM.js.map → chunk-GFGSHQN5.js.map} +1 -1
  16. package/dist/{chunk-XRDN232O.js → chunk-KB3HUVMD.js} +2 -2
  17. package/dist/chunk-KB3HUVMD.js.map +1 -0
  18. package/dist/chunk-OHMZZMMC.js +58 -0
  19. package/dist/chunk-OHMZZMMC.js.map +1 -0
  20. package/dist/chunk-P34HDRN5.js +213 -0
  21. package/dist/chunk-P34HDRN5.js.map +1 -0
  22. package/dist/{chunk-PAICJCKJ.js → chunk-Q3FKHJ3B.js} +17 -4
  23. package/dist/chunk-Q3FKHJ3B.js.map +1 -0
  24. package/dist/{chunk-5SWHE62F.js → chunk-T2QDHVUD.js} +71 -11
  25. package/dist/chunk-T2QDHVUD.js.map +1 -0
  26. package/dist/{chunk-2KSO3W4A.js → chunk-YLFNJQI2.js} +2 -2
  27. package/dist/{chunk-2KSO3W4A.js.map → chunk-YLFNJQI2.js.map} +1 -1
  28. package/dist/{chunk-2STZHJ24.js → chunk-ZRWNMP5L.js} +58 -7
  29. package/dist/chunk-ZRWNMP5L.js.map +1 -0
  30. package/dist/client.d.ts +5 -4
  31. package/dist/client.js +7 -6
  32. package/dist/gateway.d.ts +6 -5
  33. package/dist/gateway.js +7 -6
  34. package/dist/{hybrid-DWe1bMoV.d.ts → hybrid-B7EjCj3q.d.ts} +4 -4
  35. package/dist/{index-CdW8j8Bn.d.ts → index-D2P6Z_hP.d.ts} +25 -2
  36. package/dist/{index-BuEQtBHD.d.ts → index-DDwiS7tf.d.ts} +8 -4
  37. package/dist/index.d.ts +51 -9
  38. package/dist/index.js +12 -10
  39. package/dist/index.js.map +1 -1
  40. package/dist/mesh.d.ts +1 -1
  41. package/dist/mesh.js +1 -1
  42. package/dist/{node-B0b2vUFS.d.ts → node-Djzm6UYd.d.ts} +8 -0
  43. package/dist/protocol/liop_core.proto +22 -6
  44. package/dist/server.d.ts +4 -3
  45. package/dist/server.js +5 -4
  46. package/dist/{types-CzRSOlOo.d.ts → types-rxL19f0l.d.ts} +3 -0
  47. package/dist/types.d.ts +2 -1
  48. package/dist/types.js +2 -1
  49. package/dist/{verifier-COnid_dg.d.ts → verifier-DTn1LXDU.d.ts} +25 -3
  50. package/dist/verifier-UBJTZQSA.js +6 -0
  51. package/dist/{verifier-XFU7ZB2W.js.map → verifier-UBJTZQSA.js.map} +1 -1
  52. package/dist/workers/logic-execution.d.ts +6 -0
  53. package/dist/workers/logic-execution.js +56 -1
  54. package/dist/workers/logic-execution.js.map +1 -1
  55. package/dist/workers/zk-verifier.d.ts +9 -0
  56. package/dist/workers/zk-verifier.js +119 -47
  57. package/dist/workers/zk-verifier.js.map +1 -1
  58. package/dist/zk-CYImPsa6.d.ts +91 -0
  59. package/package.json +2 -1
  60. package/dist/chunk-2STZHJ24.js.map +0 -1
  61. package/dist/chunk-5SWHE62F.js.map +0 -1
  62. package/dist/chunk-FCFTYOAS.js.map +0 -1
  63. package/dist/chunk-PAICJCKJ.js.map +0 -1
  64. package/dist/chunk-VRB5HUYU.js.map +0 -1
  65. package/dist/chunk-VRDZ5IKE.js.map +0 -1
  66. package/dist/chunk-XRDN232O.js.map +0 -1
  67. package/dist/verifier-XFU7ZB2W.js +0 -6
@@ -1,8 +1,8 @@
1
1
  import { sanitizeOutput } from './chunk-Y62GORQF.js';
2
2
  import { LIOP_SCOPES, Dilithium65Wrapper, authorizeRequest } from './chunk-WPTOJYN5.js';
3
- import { GRPC_CHANNEL_OPTIONS, liopV1, createServerCredentials, TokenTelemetryEngine } from './chunk-UJFWPRDM.js';
4
- import { egressBlocksTotal, toolCallsTotal, fuelConsumed, wireEgressBytesTotal, wireSavedBytesTotal, toolCallErrorsTotal } from './chunk-PAICJCKJ.js';
5
- import { MeshNode } from './chunk-XRDN232O.js';
3
+ import { GRPC_CHANNEL_OPTIONS, liopV1, createServerCredentials, TokenTelemetryEngine } from './chunk-GFGSHQN5.js';
4
+ import { egressBlocksTotal, toolCallsTotal, fuelConsumed, wireEgressBytesTotal, wireSavedBytesTotal, toolCallErrorsTotal } from './chunk-Q3FKHJ3B.js';
5
+ import { MeshNode } from './chunk-KB3HUVMD.js';
6
6
  import { log } from './chunk-K3DGJLUY.js';
7
7
  import { Buffer } from 'buffer';
8
8
  import * as crypto3 from 'crypto';
@@ -2810,11 +2810,18 @@ Data structure: ${schemaDigest}. Full schema: resource ${uri}. Guidelines: resou
2810
2810
  await this.meshNode.start();
2811
2811
  const meshNodeRef = this.meshNode;
2812
2812
  this.meshNode.registerManifestHandler(() => {
2813
- const tools = this.listTools().map((t) => ({
2814
- name: t.name,
2815
- description: t.description,
2816
- inputSchema: t.inputSchema
2817
- }));
2813
+ const tools = this.listTools().map((t) => {
2814
+ const entry = this.tools.get(t.name);
2815
+ return {
2816
+ name: t.name,
2817
+ description: t.description,
2818
+ inputSchema: t.inputSchema,
2819
+ zkMode: entry?.policy?.zkMode,
2820
+ guestImageId: entry?.policy?.guestImageId ?? this.config?.guestImageId,
2821
+ circuitName: entry?.policy?.circuitName,
2822
+ vkey: entry?.policy?.vkey
2823
+ };
2824
+ });
2818
2825
  const resources = Array.from(this.resources.values()).map((r) => ({
2819
2826
  name: r.name,
2820
2827
  uri: r.uri,
@@ -2830,6 +2837,8 @@ Data structure: ${schemaDigest}. Full schema: resource ${uri}. Guidelines: resou
2830
2837
  serverInfo: this.serverInfo,
2831
2838
  authRequired: this.jwtValidator !== void 0,
2832
2839
  tokenSlug: this.config?.tokenSlug,
2840
+ guestImageId: this.config?.guestImageId,
2841
+ vkeys: this.config?.zkVkeys,
2833
2842
  taxonomy: this.config?.taxonomy ? {
2834
2843
  domain: this.config.taxonomy.domain || "Unknown Domain",
2835
2844
  clearanceTier: this.config.taxonomy.clearanceTier ?? 0,
@@ -3058,6 +3067,16 @@ Data structure: ${schemaDigest}. Full schema: resource ${uri}. Guidelines: resou
3058
3067
  sensitivity: toolPolicy.dpSensitivity ?? 1,
3059
3068
  smallDatasetThreshold: toolPolicy.dpSmallDatasetThreshold ?? 50
3060
3069
  } : void 0;
3070
+ let requestedProofMode = request.requested_proof_mode;
3071
+ if (requestedProofMode === void 0 || requestedProofMode === 0 /* PROOF_MODE_LEGACY_HMAC */) {
3072
+ if (toolPolicy?.zkMode === "required") {
3073
+ requestedProofMode = 2 /* PROOF_MODE_ZK_BLOCKING */;
3074
+ } else if (toolPolicy?.zkMode === "optimistic") {
3075
+ requestedProofMode = 1 /* PROOF_MODE_ZK_OPTIMISTIC */;
3076
+ } else {
3077
+ requestedProofMode = 0 /* PROOF_MODE_LEGACY_HMAC */;
3078
+ }
3079
+ }
3061
3080
  const workerResponse = await this.workerPool.run({
3062
3081
  ciphertext: request.pqc_ciphertext,
3063
3082
  secretKeyObj: Array.from(session.kyber_sk),
@@ -3068,9 +3087,27 @@ Data structure: ${schemaDigest}. Full schema: resource ${uri}. Guidelines: resou
3068
3087
  sessionToken: request.session_token,
3069
3088
  sessionTimestamp: session.createdAt,
3070
3089
  isEncrypted: true,
3090
+ proofMode: requestedProofMode,
3091
+ guestImageId: toolPolicy?.guestImageId ?? this.config?.guestImageId,
3071
3092
  dpConfig
3072
3093
  // Apply DP noise inside worker before ZK-Receipt commitment
3073
3094
  });
3095
+ if (requestedProofMode === 2 /* PROOF_MODE_ZK_BLOCKING */ && workerResponse.proof_type !== 2 /* GROTH16 */) {
3096
+ log.error(
3097
+ `[LIOP-RPC] Enclave policy violation: Valid Groth16 zero-knowledge proof required but unavailable for ${toolName || "tool"}`
3098
+ );
3099
+ const errorResponse = {
3100
+ semantic_evidence: "[LIOP-ZK] Clearance Tier 1 enclave policy violation: Valid Groth16 zero-knowledge proof required but unavailable.",
3101
+ cryptographic_proof: Buffer.from(""),
3102
+ zk_receipt: Buffer.from(""),
3103
+ is_error: true,
3104
+ proof_type: 0 /* PROOF_TYPE_HMAC_LEGACY */
3105
+ };
3106
+ call.write(errorResponse, () => {
3107
+ call.end();
3108
+ });
3109
+ return;
3110
+ }
3074
3111
  const sanitizedWorkerOutput = sanitizeOutput(workerResponse.output);
3075
3112
  let finalOutput;
3076
3113
  let validationOutput = sanitizedWorkerOutput;
@@ -3140,7 +3177,9 @@ Data structure: ${schemaDigest}. Full schema: resource ${uri}. Guidelines: resou
3140
3177
  "hex"
3141
3178
  ),
3142
3179
  zk_receipt: workerResponse.zk_receipt ? Buffer.from(workerResponse.zk_receipt, "base64") : Buffer.from(""),
3143
- is_error: false
3180
+ is_error: false,
3181
+ proof_type: workerResponse.proof_type === 2 /* GROTH16 */ ? 2 /* PROOF_TYPE_GROTH16 */ : 0 /* PROOF_TYPE_HMAC_LEGACY */,
3182
+ guest_image_id: workerResponse.guest_image_id || toolPolicy?.guestImageId || this.config?.guestImageId || ""
3144
3183
  };
3145
3184
  const violation = await this.piiScanner.scan(validationOutput);
3146
3185
  const aggregationViolation = this.violatesAggregationFirstPolicy(
@@ -3338,6 +3377,12 @@ Data structure: ${schemaDigest}. Full schema: resource ${uri}. Guidelines: resou
3338
3377
  sensitivity: dpPolicy.dpSensitivity ?? 1,
3339
3378
  smallDatasetThreshold: dpPolicy.dpSmallDatasetThreshold ?? 50
3340
3379
  } : void 0;
3380
+ let proofMode = 0 /* PROOF_MODE_LEGACY_HMAC */;
3381
+ if (dpPolicy?.zkMode === "required") {
3382
+ proofMode = 2 /* PROOF_MODE_ZK_BLOCKING */;
3383
+ } else if (dpPolicy?.zkMode === "optimistic") {
3384
+ proofMode = 1 /* PROOF_MODE_ZK_OPTIMISTIC */;
3385
+ }
3341
3386
  const workerResponse = await this.workerPool.run({
3342
3387
  ciphertext: new Uint8Array(0),
3343
3388
  secretKeyObj: Array.from(new Uint8Array(0)),
@@ -3348,15 +3393,30 @@ Data structure: ${schemaDigest}. Full schema: resource ${uri}. Guidelines: resou
3348
3393
  sessionToken: "local-dev-token",
3349
3394
  isEncrypted: false,
3350
3395
  // Use plaintext for local Logic-on-Origin injection
3396
+ proofMode,
3397
+ guestImageId: dpPolicy?.guestImageId ?? this.config?.guestImageId,
3351
3398
  dpConfig
3352
3399
  // Pass DP Config to apply inside worker before ZK-Receipt commitment
3353
3400
  });
3401
+ if (proofMode === 2 /* PROOF_MODE_ZK_BLOCKING */ && workerResponse.proof_type !== 2 /* GROTH16 */) {
3402
+ return {
3403
+ content: [
3404
+ {
3405
+ type: "text",
3406
+ text: "[LIOP-ZK] Clearance Tier 1 enclave policy violation: Valid Groth16 zero-knowledge proof required but unavailable."
3407
+ }
3408
+ ],
3409
+ isError: true
3410
+ };
3411
+ }
3354
3412
  const dpOutput = workerResponse.output;
3355
3413
  const sanitizedOutput = sanitizeOutput(dpOutput);
3356
3414
  const textOutput = JSON.stringify({
3357
3415
  computation_result: sanitizedOutput,
3358
3416
  image_id: workerResponse.image_id,
3359
3417
  zk_receipt: workerResponse.zk_receipt,
3418
+ proof_type: workerResponse.proof_type === 2 /* GROTH16 */ ? "GROTH16" : "HMAC_LEGACY",
3419
+ guest_image_id: workerResponse.guest_image_id,
3360
3420
  status: "Worker Pool Execution Success"
3361
3421
  });
3362
3422
  const content = [
@@ -3679,5 +3739,5 @@ Data structure: ${schemaDigest}. Full schema: resource ${uri}. Guidelines: resou
3679
3739
  };
3680
3740
 
3681
3741
  export { AUTH_DEFAULTS, AuditLogger, GENESIS_HASH, JwtValidator, LiopRpcServer, LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner, computeEntryHash, createOAuthServer, globalAuditLogger };
3682
- //# sourceMappingURL=chunk-5SWHE62F.js.map
3683
- //# sourceMappingURL=chunk-5SWHE62F.js.map
3742
+ //# sourceMappingURL=chunk-T2QDHVUD.js.map
3743
+ //# sourceMappingURL=chunk-T2QDHVUD.js.map