@dstorage-tech/dstorage-sdk 0.0.4

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 (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +530 -0
  3. package/dist/KeypairEncryptionAdapter-AE75YC4W-AOWNSH2M.mjs +9 -0
  4. package/dist/KeypairEncryptionAdapter-AE75YC4W-BAVHRNNJ.mjs +1 -0
  5. package/dist/KeypairEncryptionAdapter-AE75YC4W-BEYO4RUO.mjs +1 -0
  6. package/dist/KeypairEncryptionAdapter-AE75YC4W-VAOH6AAL.mjs +9 -0
  7. package/dist/KeypairEncryptionAdapter-XUKCLRFU-6ERIZN2M.mjs +1 -0
  8. package/dist/KeypairEncryptionAdapter-XUKCLRFU-AYDAZ2TZ.mjs +9 -0
  9. package/dist/KeypairEncryptionAdapter-XUKCLRFU-ERPYK5S4.mjs +8 -0
  10. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-6DFVUVD6.mjs +1 -0
  11. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-O5AJPX42.mjs +1 -0
  12. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-SI6TBLTQ.mjs +9 -0
  13. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-WEPFOTSJ.mjs +9 -0
  14. package/dist/MnemonicEncryptionAdapter-RCHUETBP-DZPBGQG6.mjs +8 -0
  15. package/dist/MnemonicEncryptionAdapter-RCHUETBP-ELAMJMMO.mjs +1 -0
  16. package/dist/MnemonicEncryptionAdapter-RCHUETBP-M7NHGSHO.mjs +9 -0
  17. package/dist/PasswordEncryptionAdapter-CWOXUGR4-2YZ64B4A.mjs +1 -0
  18. package/dist/PasswordEncryptionAdapter-CWOXUGR4-DCEGC2NX.mjs +1 -0
  19. package/dist/PasswordEncryptionAdapter-CWOXUGR4-QEGGYPFJ.mjs +13 -0
  20. package/dist/PasswordEncryptionAdapter-CWOXUGR4-ZYUBUYUI.mjs +13 -0
  21. package/dist/PasswordEncryptionAdapter-ECHND672-3DEFO6FP.mjs +13 -0
  22. package/dist/PasswordEncryptionAdapter-ECHND672-MUTHAMZY.mjs +12 -0
  23. package/dist/PasswordEncryptionAdapter-ECHND672-XVBPHPPT.mjs +1 -0
  24. package/dist/browser.d.mts +2418 -0
  25. package/dist/browser.mjs +5175 -0
  26. package/dist/chunk-25I6ZXUC.mjs +9403 -0
  27. package/dist/chunk-4X5K43JF.mjs +62 -0
  28. package/dist/chunk-4YMF57VY.mjs +1 -0
  29. package/dist/chunk-5MZ7FPPY.mjs +1 -0
  30. package/dist/chunk-5P4EW2YL.mjs +1 -0
  31. package/dist/chunk-5QOKJEH3.mjs +8 -0
  32. package/dist/chunk-5RW7SGA7.mjs +1 -0
  33. package/dist/chunk-62RSKZ6T.mjs +118 -0
  34. package/dist/chunk-6IAQVMSM.mjs +102 -0
  35. package/dist/chunk-BBJCQFWP.mjs +275 -0
  36. package/dist/chunk-BWLEAAFW.mjs +2599 -0
  37. package/dist/chunk-EYF3263P.mjs +2049 -0
  38. package/dist/chunk-FJ7LSZOW.mjs +5537 -0
  39. package/dist/chunk-GUYENY5N.mjs +1 -0
  40. package/dist/chunk-HDD6SUU4.mjs +276 -0
  41. package/dist/chunk-JMPRZK5D.mjs +62 -0
  42. package/dist/chunk-L5QD6GHB.mjs +101 -0
  43. package/dist/chunk-O37NHERH.mjs +17 -0
  44. package/dist/chunk-OLGVVM5Y.mjs +102 -0
  45. package/dist/chunk-PKHRAYFD.mjs +1 -0
  46. package/dist/chunk-PLAOCKSS.mjs +101 -0
  47. package/dist/chunk-QKA2DCR6.mjs +118 -0
  48. package/dist/chunk-RPSRFFXN.mjs +275 -0
  49. package/dist/chunk-TESUOXRJ.mjs +1 -0
  50. package/dist/chunk-TMLXCRJU.mjs +1 -0
  51. package/dist/chunk-TNRKN4LB.mjs +1 -0
  52. package/dist/chunk-TSZ37JDY.mjs +2596 -0
  53. package/dist/chunk-U3MS6KMF.mjs +1 -0
  54. package/dist/chunk-UBALMYIY.mjs +2049 -0
  55. package/dist/chunk-UDYXMII2.mjs +121 -0
  56. package/dist/chunk-UJCSKKID.mjs +30 -0
  57. package/dist/chunk-UOOF4V2Y.mjs +1 -0
  58. package/dist/chunk-VDZ7F7MP.mjs +1329 -0
  59. package/dist/chunk-X4LEBNK6.mjs +276 -0
  60. package/dist/chunk-Z2TH6U4C.mjs +3 -0
  61. package/dist/chunk-Z6DUAI5B.mjs +121 -0
  62. package/dist/chunk-ZEPZ4QDD.mjs +1 -0
  63. package/dist/chunk-ZGUY5EIR.mjs +1 -0
  64. package/dist/cjs-RMZ3L2IO.mjs +5 -0
  65. package/dist/contract-api-AO4RGPLT-4HRCMSCE.mjs +279 -0
  66. package/dist/contract-api-AO4RGPLT-ADH6ZDKC.mjs +279 -0
  67. package/dist/contract-api-AO4RGPLT-ENC72WCG.mjs +280 -0
  68. package/dist/contract-api-AO4RGPLT-PAMIPEI3.mjs +1 -0
  69. package/dist/contract-api-AO4RGPLT-W3RSVP5A.mjs +1 -0
  70. package/dist/contract-api-AO4RGPLT-WENYDV6I.mjs +1 -0
  71. package/dist/contract-api-TJ7JPHZA-6FUBJ6DS.mjs +279 -0
  72. package/dist/contract-api-TJ7JPHZA-ZWP3EH7D.mjs +279 -0
  73. package/dist/contracts/dataregistry/managed/keys/removeReference.prover +0 -0
  74. package/dist/contracts/dataregistry/managed/keys/removeReference.verifier +0 -0
  75. package/dist/contracts/dataregistry/managed/keys/storeReference.prover +0 -0
  76. package/dist/contracts/dataregistry/managed/keys/storeReference.verifier +0 -0
  77. package/dist/contracts/dataregistry/managed/keys/updateReference.prover +0 -0
  78. package/dist/contracts/dataregistry/managed/keys/updateReference.verifier +0 -0
  79. package/dist/contracts/dataregistry/managed/zkir/removeReference.bzkir +0 -0
  80. package/dist/contracts/dataregistry/managed/zkir/removeReference.zkir +138 -0
  81. package/dist/contracts/dataregistry/managed/zkir/storeReference.bzkir +0 -0
  82. package/dist/contracts/dataregistry/managed/zkir/storeReference.zkir +158 -0
  83. package/dist/contracts/dataregistry/managed/zkir/updateReference.bzkir +0 -0
  84. package/dist/contracts/dataregistry/managed/zkir/updateReference.zkir +190 -0
  85. package/dist/dataregistry-simulator-E6RTGGWT-5YEGBW7P.mjs +108 -0
  86. package/dist/dataregistry-simulator-E6RTGGWT-DJS4MHBD.mjs +109 -0
  87. package/dist/dataregistry-simulator-E6RTGGWT-QGCYR3VF.mjs +1 -0
  88. package/dist/dist-655VYUPJ.mjs +1 -0
  89. package/dist/dist-INTAFXQ7.mjs +65 -0
  90. package/dist/dist-MEZZWKP4.mjs +1 -0
  91. package/dist/dist-MOLWJ4Y7.mjs +64 -0
  92. package/dist/dist-UD4WRMYJ.mjs +65 -0
  93. package/dist/errors.d.mts +117 -0
  94. package/dist/errors.d.ts +117 -0
  95. package/dist/errors.js +2308 -0
  96. package/dist/errors.mjs +2278 -0
  97. package/dist/esm5-AGBDHMNS.mjs +1 -0
  98. package/dist/esm5-GFOBLUFI.mjs +350 -0
  99. package/dist/in-memory-private-state-NGOP37V7-DXWZE42Q.mjs +48 -0
  100. package/dist/in-memory-private-state-NGOP37V7-QXT3RUEH.mjs +49 -0
  101. package/dist/in-memory-private-state-NGOP37V7-XFJFNFCQ.mjs +1 -0
  102. package/dist/index.d.mts +2843 -0
  103. package/dist/index.d.ts +2843 -0
  104. package/dist/index.js +19639 -0
  105. package/dist/index.mjs +5177 -0
  106. package/package.json +87 -0
@@ -0,0 +1,279 @@
1
+ import {
2
+ ChainErrorCode
3
+ } from "./chunk-JMPRZK5D.mjs";
4
+ import {
5
+ DStorageError
6
+ } from "./chunk-BWLEAAFW.mjs";
7
+ import {
8
+ CompiledDataRegistryContract,
9
+ createDataRegistryPrivateState,
10
+ ledger
11
+ } from "./chunk-VDZ7F7MP.mjs";
12
+ import "./chunk-5QOKJEH3.mjs";
13
+ import {
14
+ require_cjs
15
+ } from "./chunk-25I6ZXUC.mjs";
16
+ import {
17
+ __toESM
18
+ } from "./chunk-UJCSKKID.mjs";
19
+
20
+ // ../chain/dist/contract-api-TJ7JPHZA.mjs
21
+ var import_rxjs = __toESM(require_cjs(), 1);
22
+ import {
23
+ deployContract,
24
+ findDeployedContract,
25
+ withContractScopedTransaction
26
+ } from "@midnight-ntwrk/midnight-js-contracts";
27
+ import { toHex } from "@midnight-ntwrk/midnight-js-utils";
28
+ var dataRegistryPrivateStateKey = "DataRegistryPrivateState";
29
+ var SUPPORTED_CONTRACT_VERSION = 0n;
30
+ function validateContractVersion(version, contractAddress) {
31
+ if (version !== SUPPORTED_CONTRACT_VERSION) {
32
+ throw new DStorageError(
33
+ ChainErrorCode.CONTRACT_UNSUPPORTED_VERSION,
34
+ `[dStorage/midnight] Unsupported contract version ${version} at ${contractAddress}. This SDK supports version ${SUPPORTED_CONTRACT_VERSION} only. Deploy a compatible DataRegistry contract or upgrade the SDK.`
35
+ );
36
+ }
37
+ }
38
+ var DataRegistryAPI = class _DataRegistryAPI {
39
+ /** @internal */
40
+ constructor(deployedContract, providers, logger) {
41
+ this.deployedContract = deployedContract;
42
+ this.providers = providers;
43
+ this.logger = logger;
44
+ this.deployedContractAddress = deployedContract.deployTxData.public.contractAddress;
45
+ this.state$ = (0, import_rxjs.combineLatest)(
46
+ [
47
+ // Combine public (ledger) state with...
48
+ providers.publicDataProvider.contractStateObservable(this.deployedContractAddress, {
49
+ type: "latest"
50
+ }).pipe(
51
+ (0, import_rxjs.map)((contractState) => ledger(contractState.data)),
52
+ (0, import_rxjs.tap)(
53
+ (ledgerState) => logger?.debug?.(
54
+ "dStorage/midnight",
55
+ `ledger state changed: refCounter=${ledgerState.refCounter}`
56
+ )
57
+ )
58
+ ),
59
+ // ...private state...
60
+ // since the private state of the DataRegistry application never changes, we can query the
61
+ // private state once and always use the same value with `combineLatest`. In applications
62
+ // where the private state is expected to change, we would need to make this an `Observable`.
63
+ (0, import_rxjs.from)(
64
+ providers.privateStateProvider.get(
65
+ dataRegistryPrivateStateKey
66
+ )
67
+ )
68
+ ],
69
+ // ...and combine them to produce the required derived state.
70
+ // isOurs is set to false here — ownership is determined by the core SDK
71
+ // (dStorage.ts) by attempting to unwrap the DEK from the keyEnvelope using
72
+ // the available KEKs. This avoids coupling the chain layer to key material.
73
+ (ledgerState, _privateState) => {
74
+ const references = /* @__PURE__ */ new Map();
75
+ for (const [id, refEntry] of ledgerState.references) {
76
+ const refId = toHex(id);
77
+ references.set(refId, refEntry);
78
+ }
79
+ return {
80
+ references,
81
+ refCounter: ledgerState.refCounter,
82
+ contractVersion: ledgerState.contractVersion
83
+ };
84
+ }
85
+ ).pipe(
86
+ // Keep one live subscription to the indexer WebSocket for the lifetime of
87
+ // this API instance. Without shareReplay, each firstValueFrom(state$) call
88
+ // creates a new subscription — the indexer does not replay the last emitted
89
+ // state to new subscribers, so callers would receive stale data until the
90
+ // next on-chain change arrives. shareReplay(1) ensures:
91
+ // 1. The indexer connection is established once and kept alive.
92
+ // 2. Every new subscriber (e.g. listReferences, readReference) immediately
93
+ // receives the most recently emitted state.
94
+ // 3. Future indexer pushes (after upload/remove txs) still update the cache.
95
+ (0, import_rxjs.shareReplay)({ bufferSize: 1, refCount: false })
96
+ );
97
+ }
98
+ async storeReference(storageId, encryptionScheme, storageProvider, metadata, writtenAt, keyEnvelope, contentHash, ownerSecret) {
99
+ this.logger?.log(
100
+ "dStorage/midnight",
101
+ `storing reference: storageId=${storageId}`
102
+ );
103
+ await this.providers.privateStateProvider.set(dataRegistryPrivateStateKey, {
104
+ ownerSecret: new Uint8Array(ownerSecret)
105
+ });
106
+ try {
107
+ const txData = await withContractScopedTransaction(
108
+ this.providers,
109
+ async (txCtx) => {
110
+ await this.deployedContract.callTx.storeReference(
111
+ txCtx,
112
+ storageId,
113
+ encryptionScheme,
114
+ storageProvider,
115
+ metadata,
116
+ writtenAt,
117
+ keyEnvelope,
118
+ contentHash
119
+ );
120
+ },
121
+ { scopeName: "storeReference" }
122
+ );
123
+ const txHash = txData.public.txHash ?? txData.public.txId ?? "";
124
+ const blockHeight = Number(txData.public.blockHeight ?? 0);
125
+ const circuitResult = txData.private.result;
126
+ if (!(circuitResult instanceof Uint8Array)) {
127
+ throw new DStorageError(
128
+ ChainErrorCode.CONTRACT_CIRCUIT_RESULT_MISSING,
129
+ `[dStorage/midnight] storeReference succeeded on-chain (txHash=${txHash}) but the runtime did not return the circuit refId at txData.private.result (got ${typeof circuitResult}). This is likely a compact-runtime version mismatch. Upgrade @midnight-ntwrk/compact-runtime or report this as a bug.`
130
+ );
131
+ }
132
+ this.logger?.debug?.(
133
+ "dStorage/midnight",
134
+ `transaction: circuit=storeReference txHash=${txHash} blockHeight=${blockHeight}`
135
+ );
136
+ return { refId: circuitResult, txHash, blockHeight };
137
+ } finally {
138
+ await this.providers.privateStateProvider.set(
139
+ dataRegistryPrivateStateKey,
140
+ {}
141
+ );
142
+ }
143
+ }
144
+ async removeReference(refId, ownerSecret) {
145
+ this.logger?.log(
146
+ "dStorage/midnight",
147
+ `removing reference: ${toHex(refId)}`
148
+ );
149
+ await this.providers.privateStateProvider.set(dataRegistryPrivateStateKey, {
150
+ ownerSecret: new Uint8Array(ownerSecret)
151
+ });
152
+ try {
153
+ const txData = await withContractScopedTransaction(
154
+ this.providers,
155
+ async (txCtx) => {
156
+ await this.deployedContract.callTx.removeReference(txCtx, refId);
157
+ },
158
+ { scopeName: "removeReference" }
159
+ );
160
+ const txHash = txData.public.txHash ?? txData.public.txId ?? "";
161
+ const blockHeight = Number(txData.public.blockHeight ?? 0);
162
+ this.logger?.debug?.(
163
+ "dStorage/midnight",
164
+ `transaction: circuit=removeReference txHash=${txHash} blockHeight=${blockHeight}`
165
+ );
166
+ return { txHash, blockHeight };
167
+ } finally {
168
+ await this.providers.privateStateProvider.set(
169
+ dataRegistryPrivateStateKey,
170
+ {}
171
+ );
172
+ }
173
+ }
174
+ async updateReference(refId, storageId, encryptionScheme, storageProvider, metadata, writtenAt, keyEnvelope, contentHash, ownerSecret, newOwnerSecret) {
175
+ this.logger?.log(
176
+ "dStorage/midnight",
177
+ `updating reference: ${toHex(refId)}`
178
+ );
179
+ await this.providers.privateStateProvider.set(dataRegistryPrivateStateKey, {
180
+ ownerSecret: new Uint8Array(ownerSecret),
181
+ // When no new secret is provided, pass the old one so the circuit recomputes the same
182
+ // commitment and the stored value is preserved unchanged.
183
+ newOwnerSecret: new Uint8Array(newOwnerSecret ?? ownerSecret)
184
+ });
185
+ try {
186
+ const txData = await withContractScopedTransaction(
187
+ this.providers,
188
+ async (txCtx) => {
189
+ await this.deployedContract.callTx.updateReference(
190
+ txCtx,
191
+ refId,
192
+ storageId,
193
+ encryptionScheme,
194
+ storageProvider,
195
+ metadata,
196
+ writtenAt,
197
+ keyEnvelope,
198
+ contentHash
199
+ );
200
+ },
201
+ { scopeName: "updateReference" }
202
+ );
203
+ const txHash = txData.public.txHash ?? txData.public.txId ?? "";
204
+ const blockHeight = Number(txData.public.blockHeight ?? 0);
205
+ this.logger?.debug?.(
206
+ "dStorage/midnight",
207
+ `transaction: circuit=updateReference txHash=${txHash} blockHeight=${blockHeight}`
208
+ );
209
+ return { txHash, blockHeight };
210
+ } finally {
211
+ await this.providers.privateStateProvider.set(
212
+ dataRegistryPrivateStateKey,
213
+ {}
214
+ );
215
+ }
216
+ }
217
+ /**
218
+ * Deploys a new DataRegistry contract to the network.
219
+ *
220
+ * @param providers The DataRegistry providers.
221
+ * @param logger An optional 'pino' logger to use for logging.
222
+ * @returns A `Promise` that resolves with a {@link DataRegistryAPI} instance that manages the newly deployed
223
+ * {@link DeployedDataRegistryContract}; or rejects with a deployment error.
224
+ */
225
+ static async deploy(providers, logger) {
226
+ logger?.log("dStorage/midnight", "deploying DataRegistry contract...");
227
+ const deployedDataRegistryContract = await deployContract(providers, {
228
+ compiledContract: CompiledDataRegistryContract,
229
+ privateStateId: dataRegistryPrivateStateKey,
230
+ initialPrivateState: createDataRegistryPrivateState()
231
+ });
232
+ return new _DataRegistryAPI(deployedDataRegistryContract, providers, logger);
233
+ }
234
+ /**
235
+ * Finds an already deployed DataRegistry contract on the network, and joins it.
236
+ *
237
+ * @param providers The DataRegistry providers.
238
+ * @param contractAddress The contract address of the deployed DataRegistry contract to search for and join.
239
+ * @param logger An optional 'pino' logger to use for logging.
240
+ * @returns A `Promise` that resolves with a {@link DataRegistryAPI} instance that manages the joined
241
+ * {@link DeployedDataRegistryContract}; or rejects with an error.
242
+ */
243
+ static async join(providers, contractAddress, logger) {
244
+ logger?.log(
245
+ "dStorage/midnight",
246
+ `joining DataRegistry contract at: ${contractAddress}`
247
+ );
248
+ providers.privateStateProvider.setContractAddress(contractAddress);
249
+ const deployedDataRegistryContract = await findDeployedContract(providers, {
250
+ contractAddress,
251
+ compiledContract: CompiledDataRegistryContract,
252
+ privateStateId: dataRegistryPrivateStateKey,
253
+ initialPrivateState: await _DataRegistryAPI.getPrivateState(providers)
254
+ });
255
+ const contractVersion = await (0, import_rxjs.firstValueFrom)(
256
+ providers.publicDataProvider.contractStateObservable(contractAddress, { type: "latest" }).pipe((0, import_rxjs.map)((s) => ledger(s.data).contractVersion))
257
+ );
258
+ validateContractVersion(contractVersion, contractAddress);
259
+ return new _DataRegistryAPI(deployedDataRegistryContract, providers, logger);
260
+ }
261
+ static async getPrivateState(providers) {
262
+ const existingPrivateState = await providers.privateStateProvider.get(
263
+ dataRegistryPrivateStateKey
264
+ );
265
+ return existingPrivateState ?? createDataRegistryPrivateState();
266
+ }
267
+ };
268
+ var randomBytes = (length) => {
269
+ const bytes = new Uint8Array(length);
270
+ crypto.getRandomValues(bytes);
271
+ return bytes;
272
+ };
273
+ export {
274
+ DataRegistryAPI,
275
+ SUPPORTED_CONTRACT_VERSION,
276
+ dataRegistryPrivateStateKey,
277
+ randomBytes,
278
+ validateContractVersion
279
+ };
@@ -0,0 +1,138 @@
1
+ {
2
+ "version": { "major": 2, "minor": 0 },
3
+ "do_communications_commitment": true,
4
+ "num_inputs": 2,
5
+ "instructions": [
6
+ { "op": "constrain_bits", "var": 0, "bits": 8 },
7
+ { "op": "constrain_bits", "var": 1, "bits": 248 },
8
+ { "op": "load_imm", "imm": "01" },
9
+ { "op": "load_imm", "imm": "30" },
10
+ { "op": "declare_pub_input", "var": 3 },
11
+ { "op": "pi_skip", "guard": 2, "count": 1 },
12
+ { "op": "load_imm", "imm": "50" },
13
+ { "op": "load_imm", "imm": "00" },
14
+ { "op": "declare_pub_input", "var": 4 },
15
+ { "op": "declare_pub_input", "var": 2 },
16
+ { "op": "declare_pub_input", "var": 2 },
17
+ { "op": "declare_pub_input", "var": 5 },
18
+ { "op": "pi_skip", "guard": 2, "count": 4 },
19
+ { "op": "load_imm", "imm": "10" },
20
+ { "op": "load_imm", "imm": "20" },
21
+ { "op": "declare_pub_input", "var": 6 },
22
+ { "op": "declare_pub_input", "var": 2 },
23
+ { "op": "declare_pub_input", "var": 2 },
24
+ { "op": "declare_pub_input", "var": 7 },
25
+ { "op": "declare_pub_input", "var": 0 },
26
+ { "op": "declare_pub_input", "var": 1 },
27
+ { "op": "pi_skip", "guard": 2, "count": 6 },
28
+ { "op": "load_imm", "imm": "18" },
29
+ { "op": "declare_pub_input", "var": 8 },
30
+ { "op": "pi_skip", "guard": 2, "count": 1 },
31
+ { "op": "public_input", "guard": null },
32
+ { "op": "load_imm", "imm": "0D" },
33
+ { "op": "declare_pub_input", "var": 10 },
34
+ { "op": "declare_pub_input", "var": 2 },
35
+ { "op": "declare_pub_input", "var": 2 },
36
+ { "op": "declare_pub_input", "var": 9 },
37
+ { "op": "pi_skip", "guard": 2, "count": 4 },
38
+ { "op": "assert", "cond": 9 },
39
+ { "op": "declare_pub_input", "var": 3 },
40
+ { "op": "pi_skip", "guard": 2, "count": 1 },
41
+ { "op": "declare_pub_input", "var": 4 },
42
+ { "op": "declare_pub_input", "var": 2 },
43
+ { "op": "declare_pub_input", "var": 2 },
44
+ { "op": "declare_pub_input", "var": 5 },
45
+ { "op": "pi_skip", "guard": 2, "count": 4 },
46
+ { "op": "declare_pub_input", "var": 4 },
47
+ { "op": "declare_pub_input", "var": 2 },
48
+ { "op": "declare_pub_input", "var": 7 },
49
+ { "op": "declare_pub_input", "var": 0 },
50
+ { "op": "declare_pub_input", "var": 1 },
51
+ { "op": "pi_skip", "guard": 2, "count": 5 },
52
+ { "op": "public_input", "guard": null },
53
+ { "op": "public_input", "guard": null },
54
+ { "op": "public_input", "guard": null },
55
+ { "op": "public_input", "guard": null },
56
+ { "op": "public_input", "guard": null },
57
+ { "op": "public_input", "guard": null },
58
+ { "op": "public_input", "guard": null },
59
+ { "op": "public_input", "guard": null },
60
+ { "op": "public_input", "guard": null },
61
+ { "op": "public_input", "guard": null },
62
+ { "op": "load_imm", "imm": "-01" },
63
+ { "op": "load_imm", "imm": "08" },
64
+ { "op": "load_imm", "imm": "0C" },
65
+ { "op": "declare_pub_input", "var": 23 },
66
+ { "op": "declare_pub_input", "var": 22 },
67
+ { "op": "declare_pub_input", "var": 21 },
68
+ { "op": "declare_pub_input", "var": 21 },
69
+ { "op": "declare_pub_input", "var": 21 },
70
+ { "op": "declare_pub_input", "var": 21 },
71
+ { "op": "declare_pub_input", "var": 22 },
72
+ { "op": "declare_pub_input", "var": 21 },
73
+ { "op": "declare_pub_input", "var": 7 },
74
+ { "op": "declare_pub_input", "var": 7 },
75
+ { "op": "declare_pub_input", "var": 11 },
76
+ { "op": "declare_pub_input", "var": 12 },
77
+ { "op": "declare_pub_input", "var": 13 },
78
+ { "op": "declare_pub_input", "var": 14 },
79
+ { "op": "declare_pub_input", "var": 15 },
80
+ { "op": "declare_pub_input", "var": 16 },
81
+ { "op": "declare_pub_input", "var": 17 },
82
+ { "op": "declare_pub_input", "var": 18 },
83
+ { "op": "declare_pub_input", "var": 19 },
84
+ { "op": "declare_pub_input", "var": 20 },
85
+ { "op": "pi_skip", "guard": 2, "count": 20 },
86
+ { "op": "private_input", "guard": null },
87
+ { "op": "constrain_bits", "var": 24, "bits": 8 },
88
+ { "op": "private_input", "guard": null },
89
+ { "op": "constrain_bits", "var": 25, "bits": 248 },
90
+ { "op": "test_eq", "a": 24, "b": 5 },
91
+ { "op": "test_eq", "a": 25, "b": 5 },
92
+ { "op": "cond_select", "bit": 26, "a": 27, "b": 5 },
93
+ { "op": "cond_select", "bit": 28, "a": 5, "b": 2 },
94
+ { "op": "assert", "cond": 29 },
95
+ { "op": "load_imm", "imm": "32" },
96
+ { "op": "declare_pub_input", "var": 30 },
97
+ { "op": "pi_skip", "guard": 2, "count": 1 },
98
+ { "op": "load_imm", "imm": "60" },
99
+ { "op": "declare_pub_input", "var": 31 },
100
+ { "op": "declare_pub_input", "var": 2 },
101
+ { "op": "declare_pub_input", "var": 2 },
102
+ { "op": "declare_pub_input", "var": 5 },
103
+ { "op": "pi_skip", "guard": 2, "count": 4 },
104
+ { "op": "public_input", "guard": null },
105
+ { "op": "public_input", "guard": null },
106
+ { "op": "declare_pub_input", "var": 10 },
107
+ { "op": "declare_pub_input", "var": 2 },
108
+ { "op": "declare_pub_input", "var": 7 },
109
+ { "op": "declare_pub_input", "var": 32 },
110
+ { "op": "declare_pub_input", "var": 33 },
111
+ { "op": "pi_skip", "guard": 2, "count": 5 },
112
+ { "op": "load_imm", "imm": "6473746F726167653A6F776E65723A" },
113
+ { "op": "persistent_hash", "alignment": [{ "tag": "atom", "value": { "length": 32, "tag": "bytes" } }, { "tag": "atom", "value": { "length": 32, "tag": "bytes" } }, { "tag": "atom", "value": { "length": 32, "tag": "bytes" } }, { "tag": "atom", "value": { "length": 32, "tag": "bytes" } }], "inputs": [5, 34, 24, 25, 0, 1, 32, 33] },
114
+ { "op": "test_eq", "a": 17, "b": 35 },
115
+ { "op": "test_eq", "a": 18, "b": 36 },
116
+ { "op": "cond_select", "bit": 37, "a": 38, "b": 5 },
117
+ { "op": "assert", "cond": 39 },
118
+ { "op": "load_imm", "imm": "70" },
119
+ { "op": "declare_pub_input", "var": 40 },
120
+ { "op": "declare_pub_input", "var": 2 },
121
+ { "op": "declare_pub_input", "var": 2 },
122
+ { "op": "declare_pub_input", "var": 5 },
123
+ { "op": "pi_skip", "guard": 2, "count": 4 },
124
+ { "op": "declare_pub_input", "var": 6 },
125
+ { "op": "declare_pub_input", "var": 2 },
126
+ { "op": "declare_pub_input", "var": 2 },
127
+ { "op": "declare_pub_input", "var": 7 },
128
+ { "op": "declare_pub_input", "var": 0 },
129
+ { "op": "declare_pub_input", "var": 1 },
130
+ { "op": "pi_skip", "guard": 2, "count": 6 },
131
+ { "op": "load_imm", "imm": "19" },
132
+ { "op": "declare_pub_input", "var": 41 },
133
+ { "op": "pi_skip", "guard": 2, "count": 1 },
134
+ { "op": "load_imm", "imm": "A1" },
135
+ { "op": "declare_pub_input", "var": 42 },
136
+ { "op": "pi_skip", "guard": 2, "count": 1 }
137
+ ]
138
+ }
@@ -0,0 +1,158 @@
1
+ {
2
+ "version": { "major": 2, "minor": 0 },
3
+ "do_communications_commitment": true,
4
+ "num_inputs": 8,
5
+ "instructions": [
6
+ { "op": "constrain_bits", "var": 4, "bits": 64 },
7
+ { "op": "constrain_bits", "var": 6, "bits": 8 },
8
+ { "op": "constrain_bits", "var": 7, "bits": 248 },
9
+ { "op": "load_imm", "imm": "01" },
10
+ { "op": "load_imm", "imm": "30" },
11
+ { "op": "declare_pub_input", "var": 9 },
12
+ { "op": "pi_skip", "guard": 8, "count": 1 },
13
+ { "op": "load_imm", "imm": "50" },
14
+ { "op": "declare_pub_input", "var": 10 },
15
+ { "op": "declare_pub_input", "var": 8 },
16
+ { "op": "declare_pub_input", "var": 8 },
17
+ { "op": "declare_pub_input", "var": 8 },
18
+ { "op": "pi_skip", "guard": 8, "count": 4 },
19
+ { "op": "public_input", "guard": null },
20
+ { "op": "load_imm", "imm": "08" },
21
+ { "op": "load_imm", "imm": "0D" },
22
+ { "op": "declare_pub_input", "var": 13 },
23
+ { "op": "declare_pub_input", "var": 8 },
24
+ { "op": "declare_pub_input", "var": 12 },
25
+ { "op": "declare_pub_input", "var": 11 },
26
+ { "op": "pi_skip", "guard": 8, "count": 4 },
27
+ { "op": "div_mod_power_of_two", "var": 11, "bits": 248 },
28
+ { "op": "load_imm", "imm": "32" },
29
+ { "op": "declare_pub_input", "var": 16 },
30
+ { "op": "pi_skip", "guard": 8, "count": 1 },
31
+ { "op": "load_imm", "imm": "60" },
32
+ { "op": "load_imm", "imm": "00" },
33
+ { "op": "declare_pub_input", "var": 17 },
34
+ { "op": "declare_pub_input", "var": 8 },
35
+ { "op": "declare_pub_input", "var": 8 },
36
+ { "op": "declare_pub_input", "var": 18 },
37
+ { "op": "pi_skip", "guard": 8, "count": 4 },
38
+ { "op": "public_input", "guard": null },
39
+ { "op": "public_input", "guard": null },
40
+ { "op": "load_imm", "imm": "20" },
41
+ { "op": "declare_pub_input", "var": 13 },
42
+ { "op": "declare_pub_input", "var": 8 },
43
+ { "op": "declare_pub_input", "var": 21 },
44
+ { "op": "declare_pub_input", "var": 19 },
45
+ { "op": "declare_pub_input", "var": 20 },
46
+ { "op": "pi_skip", "guard": 8, "count": 5 },
47
+ { "op": "load_imm", "imm": "6473746F726167653A7265663A" },
48
+ { "op": "persistent_hash", "alignment": [{ "tag": "atom", "value": { "length": 32, "tag": "bytes" } }, { "tag": "atom", "value": { "length": 32, "tag": "bytes" } }, { "tag": "atom", "value": { "length": 32, "tag": "bytes" } }], "inputs": [18, 22, 14, 15, 19, 20] },
49
+ { "op": "declare_pub_input", "var": 9 },
50
+ { "op": "pi_skip", "guard": 8, "count": 1 },
51
+ { "op": "declare_pub_input", "var": 10 },
52
+ { "op": "declare_pub_input", "var": 8 },
53
+ { "op": "declare_pub_input", "var": 8 },
54
+ { "op": "declare_pub_input", "var": 18 },
55
+ { "op": "pi_skip", "guard": 8, "count": 4 },
56
+ { "op": "load_imm", "imm": "10" },
57
+ { "op": "declare_pub_input", "var": 25 },
58
+ { "op": "declare_pub_input", "var": 8 },
59
+ { "op": "declare_pub_input", "var": 8 },
60
+ { "op": "declare_pub_input", "var": 21 },
61
+ { "op": "declare_pub_input", "var": 23 },
62
+ { "op": "declare_pub_input", "var": 24 },
63
+ { "op": "pi_skip", "guard": 8, "count": 6 },
64
+ { "op": "load_imm", "imm": "18" },
65
+ { "op": "declare_pub_input", "var": 26 },
66
+ { "op": "pi_skip", "guard": 8, "count": 1 },
67
+ { "op": "public_input", "guard": null },
68
+ { "op": "declare_pub_input", "var": 13 },
69
+ { "op": "declare_pub_input", "var": 8 },
70
+ { "op": "declare_pub_input", "var": 8 },
71
+ { "op": "declare_pub_input", "var": 27 },
72
+ { "op": "pi_skip", "guard": 8, "count": 4 },
73
+ { "op": "cond_select", "bit": 27, "a": 18, "b": 8 },
74
+ { "op": "assert", "cond": 28 },
75
+ { "op": "private_input", "guard": null },
76
+ { "op": "constrain_bits", "var": 29, "bits": 8 },
77
+ { "op": "private_input", "guard": null },
78
+ { "op": "constrain_bits", "var": 30, "bits": 248 },
79
+ { "op": "test_eq", "a": 29, "b": 18 },
80
+ { "op": "test_eq", "a": 30, "b": 18 },
81
+ { "op": "cond_select", "bit": 31, "a": 32, "b": 18 },
82
+ { "op": "cond_select", "bit": 33, "a": 18, "b": 8 },
83
+ { "op": "assert", "cond": 34 },
84
+ { "op": "declare_pub_input", "var": 16 },
85
+ { "op": "pi_skip", "guard": 8, "count": 1 },
86
+ { "op": "declare_pub_input", "var": 17 },
87
+ { "op": "declare_pub_input", "var": 8 },
88
+ { "op": "declare_pub_input", "var": 8 },
89
+ { "op": "declare_pub_input", "var": 18 },
90
+ { "op": "pi_skip", "guard": 8, "count": 4 },
91
+ { "op": "public_input", "guard": null },
92
+ { "op": "public_input", "guard": null },
93
+ { "op": "declare_pub_input", "var": 13 },
94
+ { "op": "declare_pub_input", "var": 8 },
95
+ { "op": "declare_pub_input", "var": 21 },
96
+ { "op": "declare_pub_input", "var": 35 },
97
+ { "op": "declare_pub_input", "var": 36 },
98
+ { "op": "pi_skip", "guard": 8, "count": 5 },
99
+ { "op": "load_imm", "imm": "6473746F726167653A6F776E65723A" },
100
+ { "op": "persistent_hash", "alignment": [{ "tag": "atom", "value": { "length": 32, "tag": "bytes" } }, { "tag": "atom", "value": { "length": 32, "tag": "bytes" } }, { "tag": "atom", "value": { "length": 32, "tag": "bytes" } }, { "tag": "atom", "value": { "length": 32, "tag": "bytes" } }], "inputs": [18, 37, 29, 30, 23, 24, 35, 36] },
101
+ { "op": "load_imm", "imm": "70" },
102
+ { "op": "declare_pub_input", "var": 40 },
103
+ { "op": "declare_pub_input", "var": 8 },
104
+ { "op": "declare_pub_input", "var": 8 },
105
+ { "op": "declare_pub_input", "var": 18 },
106
+ { "op": "pi_skip", "guard": 8, "count": 4 },
107
+ { "op": "declare_pub_input", "var": 25 },
108
+ { "op": "declare_pub_input", "var": 8 },
109
+ { "op": "declare_pub_input", "var": 8 },
110
+ { "op": "declare_pub_input", "var": 21 },
111
+ { "op": "declare_pub_input", "var": 23 },
112
+ { "op": "declare_pub_input", "var": 24 },
113
+ { "op": "pi_skip", "guard": 8, "count": 6 },
114
+ { "op": "load_imm", "imm": "11" },
115
+ { "op": "load_imm", "imm": "-01" },
116
+ { "op": "declare_pub_input", "var": 41 },
117
+ { "op": "declare_pub_input", "var": 8 },
118
+ { "op": "declare_pub_input", "var": 12 },
119
+ { "op": "declare_pub_input", "var": 42 },
120
+ { "op": "declare_pub_input", "var": 42 },
121
+ { "op": "declare_pub_input", "var": 42 },
122
+ { "op": "declare_pub_input", "var": 42 },
123
+ { "op": "declare_pub_input", "var": 12 },
124
+ { "op": "declare_pub_input", "var": 42 },
125
+ { "op": "declare_pub_input", "var": 21 },
126
+ { "op": "declare_pub_input", "var": 21 },
127
+ { "op": "declare_pub_input", "var": 0 },
128
+ { "op": "declare_pub_input", "var": 1 },
129
+ { "op": "declare_pub_input", "var": 2 },
130
+ { "op": "declare_pub_input", "var": 3 },
131
+ { "op": "declare_pub_input", "var": 4 },
132
+ { "op": "declare_pub_input", "var": 5 },
133
+ { "op": "declare_pub_input", "var": 38 },
134
+ { "op": "declare_pub_input", "var": 39 },
135
+ { "op": "declare_pub_input", "var": 6 },
136
+ { "op": "declare_pub_input", "var": 7 },
137
+ { "op": "pi_skip", "guard": 8, "count": 21 },
138
+ { "op": "load_imm", "imm": "91" },
139
+ { "op": "declare_pub_input", "var": 43 },
140
+ { "op": "pi_skip", "guard": 8, "count": 1 },
141
+ { "op": "load_imm", "imm": "A1" },
142
+ { "op": "declare_pub_input", "var": 44 },
143
+ { "op": "pi_skip", "guard": 8, "count": 1 },
144
+ { "op": "declare_pub_input", "var": 40 },
145
+ { "op": "declare_pub_input", "var": 8 },
146
+ { "op": "declare_pub_input", "var": 8 },
147
+ { "op": "declare_pub_input", "var": 8 },
148
+ { "op": "pi_skip", "guard": 8, "count": 4 },
149
+ { "op": "load_imm", "imm": "0E" },
150
+ { "op": "declare_pub_input", "var": 45 },
151
+ { "op": "declare_pub_input", "var": 8 },
152
+ { "op": "pi_skip", "guard": 8, "count": 2 },
153
+ { "op": "declare_pub_input", "var": 44 },
154
+ { "op": "pi_skip", "guard": 8, "count": 1 },
155
+ { "op": "output", "var": 23 },
156
+ { "op": "output", "var": 24 }
157
+ ]
158
+ }