zklicensing 0.1.0-beta.2 → 0.1.0-beta.21
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/README.md +417 -201
- package/build/agent.d.ts +371 -0
- package/build/agent.d.ts.map +1 -0
- package/build/agent.js +553 -0
- package/build/agent.js.map +1 -0
- package/build/agentActions.d.ts +841 -0
- package/build/agentActions.d.ts.map +1 -0
- package/build/agentActions.js +581 -0
- package/build/agentActions.js.map +1 -0
- package/build/agentRecord.d.ts +83 -0
- package/build/agentRecord.d.ts.map +1 -0
- package/build/agentRecord.js +69 -0
- package/build/agentRecord.js.map +1 -0
- package/build/agentVendor.d.ts +220 -0
- package/build/agentVendor.d.ts.map +1 -0
- package/build/agentVendor.js +306 -0
- package/build/agentVendor.js.map +1 -0
- package/build/appsLookup.d.ts +14 -0
- package/build/appsLookup.d.ts.map +1 -0
- package/build/appsLookup.js +12 -0
- package/build/appsLookup.js.map +1 -0
- package/build/archiveBootstrap.d.ts +31 -5
- package/build/archiveBootstrap.d.ts.map +1 -0
- package/build/archiveBootstrap.js +140 -47
- package/build/archiveBootstrap.js.map +1 -0
- package/build/atomicJson.d.ts +5 -0
- package/build/atomicJson.d.ts.map +1 -0
- package/build/atomicJson.js +55 -0
- package/build/atomicJson.js.map +1 -0
- package/build/bindClient.d.ts +85 -0
- package/build/bindClient.d.ts.map +1 -0
- package/build/bindClient.js +187 -0
- package/build/bindClient.js.map +1 -0
- package/build/buyClient.d.ts +27 -4
- package/build/buyClient.d.ts.map +1 -0
- package/build/buyClient.js +72 -26
- package/build/buyClient.js.map +1 -0
- package/build/chainHead.d.ts +61 -0
- package/build/chainHead.d.ts.map +1 -0
- package/build/chainHead.js +88 -0
- package/build/chainHead.js.map +1 -0
- package/build/compactMerkleMap.d.ts +72 -0
- package/build/compactMerkleMap.d.ts.map +1 -0
- package/build/compactMerkleMap.js +224 -0
- package/build/compactMerkleMap.js.map +1 -0
- package/build/contractInterface.d.ts +191 -51
- package/build/contractInterface.d.ts.map +1 -0
- package/build/contractInterface.js +234 -43
- package/build/contractInterface.js.map +1 -0
- package/build/contractTypes.d.ts +9 -0
- package/build/contractTypes.d.ts.map +1 -0
- package/build/contractTypes.js +28 -0
- package/build/contractTypes.js.map +1 -0
- package/build/countryStats.d.ts +12 -3
- package/build/countryStats.d.ts.map +1 -0
- package/build/countryStats.js +87 -23
- package/build/countryStats.js.map +1 -0
- package/build/deployClient.d.ts +138 -24
- package/build/deployClient.d.ts.map +1 -0
- package/build/deployClient.js +91 -31
- package/build/deployClient.js.map +1 -0
- package/build/deviceIdentity.d.ts +68 -0
- package/build/deviceIdentity.d.ts.map +1 -0
- package/build/deviceIdentity.js +209 -0
- package/build/deviceIdentity.js.map +1 -0
- package/build/freezeClient.d.ts +26 -6
- package/build/freezeClient.d.ts.map +1 -0
- package/build/freezeClient.js +30 -6
- package/build/freezeClient.js.map +1 -0
- package/build/generationClient.d.ts +6 -3
- package/build/generationClient.d.ts.map +1 -0
- package/build/generationClient.js +25 -38
- package/build/generationClient.js.map +1 -0
- package/build/holderSecret.d.ts +70 -0
- package/build/holderSecret.d.ts.map +1 -0
- package/build/holderSecret.js +76 -0
- package/build/holderSecret.js.map +1 -0
- package/build/index.d.ts +38 -38
- package/build/index.d.ts.map +1 -0
- package/build/index.js +97 -121
- package/build/index.js.map +1 -0
- package/build/keysClient.d.ts +142 -0
- package/build/keysClient.d.ts.map +1 -0
- package/build/keysClient.js +109 -0
- package/build/keysClient.js.map +1 -0
- package/build/licenseLeaf.d.ts +76 -0
- package/build/licenseLeaf.d.ts.map +1 -0
- package/build/licenseLeaf.js +189 -0
- package/build/licenseLeaf.js.map +1 -0
- package/build/licenseRecord.d.ts +68 -5
- package/build/licenseRecord.d.ts.map +1 -0
- package/build/licenseRecord.js +26 -1
- package/build/licenseRecord.js.map +1 -0
- package/build/licenseStore.d.ts +81 -4
- package/build/licenseStore.d.ts.map +1 -0
- package/build/licenseStore.js +400 -30
- package/build/licenseStore.js.map +1 -0
- package/build/licenseTrustless.d.ts +43 -0
- package/build/licenseTrustless.d.ts.map +1 -0
- package/build/licenseTrustless.js +180 -0
- package/build/licenseTrustless.js.map +1 -0
- package/build/manifestVerify.d.ts +29 -1
- package/build/manifestVerify.d.ts.map +1 -0
- package/build/manifestVerify.js +46 -4
- package/build/manifestVerify.js.map +1 -0
- package/build/minaPriceHistory.d.ts +9 -0
- package/build/minaPriceHistory.d.ts.map +1 -0
- package/build/minaPriceHistory.js +152 -0
- package/build/minaPriceHistory.js.map +1 -0
- package/build/onChainRoot.d.ts +60 -0
- package/build/onChainRoot.d.ts.map +1 -0
- package/build/onChainRoot.js +74 -0
- package/build/onChainRoot.js.map +1 -0
- package/build/ownershipLicenseHash.d.ts +25 -0
- package/build/ownershipLicenseHash.d.ts.map +1 -0
- package/build/ownershipLicenseHash.js +29 -0
- package/build/ownershipLicenseHash.js.map +1 -0
- package/build/ownershipSignature.d.ts +153 -0
- package/build/ownershipSignature.d.ts.map +1 -0
- package/build/ownershipSignature.js +297 -0
- package/build/ownershipSignature.js.map +1 -0
- package/build/permitCheckFlow.d.ts +155 -0
- package/build/permitCheckFlow.d.ts.map +1 -0
- package/build/permitCheckFlow.js +196 -0
- package/build/permitCheckFlow.js.map +1 -0
- package/build/permitDescribe.d.ts +124 -0
- package/build/permitDescribe.d.ts.map +1 -0
- package/build/permitDescribe.js +324 -0
- package/build/permitDescribe.js.map +1 -0
- package/build/permitInterface.d.ts +85 -0
- package/build/permitInterface.d.ts.map +1 -0
- package/build/permitInterface.js +121 -0
- package/build/permitInterface.js.map +1 -0
- package/build/permitMessages.d.ts +313 -0
- package/build/permitMessages.d.ts.map +1 -0
- package/build/permitMessages.js +462 -0
- package/build/permitMessages.js.map +1 -0
- package/build/permitProof.d.ts +108 -0
- package/build/permitProof.d.ts.map +1 -0
- package/build/permitProof.js +202 -0
- package/build/permitProof.js.map +1 -0
- package/build/permitRegistryRebuild.d.ts +166 -0
- package/build/permitRegistryRebuild.d.ts.map +1 -0
- package/build/permitRegistryRebuild.js +347 -0
- package/build/permitRegistryRebuild.js.map +1 -0
- package/build/permitTree.d.ts +88 -0
- package/build/permitTree.d.ts.map +1 -0
- package/build/permitTree.js +230 -0
- package/build/permitTree.js.map +1 -0
- package/build/permitsClient.d.ts +680 -0
- package/build/permitsClient.d.ts.map +1 -0
- package/build/permitsClient.js +597 -0
- package/build/permitsClient.js.map +1 -0
- package/build/proveErrors.d.ts +50 -0
- package/build/proveErrors.d.ts.map +1 -0
- package/build/proveErrors.js +76 -0
- package/build/proveErrors.js.map +1 -0
- package/build/receipt.d.ts +95 -0
- package/build/receipt.d.ts.map +1 -0
- package/build/receipt.js +84 -0
- package/build/receipt.js.map +1 -0
- package/build/refundClient.d.ts +7 -12
- package/build/refundClient.d.ts.map +1 -0
- package/build/refundClient.js +52 -21
- package/build/refundClient.js.map +1 -0
- package/build/registryTrustVerify.d.ts +78 -0
- package/build/registryTrustVerify.d.ts.map +1 -0
- package/build/registryTrustVerify.js +129 -0
- package/build/registryTrustVerify.js.map +1 -0
- package/build/releaseClient.d.ts +26 -0
- package/build/releaseClient.d.ts.map +1 -0
- package/build/releaseClient.js +65 -0
- package/build/releaseClient.js.map +1 -0
- package/build/renewClient.d.ts +28 -2
- package/build/renewClient.d.ts.map +1 -0
- package/build/renewClient.js +31 -27
- package/build/renewClient.js.map +1 -0
- package/build/seatName.d.ts +8 -0
- package/build/seatName.d.ts.map +1 -0
- package/build/seatName.js +136 -0
- package/build/seatName.js.map +1 -0
- package/build/slotConstants.d.ts +15 -0
- package/build/slotConstants.d.ts.map +1 -0
- package/build/slotConstants.js +17 -0
- package/build/slotConstants.js.map +1 -0
- package/build/statsClient.d.ts +61 -7
- package/build/statsClient.d.ts.map +1 -0
- package/build/statsClient.js +44 -5
- package/build/statsClient.js.map +1 -0
- package/build/successorChain.d.ts +35 -0
- package/build/successorChain.d.ts.map +1 -0
- package/build/successorChain.js +69 -0
- package/build/successorChain.js.map +1 -0
- package/build/taxId.d.ts +44 -0
- package/build/taxId.d.ts.map +1 -0
- package/build/taxId.js +212 -0
- package/build/taxId.js.map +1 -0
- package/build/trustAnchorVerify.d.ts +49 -0
- package/build/trustAnchorVerify.d.ts.map +1 -0
- package/build/trustAnchorVerify.js +432 -0
- package/build/trustAnchorVerify.js.map +1 -0
- package/build/trustAnchorVerifyCli.d.ts +45 -0
- package/build/trustAnchorVerifyCli.d.ts.map +1 -0
- package/build/trustAnchorVerifyCli.js +235 -0
- package/build/trustAnchorVerifyCli.js.map +1 -0
- package/build/txBroadcastClient.d.ts +26 -0
- package/build/txBroadcastClient.d.ts.map +1 -0
- package/build/txBroadcastClient.js +20 -0
- package/build/txBroadcastClient.js.map +1 -0
- package/build/unbindClient.d.ts +77 -0
- package/build/unbindClient.d.ts.map +1 -0
- package/build/unbindClient.js +169 -0
- package/build/unbindClient.js.map +1 -0
- package/build/units.d.ts +28 -0
- package/build/units.d.ts.map +1 -0
- package/build/units.js +65 -0
- package/build/units.js.map +1 -0
- package/build/vatRates.d.ts +54 -0
- package/build/vatRates.d.ts.map +1 -0
- package/build/vatRates.js +82 -0
- package/build/vatRates.js.map +1 -0
- package/build/vatRatesData.d.ts +5 -0
- package/build/vatRatesData.d.ts.map +1 -0
- package/build/vatRatesData.js +42 -0
- package/build/vatRatesData.js.map +1 -0
- package/build/vendorAccountClient.d.ts +66 -0
- package/build/vendorAccountClient.d.ts.map +1 -0
- package/build/vendorAccountClient.js +47 -0
- package/build/vendorAccountClient.js.map +1 -0
- package/build/verifyCore.d.ts +4 -1
- package/build/verifyCore.d.ts.map +1 -0
- package/build/verifyCore.js +21 -10
- package/build/verifyCore.js.map +1 -0
- package/build/verifyOffline.d.ts +85 -0
- package/build/verifyOffline.d.ts.map +1 -0
- package/build/verifyOffline.js +139 -0
- package/build/verifyOffline.js.map +1 -0
- package/build/verifyService.d.ts.map +1 -0
- package/build/verifyService.js +571 -501
- package/build/verifyService.js.map +1 -0
- package/build/verifyWithAncestors.d.ts +19 -0
- package/build/verifyWithAncestors.d.ts.map +1 -0
- package/build/verifyWithAncestors.js +127 -0
- package/build/verifyWithAncestors.js.map +1 -0
- package/build/zipToState.d.ts +2 -0
- package/build/zipToState.d.ts.map +1 -0
- package/build/zipToState.js +94 -0
- package/build/zipToState.js.map +1 -0
- package/package.json +141 -16
- package/src/agent.ts +682 -0
- package/src/agentActions.ts +637 -0
- package/src/agentRecord.ts +121 -0
- package/src/agentVendor.ts +356 -0
- package/src/appsLookup.ts +48 -0
- package/src/archiveBootstrap.ts +386 -0
- package/src/atomicJson.ts +53 -0
- package/src/bindClient.ts +297 -0
- package/src/buyClient.ts +344 -0
- package/src/chainHead.ts +106 -0
- package/src/compactMerkleMap.ts +222 -0
- package/src/contractInterface.ts +465 -0
- package/src/contractTypes.ts +31 -0
- package/src/countryStats.ts +200 -0
- package/src/deployClient.ts +517 -0
- package/src/deviceIdentity.ts +249 -0
- package/src/freezeClient.ts +162 -0
- package/src/generationClient.ts +145 -0
- package/src/holderSecret.ts +91 -0
- package/src/index.ts +362 -0
- package/src/keysClient.ts +135 -0
- package/src/licenseLeaf.ts +221 -0
- package/src/licenseRecord.ts +190 -0
- package/src/licenseStore.ts +767 -0
- package/src/licenseTrustless.ts +207 -0
- package/src/manifestVerify.ts +164 -0
- package/src/minaPriceHistory.ts +166 -0
- package/src/onChainRoot.ts +90 -0
- package/src/ownershipLicenseHash.ts +31 -0
- package/src/ownershipSignature.ts +421 -0
- package/src/permitCheckFlow.ts +227 -0
- package/src/permitDescribe.ts +362 -0
- package/src/permitInterface.ts +146 -0
- package/src/permitMessages.ts +572 -0
- package/src/permitProof.ts +230 -0
- package/src/permitRegistryRebuild.ts +423 -0
- package/src/permitTree.ts +232 -0
- package/src/permitsClient.ts +746 -0
- package/src/proveErrors.ts +98 -0
- package/src/receipt.ts +156 -0
- package/src/refundClient.ts +177 -0
- package/src/registryTrustVerify.ts +192 -0
- package/src/releaseClient.ts +101 -0
- package/src/renewClient.ts +234 -0
- package/src/seatName.ts +165 -0
- package/src/slotConstants.ts +18 -0
- package/src/statsClient.ts +249 -0
- package/src/successorChain.ts +87 -0
- package/src/taxId.ts +227 -0
- package/src/trustAnchorVerify.ts +550 -0
- package/src/trustAnchorVerifyCli.ts +234 -0
- package/src/txBroadcastClient.ts +48 -0
- package/src/unbindClient.ts +233 -0
- package/src/units.ts +74 -0
- package/src/vatRates.ts +100 -0
- package/src/vatRatesData.ts +43 -0
- package/src/vendorAccountClient.ts +120 -0
- package/src/verifyCore.ts +100 -0
- package/src/verifyOffline.ts +212 -0
- package/src/verifyService.ts +982 -0
- package/src/verifyWithAncestors.ts +163 -0
- package/src/zipToState.ts +94 -0
- package/build/licenseProof.d.ts +0 -26
- package/build/licenseProof.js +0 -41
- package/build/migrateClient.d.ts +0 -43
- package/build/migrateClient.js +0 -47
- package/build/ownership.d.ts +0 -34
- package/build/ownership.js +0 -147
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Copyright (c) 2025-2026 zkLicensing project developers
|
|
2
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
3
|
+
/**
|
|
4
|
+
* verifyOffline.ts
|
|
5
|
+
*
|
|
6
|
+
* Non-custodial device-binding offline verifier. Given:
|
|
7
|
+
* - a serialized MerkleMapWitness for the license entry
|
|
8
|
+
* - a `licensesRoot` value the caller has anchored to (see "Trust anchoring")
|
|
9
|
+
* - the full LicenseLeaf field set (licenseHash, expirySlot, deviceCap,
|
|
10
|
+
* deviceSlots[]) as of that sync — the leaf carries no separate
|
|
11
|
+
* owner-pubkey commitment because `licenseHash` IS it (buy circuit
|
|
12
|
+
* asserts equality)
|
|
13
|
+
* - the caller's device public key
|
|
14
|
+
*
|
|
15
|
+
* this module:
|
|
16
|
+
* 1. Reconstructs the LicenseLeaf hash from its fields.
|
|
17
|
+
* 2. Rebuilds the on-chain root through the witness and asserts it matches
|
|
18
|
+
* the passed `licensesRoot` — proves the leaf field set is authentic
|
|
19
|
+
* relative to that root.
|
|
20
|
+
* 3. If `deviceCap > 0`: computes the device commitment for the caller's
|
|
21
|
+
* pubkey and asserts it appears in `occupied[]`.
|
|
22
|
+
* 4. Asserts `expirySlot > currentSlot` (grace-period handling stays in
|
|
23
|
+
* the online verifier; the device-bound offline path is pass/fail).
|
|
24
|
+
* 5. If `deviceCap === 0`: skips the device check entirely — the app has
|
|
25
|
+
* binding disabled at the vendor level.
|
|
26
|
+
*
|
|
27
|
+
* Trust anchoring — where does `licensesRoot` come from?
|
|
28
|
+
* -------------------------------------------------------
|
|
29
|
+
* This module treats the passed root as ground truth. It does NOT fetch
|
|
30
|
+
* it. Two ways to source it:
|
|
31
|
+
*
|
|
32
|
+
* • Non-custodial (recommended). Fetch it yourself from Mina via
|
|
33
|
+
* `fetchOnChainLicensesRoot({ zkAppAddress, network })` from
|
|
34
|
+
* `zklicensing/on-chain-root`. That reads `zkapp.appState[0]` on
|
|
35
|
+
* the deployed LicensingApp — the same field the circuit updates on
|
|
36
|
+
* every buy/renew/bind/unbind/refund. No trust in the licensing
|
|
37
|
+
* service required.
|
|
38
|
+
*
|
|
39
|
+
* • Custodial (trusted-service). Use whatever root the licensing
|
|
40
|
+
* service returned on its `/verify` or `/witness` response. Faster
|
|
41
|
+
* (no o1js + Mina RPC round-trip) but relies on the service to
|
|
42
|
+
* report the true chain state. If you go this route, cross-check
|
|
43
|
+
* the reported root against the on-chain value on some cadence.
|
|
44
|
+
*
|
|
45
|
+
* The caller fetches the device slot state (occupied[] + freedAt[] + cap)
|
|
46
|
+
* from the vendor SDK or platform verifier alongside the licensesRoot on
|
|
47
|
+
* the sync cadence of their choice. The parallel arrays fold to
|
|
48
|
+
* `deviceSlotsRoot`, so any tampering with slot contents changes the leaf
|
|
49
|
+
* hash and fails the witness check — provided `licensesRoot` itself is
|
|
50
|
+
* trustworthy (see above), verifyOffline needs no trust in whoever
|
|
51
|
+
* served the slot arrays.
|
|
52
|
+
*
|
|
53
|
+
* Not exported at the top-level barrel by default; vendors who ship a
|
|
54
|
+
* device-cap app import from `zklicensing/verify-offline` explicitly.
|
|
55
|
+
*/
|
|
56
|
+
import { Field, Poseidon, UInt32 } from 'o1js';
|
|
57
|
+
import { deserializeWitness } from './licenseStore.js';
|
|
58
|
+
import { computeDeviceSlotsRoot, DEVICE_SLOT_CAP_N, leafHash, LicenseLeaf, packSlotTimes, } from './licenseLeaf.js';
|
|
59
|
+
import { computeDeviceCommitment } from './deviceIdentity.js';
|
|
60
|
+
// Pad or trim the caller-supplied slot list to exactly DEVICE_SLOT_CAP_N and
|
|
61
|
+
// order by slotIndex. `computeDeviceSlotsRoot` requires the exact layout
|
|
62
|
+
// (occupied[i], freedAt[i], ...) that the circuit folds — mismatched length
|
|
63
|
+
// or ordering yields a different root and (correctly) fails the witness
|
|
64
|
+
// check downstream. Doing the normalization here keeps the caller free to
|
|
65
|
+
// pass only the occupied slots.
|
|
66
|
+
function normalizeSlots(devices) {
|
|
67
|
+
const occupied = [];
|
|
68
|
+
const freedAt = [];
|
|
69
|
+
const occupiedCommitments = [];
|
|
70
|
+
for (let i = 0; i < DEVICE_SLOT_CAP_N; i++) {
|
|
71
|
+
const slot = devices.find(d => d.slotIndex === i);
|
|
72
|
+
const occ = slot?.deviceCommitment ?? '0';
|
|
73
|
+
occupied.push(Field(occ));
|
|
74
|
+
occupiedCommitments.push(occ);
|
|
75
|
+
const boundU32 = UInt32.from(slot?.boundAtSlot ?? 0);
|
|
76
|
+
const freedU32 = UInt32.from(slot?.freedAtSlot ?? 0);
|
|
77
|
+
freedAt.push(packSlotTimes(boundU32, freedU32));
|
|
78
|
+
}
|
|
79
|
+
return { occupied, freedAt, occupiedCommitments };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Pure offline device-binding verifier. See module-level docstring.
|
|
83
|
+
*
|
|
84
|
+
* All errors are returned via `{ valid: false, reason }` rather than thrown
|
|
85
|
+
* — callers integrate this into a boot-time gate and don't want to catch
|
|
86
|
+
* around every call. `reason` is stable enough to key error UX off of.
|
|
87
|
+
*/
|
|
88
|
+
export function verifyOffline(input) {
|
|
89
|
+
const { licensesRoot, currentSlot, licenseHash, expirySlot, deviceCap, devices, witness, devicePubKey, } = input;
|
|
90
|
+
const { occupied, freedAt, occupiedCommitments } = normalizeSlots(devices);
|
|
91
|
+
const deviceSlotsRoot = computeDeviceSlotsRoot(occupied, freedAt);
|
|
92
|
+
const deviceSlotsFilled = occupiedCommitments.filter(c => c !== '0').length;
|
|
93
|
+
const leaf = new LicenseLeaf({
|
|
94
|
+
licenseHash: Field(licenseHash),
|
|
95
|
+
expirySlot: UInt32.from(expirySlot),
|
|
96
|
+
cap: UInt32.from(deviceCap),
|
|
97
|
+
deviceSlotsRoot,
|
|
98
|
+
deviceSlotsFilled: UInt32.from(deviceSlotsFilled),
|
|
99
|
+
});
|
|
100
|
+
const expectedLeafHash = leafHash(leaf);
|
|
101
|
+
const restoredWitness = deserializeWitness(witness);
|
|
102
|
+
const [computedRoot, computedKey] = restoredWitness.computeRootAndKey(expectedLeafHash);
|
|
103
|
+
if (computedKey.toString() !== Field(licenseHash).toString()) {
|
|
104
|
+
return { valid: false, reason: 'Witness key does not match licenseHash' };
|
|
105
|
+
}
|
|
106
|
+
if (computedRoot.toString() !== licensesRoot) {
|
|
107
|
+
return { valid: false, reason: 'Reconstructed leaf does not match synced licensesRoot' };
|
|
108
|
+
}
|
|
109
|
+
if (expirySlot <= currentSlot) {
|
|
110
|
+
return { valid: false, reason: 'License has expired' };
|
|
111
|
+
}
|
|
112
|
+
if (deviceCap === 0) {
|
|
113
|
+
if (devicePubKey !== undefined) {
|
|
114
|
+
// Fail loud rather than silently accept — a caller wiring devicePubKey
|
|
115
|
+
// into an app that turns out to have cap=0 is almost certainly a
|
|
116
|
+
// misconfiguration (they think the app enforces bindings when it
|
|
117
|
+
// doesn't).
|
|
118
|
+
return { valid: false, reason: 'deviceCap is 0 for this license; do not pass devicePubKey' };
|
|
119
|
+
}
|
|
120
|
+
return { valid: true, reason: null };
|
|
121
|
+
}
|
|
122
|
+
if (!devicePubKey) {
|
|
123
|
+
return { valid: false, reason: 'deviceCap > 0 requires devicePubKey' };
|
|
124
|
+
}
|
|
125
|
+
const commitment = computeDeviceCommitment(devicePubKey);
|
|
126
|
+
if (!occupiedCommitments.includes(commitment)) {
|
|
127
|
+
return { valid: false, reason: 'Device is not bound to this license' };
|
|
128
|
+
}
|
|
129
|
+
return { valid: true, reason: null };
|
|
130
|
+
}
|
|
131
|
+
// Re-export the shared Poseidon fold formula so callers that want to compute
|
|
132
|
+
// `deviceCommitment` for a pubkey they only have as (x, isOdd) can reuse
|
|
133
|
+
// the identical shape the circuit uses. Preferred entry point is still
|
|
134
|
+
// `computeDeviceCommitment(devicePubKey)` in ./deviceIdentity.ts — this is
|
|
135
|
+
// for callers who only hold raw fields.
|
|
136
|
+
export function deviceCommitmentFromFields(x, isOdd) {
|
|
137
|
+
return Poseidon.hash([x, isOdd]);
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=verifyOffline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyOffline.js","sourceRoot":"","sources":["../src/verifyOffline.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,oCAAoC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAa,MAAM,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAyB,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAiD9D,6EAA6E;AAC7E,yEAAyE;AACzE,4EAA4E;AAC5E,wEAAwE;AACxE,0EAA0E;AAC1E,gCAAgC;AAChC,SAAS,cAAc,CAAC,OAA6B;I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