@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,190 @@
1
+ {
2
+ "version": { "major": 2, "minor": 0 },
3
+ "do_communications_commitment": true,
4
+ "num_inputs": 10,
5
+ "instructions": [
6
+ { "op": "constrain_bits", "var": 0, "bits": 8 },
7
+ { "op": "constrain_bits", "var": 1, "bits": 248 },
8
+ { "op": "constrain_bits", "var": 6, "bits": 64 },
9
+ { "op": "constrain_bits", "var": 8, "bits": 8 },
10
+ { "op": "constrain_bits", "var": 9, "bits": 248 },
11
+ { "op": "load_imm", "imm": "01" },
12
+ { "op": "load_imm", "imm": "30" },
13
+ { "op": "declare_pub_input", "var": 11 },
14
+ { "op": "pi_skip", "guard": 10, "count": 1 },
15
+ { "op": "load_imm", "imm": "50" },
16
+ { "op": "load_imm", "imm": "00" },
17
+ { "op": "declare_pub_input", "var": 12 },
18
+ { "op": "declare_pub_input", "var": 10 },
19
+ { "op": "declare_pub_input", "var": 10 },
20
+ { "op": "declare_pub_input", "var": 13 },
21
+ { "op": "pi_skip", "guard": 10, "count": 4 },
22
+ { "op": "load_imm", "imm": "10" },
23
+ { "op": "load_imm", "imm": "20" },
24
+ { "op": "declare_pub_input", "var": 14 },
25
+ { "op": "declare_pub_input", "var": 10 },
26
+ { "op": "declare_pub_input", "var": 10 },
27
+ { "op": "declare_pub_input", "var": 15 },
28
+ { "op": "declare_pub_input", "var": 0 },
29
+ { "op": "declare_pub_input", "var": 1 },
30
+ { "op": "pi_skip", "guard": 10, "count": 6 },
31
+ { "op": "load_imm", "imm": "18" },
32
+ { "op": "declare_pub_input", "var": 16 },
33
+ { "op": "pi_skip", "guard": 10, "count": 1 },
34
+ { "op": "public_input", "guard": null },
35
+ { "op": "load_imm", "imm": "0D" },
36
+ { "op": "declare_pub_input", "var": 18 },
37
+ { "op": "declare_pub_input", "var": 10 },
38
+ { "op": "declare_pub_input", "var": 10 },
39
+ { "op": "declare_pub_input", "var": 17 },
40
+ { "op": "pi_skip", "guard": 10, "count": 4 },
41
+ { "op": "assert", "cond": 17 },
42
+ { "op": "declare_pub_input", "var": 11 },
43
+ { "op": "pi_skip", "guard": 10, "count": 1 },
44
+ { "op": "declare_pub_input", "var": 12 },
45
+ { "op": "declare_pub_input", "var": 10 },
46
+ { "op": "declare_pub_input", "var": 10 },
47
+ { "op": "declare_pub_input", "var": 13 },
48
+ { "op": "pi_skip", "guard": 10, "count": 4 },
49
+ { "op": "declare_pub_input", "var": 12 },
50
+ { "op": "declare_pub_input", "var": 10 },
51
+ { "op": "declare_pub_input", "var": 15 },
52
+ { "op": "declare_pub_input", "var": 0 },
53
+ { "op": "declare_pub_input", "var": 1 },
54
+ { "op": "pi_skip", "guard": 10, "count": 5 },
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": "public_input", "guard": null },
63
+ { "op": "public_input", "guard": null },
64
+ { "op": "public_input", "guard": null },
65
+ { "op": "load_imm", "imm": "-01" },
66
+ { "op": "load_imm", "imm": "08" },
67
+ { "op": "load_imm", "imm": "0C" },
68
+ { "op": "declare_pub_input", "var": 31 },
69
+ { "op": "declare_pub_input", "var": 30 },
70
+ { "op": "declare_pub_input", "var": 29 },
71
+ { "op": "declare_pub_input", "var": 29 },
72
+ { "op": "declare_pub_input", "var": 29 },
73
+ { "op": "declare_pub_input", "var": 29 },
74
+ { "op": "declare_pub_input", "var": 30 },
75
+ { "op": "declare_pub_input", "var": 29 },
76
+ { "op": "declare_pub_input", "var": 15 },
77
+ { "op": "declare_pub_input", "var": 15 },
78
+ { "op": "declare_pub_input", "var": 19 },
79
+ { "op": "declare_pub_input", "var": 20 },
80
+ { "op": "declare_pub_input", "var": 21 },
81
+ { "op": "declare_pub_input", "var": 22 },
82
+ { "op": "declare_pub_input", "var": 23 },
83
+ { "op": "declare_pub_input", "var": 24 },
84
+ { "op": "declare_pub_input", "var": 25 },
85
+ { "op": "declare_pub_input", "var": 26 },
86
+ { "op": "declare_pub_input", "var": 27 },
87
+ { "op": "declare_pub_input", "var": 28 },
88
+ { "op": "pi_skip", "guard": 10, "count": 20 },
89
+ { "op": "private_input", "guard": null },
90
+ { "op": "constrain_bits", "var": 32, "bits": 8 },
91
+ { "op": "private_input", "guard": null },
92
+ { "op": "constrain_bits", "var": 33, "bits": 248 },
93
+ { "op": "test_eq", "a": 32, "b": 13 },
94
+ { "op": "test_eq", "a": 33, "b": 13 },
95
+ { "op": "cond_select", "bit": 34, "a": 35, "b": 13 },
96
+ { "op": "cond_select", "bit": 36, "a": 13, "b": 10 },
97
+ { "op": "assert", "cond": 37 },
98
+ { "op": "load_imm", "imm": "32" },
99
+ { "op": "declare_pub_input", "var": 38 },
100
+ { "op": "pi_skip", "guard": 10, "count": 1 },
101
+ { "op": "load_imm", "imm": "60" },
102
+ { "op": "declare_pub_input", "var": 39 },
103
+ { "op": "declare_pub_input", "var": 10 },
104
+ { "op": "declare_pub_input", "var": 10 },
105
+ { "op": "declare_pub_input", "var": 13 },
106
+ { "op": "pi_skip", "guard": 10, "count": 4 },
107
+ { "op": "public_input", "guard": null },
108
+ { "op": "public_input", "guard": null },
109
+ { "op": "declare_pub_input", "var": 18 },
110
+ { "op": "declare_pub_input", "var": 10 },
111
+ { "op": "declare_pub_input", "var": 15 },
112
+ { "op": "declare_pub_input", "var": 40 },
113
+ { "op": "declare_pub_input", "var": 41 },
114
+ { "op": "pi_skip", "guard": 10, "count": 5 },
115
+ { "op": "load_imm", "imm": "6473746F726167653A6F776E65723A" },
116
+ { "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": [13, 42, 32, 33, 0, 1, 40, 41] },
117
+ { "op": "test_eq", "a": 25, "b": 43 },
118
+ { "op": "test_eq", "a": 26, "b": 44 },
119
+ { "op": "cond_select", "bit": 45, "a": 46, "b": 13 },
120
+ { "op": "assert", "cond": 47 },
121
+ { "op": "private_input", "guard": null },
122
+ { "op": "constrain_bits", "var": 48, "bits": 8 },
123
+ { "op": "private_input", "guard": null },
124
+ { "op": "constrain_bits", "var": 49, "bits": 248 },
125
+ { "op": "test_eq", "a": 48, "b": 13 },
126
+ { "op": "test_eq", "a": 49, "b": 13 },
127
+ { "op": "cond_select", "bit": 50, "a": 51, "b": 13 },
128
+ { "op": "cond_select", "bit": 52, "a": 13, "b": 10 },
129
+ { "op": "assert", "cond": 53 },
130
+ { "op": "declare_pub_input", "var": 38 },
131
+ { "op": "pi_skip", "guard": 10, "count": 1 },
132
+ { "op": "declare_pub_input", "var": 39 },
133
+ { "op": "declare_pub_input", "var": 10 },
134
+ { "op": "declare_pub_input", "var": 10 },
135
+ { "op": "declare_pub_input", "var": 13 },
136
+ { "op": "pi_skip", "guard": 10, "count": 4 },
137
+ { "op": "public_input", "guard": null },
138
+ { "op": "public_input", "guard": null },
139
+ { "op": "declare_pub_input", "var": 18 },
140
+ { "op": "declare_pub_input", "var": 10 },
141
+ { "op": "declare_pub_input", "var": 15 },
142
+ { "op": "declare_pub_input", "var": 54 },
143
+ { "op": "declare_pub_input", "var": 55 },
144
+ { "op": "pi_skip", "guard": 10, "count": 5 },
145
+ { "op": "load_imm", "imm": "6473746F726167653A6F776E65723A" },
146
+ { "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": [13, 56, 48, 49, 0, 1, 54, 55] },
147
+ { "op": "load_imm", "imm": "70" },
148
+ { "op": "declare_pub_input", "var": 59 },
149
+ { "op": "declare_pub_input", "var": 10 },
150
+ { "op": "declare_pub_input", "var": 10 },
151
+ { "op": "declare_pub_input", "var": 13 },
152
+ { "op": "pi_skip", "guard": 10, "count": 4 },
153
+ { "op": "declare_pub_input", "var": 14 },
154
+ { "op": "declare_pub_input", "var": 10 },
155
+ { "op": "declare_pub_input", "var": 10 },
156
+ { "op": "declare_pub_input", "var": 15 },
157
+ { "op": "declare_pub_input", "var": 0 },
158
+ { "op": "declare_pub_input", "var": 1 },
159
+ { "op": "pi_skip", "guard": 10, "count": 6 },
160
+ { "op": "load_imm", "imm": "11" },
161
+ { "op": "declare_pub_input", "var": 60 },
162
+ { "op": "declare_pub_input", "var": 10 },
163
+ { "op": "declare_pub_input", "var": 30 },
164
+ { "op": "declare_pub_input", "var": 29 },
165
+ { "op": "declare_pub_input", "var": 29 },
166
+ { "op": "declare_pub_input", "var": 29 },
167
+ { "op": "declare_pub_input", "var": 29 },
168
+ { "op": "declare_pub_input", "var": 30 },
169
+ { "op": "declare_pub_input", "var": 29 },
170
+ { "op": "declare_pub_input", "var": 15 },
171
+ { "op": "declare_pub_input", "var": 15 },
172
+ { "op": "declare_pub_input", "var": 2 },
173
+ { "op": "declare_pub_input", "var": 3 },
174
+ { "op": "declare_pub_input", "var": 4 },
175
+ { "op": "declare_pub_input", "var": 5 },
176
+ { "op": "declare_pub_input", "var": 6 },
177
+ { "op": "declare_pub_input", "var": 7 },
178
+ { "op": "declare_pub_input", "var": 57 },
179
+ { "op": "declare_pub_input", "var": 58 },
180
+ { "op": "declare_pub_input", "var": 8 },
181
+ { "op": "declare_pub_input", "var": 9 },
182
+ { "op": "pi_skip", "guard": 10, "count": 21 },
183
+ { "op": "load_imm", "imm": "91" },
184
+ { "op": "declare_pub_input", "var": 61 },
185
+ { "op": "pi_skip", "guard": 10, "count": 1 },
186
+ { "op": "load_imm", "imm": "A1" },
187
+ { "op": "declare_pub_input", "var": 62 },
188
+ { "op": "pi_skip", "guard": 10, "count": 1 }
189
+ ]
190
+ }
@@ -0,0 +1,108 @@
1
+ import {
2
+ Contract,
3
+ createDataRegistryPrivateState,
4
+ ledger,
5
+ witnesses
6
+ } from "./chunk-VDZ7F7MP.mjs";
7
+ import "./chunk-5QOKJEH3.mjs";
8
+
9
+ // ../chain/dist/dataregistry-simulator-E6RTGGWT.mjs
10
+ import {
11
+ QueryContext,
12
+ sampleContractAddress,
13
+ createConstructorContext,
14
+ emptyZswapLocalState,
15
+ CostModel
16
+ } from "@midnight-ntwrk/compact-runtime";
17
+ var DataRegistrySimulator = class {
18
+ constructor(senderPk) {
19
+ this._defaultOwnerSecret = crypto.getRandomValues(
20
+ new Uint8Array(32)
21
+ );
22
+ this.contractAddress = sampleContractAddress();
23
+ this.contract = new Contract(witnesses);
24
+ this.currentPk = senderPk;
25
+ const {
26
+ currentPrivateState,
27
+ currentContractState,
28
+ currentZswapLocalState
29
+ } = this.contract.initialState(
30
+ createConstructorContext(createDataRegistryPrivateState(), senderPk)
31
+ );
32
+ this.circuitContext = {
33
+ currentPrivateState,
34
+ currentZswapLocalState,
35
+ costModel: CostModel.initialCostModel(),
36
+ currentQueryContext: new QueryContext(
37
+ currentContractState.data,
38
+ this.contractAddress
39
+ )
40
+ };
41
+ }
42
+ /**
43
+ * Switch to a different user (different secret key and public key).
44
+ * Generates a fresh random default owner secret for the new user.
45
+ */
46
+ switchUser(senderPk) {
47
+ this.currentPk = senderPk;
48
+ this.circuitContext.currentZswapLocalState = emptyZswapLocalState(senderPk);
49
+ this.circuitContext.currentPrivateState = createDataRegistryPrivateState();
50
+ this._defaultOwnerSecret = crypto.getRandomValues(new Uint8Array(32));
51
+ }
52
+ getLedger() {
53
+ return ledger(this.circuitContext.currentQueryContext.state);
54
+ }
55
+ storeReference(storageId, encryptionScheme, storageProvider, metadata, writtenAt, keyEnvelope = "", contentHash = new Uint8Array(32), ownerSecret = this._defaultOwnerSecret) {
56
+ this.circuitContext.currentPrivateState = { ownerSecret };
57
+ const res = this.contract.impureCircuits.storeReference(
58
+ this.circuitContext,
59
+ storageId,
60
+ encryptionScheme,
61
+ storageProvider,
62
+ metadata,
63
+ writtenAt,
64
+ keyEnvelope,
65
+ contentHash
66
+ );
67
+ this.circuitContext = { ...res.context, currentPrivateState: {} };
68
+ return res.result;
69
+ }
70
+ removeReference(refId, ownerSecret = this._defaultOwnerSecret) {
71
+ this.circuitContext.currentPrivateState = { ownerSecret };
72
+ const res = this.contract.impureCircuits.removeReference(
73
+ this.circuitContext,
74
+ refId
75
+ );
76
+ this.circuitContext = { ...res.context, currentPrivateState: {} };
77
+ return res.result;
78
+ }
79
+ computeOwnerCommitment(secret, nonce, instanceSalt) {
80
+ return this.contract._computeOwnerCommitment_0(
81
+ secret,
82
+ nonce,
83
+ instanceSalt
84
+ );
85
+ }
86
+ updateReference(refId, storageId, encryptionScheme, storageProvider, metadata, writtenAt, keyEnvelope = "", contentHash = new Uint8Array(32), ownerSecret = this._defaultOwnerSecret, newOwnerSecret) {
87
+ this.circuitContext.currentPrivateState = {
88
+ ownerSecret,
89
+ newOwnerSecret: newOwnerSecret ?? ownerSecret
90
+ };
91
+ const res = this.contract.impureCircuits.updateReference(
92
+ this.circuitContext,
93
+ refId,
94
+ storageId,
95
+ encryptionScheme,
96
+ storageProvider,
97
+ metadata,
98
+ writtenAt,
99
+ keyEnvelope,
100
+ contentHash
101
+ );
102
+ this.circuitContext = { ...res.context, currentPrivateState: {} };
103
+ return res.result;
104
+ }
105
+ };
106
+ export {
107
+ DataRegistrySimulator
108
+ };
@@ -0,0 +1,109 @@
1
+ import {
2
+ Contract,
3
+ createDataRegistryPrivateState,
4
+ ledger,
5
+ witnesses
6
+ } from "./chunk-VDZ7F7MP.mjs";
7
+ import "./chunk-5QOKJEH3.mjs";
8
+ import "./chunk-UJCSKKID.mjs";
9
+
10
+ // ../chain/dist/dataregistry-simulator-E6RTGGWT.mjs
11
+ import {
12
+ QueryContext,
13
+ sampleContractAddress,
14
+ createConstructorContext,
15
+ emptyZswapLocalState,
16
+ CostModel
17
+ } from "@midnight-ntwrk/compact-runtime";
18
+ var DataRegistrySimulator = class {
19
+ constructor(senderPk) {
20
+ this._defaultOwnerSecret = crypto.getRandomValues(
21
+ new Uint8Array(32)
22
+ );
23
+ this.contractAddress = sampleContractAddress();
24
+ this.contract = new Contract(witnesses);
25
+ this.currentPk = senderPk;
26
+ const {
27
+ currentPrivateState,
28
+ currentContractState,
29
+ currentZswapLocalState
30
+ } = this.contract.initialState(
31
+ createConstructorContext(createDataRegistryPrivateState(), senderPk)
32
+ );
33
+ this.circuitContext = {
34
+ currentPrivateState,
35
+ currentZswapLocalState,
36
+ costModel: CostModel.initialCostModel(),
37
+ currentQueryContext: new QueryContext(
38
+ currentContractState.data,
39
+ this.contractAddress
40
+ )
41
+ };
42
+ }
43
+ /**
44
+ * Switch to a different user (different secret key and public key).
45
+ * Generates a fresh random default owner secret for the new user.
46
+ */
47
+ switchUser(senderPk) {
48
+ this.currentPk = senderPk;
49
+ this.circuitContext.currentZswapLocalState = emptyZswapLocalState(senderPk);
50
+ this.circuitContext.currentPrivateState = createDataRegistryPrivateState();
51
+ this._defaultOwnerSecret = crypto.getRandomValues(new Uint8Array(32));
52
+ }
53
+ getLedger() {
54
+ return ledger(this.circuitContext.currentQueryContext.state);
55
+ }
56
+ storeReference(storageId, encryptionScheme, storageProvider, metadata, writtenAt, keyEnvelope = "", contentHash = new Uint8Array(32), ownerSecret = this._defaultOwnerSecret) {
57
+ this.circuitContext.currentPrivateState = { ownerSecret };
58
+ const res = this.contract.impureCircuits.storeReference(
59
+ this.circuitContext,
60
+ storageId,
61
+ encryptionScheme,
62
+ storageProvider,
63
+ metadata,
64
+ writtenAt,
65
+ keyEnvelope,
66
+ contentHash
67
+ );
68
+ this.circuitContext = { ...res.context, currentPrivateState: {} };
69
+ return res.result;
70
+ }
71
+ removeReference(refId, ownerSecret = this._defaultOwnerSecret) {
72
+ this.circuitContext.currentPrivateState = { ownerSecret };
73
+ const res = this.contract.impureCircuits.removeReference(
74
+ this.circuitContext,
75
+ refId
76
+ );
77
+ this.circuitContext = { ...res.context, currentPrivateState: {} };
78
+ return res.result;
79
+ }
80
+ computeOwnerCommitment(secret, nonce, instanceSalt) {
81
+ return this.contract._computeOwnerCommitment_0(
82
+ secret,
83
+ nonce,
84
+ instanceSalt
85
+ );
86
+ }
87
+ updateReference(refId, storageId, encryptionScheme, storageProvider, metadata, writtenAt, keyEnvelope = "", contentHash = new Uint8Array(32), ownerSecret = this._defaultOwnerSecret, newOwnerSecret) {
88
+ this.circuitContext.currentPrivateState = {
89
+ ownerSecret,
90
+ newOwnerSecret: newOwnerSecret ?? ownerSecret
91
+ };
92
+ const res = this.contract.impureCircuits.updateReference(
93
+ this.circuitContext,
94
+ refId,
95
+ storageId,
96
+ encryptionScheme,
97
+ storageProvider,
98
+ metadata,
99
+ writtenAt,
100
+ keyEnvelope,
101
+ contentHash
102
+ );
103
+ this.circuitContext = { ...res.context, currentPrivateState: {} };
104
+ return res.result;
105
+ }
106
+ };
107
+ export {
108
+ DataRegistrySimulator
109
+ };
@@ -0,0 +1 @@
1
+ import{a as C,b as m,c as l,d as u}from"./chunk-TNRKN4LB.mjs";import"./chunk-ZGUY5EIR.mjs";import{QueryContext as S,sampleContractAddress as d,createConstructorContext as w,emptyZswapLocalState as p,CostModel as f}from"@midnight-ntwrk/compact-runtime";var R=class{constructor(t){this._defaultOwnerSecret=crypto.getRandomValues(new Uint8Array(32)),this.contractAddress=d(),this.contract=new C(l),this.currentPk=t;let{currentPrivateState:r,currentContractState:e,currentZswapLocalState:c}=this.contract.initialState(w(u(),t));this.circuitContext={currentPrivateState:r,currentZswapLocalState:c,costModel:f.initialCostModel(),currentQueryContext:new S(e.data,this.contractAddress)}}switchUser(t){this.currentPk=t,this.circuitContext.currentZswapLocalState=p(t),this.circuitContext.currentPrivateState=u(),this._defaultOwnerSecret=crypto.getRandomValues(new Uint8Array(32))}getLedger(){return m(this.circuitContext.currentQueryContext.state)}storeReference(t,r,e,c,n,a="",s=new Uint8Array(32),o=this._defaultOwnerSecret){this.circuitContext.currentPrivateState={ownerSecret:o};let i=this.contract.impureCircuits.storeReference(this.circuitContext,t,r,e,c,n,a,s);return this.circuitContext={...i.context,currentPrivateState:{}},i.result}removeReference(t,r=this._defaultOwnerSecret){this.circuitContext.currentPrivateState={ownerSecret:r};let e=this.contract.impureCircuits.removeReference(this.circuitContext,t);return this.circuitContext={...e.context,currentPrivateState:{}},e.result}computeOwnerCommitment(t,r,e){return this.contract._computeOwnerCommitment_0(t,r,e)}updateReference(t,r,e,c,n,a,s="",o=new Uint8Array(32),i=this._defaultOwnerSecret,x){this.circuitContext.currentPrivateState={ownerSecret:i,newOwnerSecret:x??i};let h=this.contract.impureCircuits.updateReference(this.circuitContext,t,r,e,c,n,a,s,o);return this.circuitContext={...h.context,currentPrivateState:{}},h.result}};export{R as DataRegistrySimulator};
@@ -0,0 +1 @@
1
+ import{A,B,C,D,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-UBALMYIY.mjs";export{c as CryptoErrorCode,a as DStorageError,f as KeyDeriver,o as XChaChaScheme,d as base64urlToBytes,u as buildKeyEnvelope,e as bytesToBase64url,C as computeBlake3,D as computeBlake3Hex,l as decryptStorageIdXChaCha,j as decryptXChaCha,q as deriveKek,t as deriveOwnerSecret,h as deriveSymmetricKeyFromSeed,n as deserializeXChaChaPayload,k as encryptStorageIdXChaCha,i as encryptXChaCha,x as findWrapper,p as generateDek,g as hexToBytes,b as isDStorageError,y as mlkemGenerateKeypair,z as mlkemGenerateKeypairFromSeed,B as mlkemUnwrapDek,A as mlkemWrapDek,w as parseKeyEnvelope,v as serializeKeyEnvelope,m as serializeXChaChaPayload,s as unwrapKey,r as wrapKey};
@@ -0,0 +1,65 @@
1
+ import {
2
+ CryptoErrorCode,
3
+ DStorageError,
4
+ KeyDeriver,
5
+ XChaChaScheme,
6
+ base64urlToBytes,
7
+ buildKeyEnvelope,
8
+ bytesToBase64url,
9
+ computeBlake3,
10
+ computeBlake3Hex,
11
+ decryptStorageIdXChaCha,
12
+ decryptXChaCha,
13
+ deriveKek,
14
+ deriveOwnerSecret,
15
+ deriveSymmetricKeyFromSeed,
16
+ deserializeXChaChaPayload,
17
+ encryptStorageIdXChaCha,
18
+ encryptXChaCha,
19
+ findWrapper,
20
+ generateDek,
21
+ hexToBytes,
22
+ isDStorageError,
23
+ mlkemGenerateKeypair,
24
+ mlkemGenerateKeypairFromSeed,
25
+ mlkemUnwrapDek,
26
+ mlkemWrapDek,
27
+ parseKeyEnvelope,
28
+ serializeKeyEnvelope,
29
+ serializeXChaChaPayload,
30
+ unwrapKey,
31
+ wrapKey
32
+ } from "./chunk-BWLEAAFW.mjs";
33
+ import "./chunk-UJCSKKID.mjs";
34
+ export {
35
+ CryptoErrorCode,
36
+ DStorageError,
37
+ KeyDeriver,
38
+ XChaChaScheme,
39
+ base64urlToBytes,
40
+ buildKeyEnvelope,
41
+ bytesToBase64url,
42
+ computeBlake3,
43
+ computeBlake3Hex,
44
+ decryptStorageIdXChaCha,
45
+ decryptXChaCha,
46
+ deriveKek,
47
+ deriveOwnerSecret,
48
+ deriveSymmetricKeyFromSeed,
49
+ deserializeXChaChaPayload,
50
+ encryptStorageIdXChaCha,
51
+ encryptXChaCha,
52
+ findWrapper,
53
+ generateDek,
54
+ hexToBytes,
55
+ isDStorageError,
56
+ mlkemGenerateKeypair,
57
+ mlkemGenerateKeypairFromSeed,
58
+ mlkemUnwrapDek,
59
+ mlkemWrapDek,
60
+ parseKeyEnvelope,
61
+ serializeKeyEnvelope,
62
+ serializeXChaChaPayload,
63
+ unwrapKey,
64
+ wrapKey
65
+ };
@@ -0,0 +1 @@
1
+ import{A,B,C,D,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-EYF3263P.mjs";export{c as CryptoErrorCode,a as DStorageError,f as KeyDeriver,o as XChaChaScheme,d as base64urlToBytes,u as buildKeyEnvelope,e as bytesToBase64url,C as computeBlake3,D as computeBlake3Hex,l as decryptStorageIdXChaCha,j as decryptXChaCha,q as deriveKek,t as deriveOwnerSecret,h as deriveSymmetricKeyFromSeed,n as deserializeXChaChaPayload,k as encryptStorageIdXChaCha,i as encryptXChaCha,x as findWrapper,p as generateDek,g as hexToBytes,b as isDStorageError,y as mlkemGenerateKeypair,z as mlkemGenerateKeypairFromSeed,B as mlkemUnwrapDek,A as mlkemWrapDek,w as parseKeyEnvelope,v as serializeKeyEnvelope,m as serializeXChaChaPayload,s as unwrapKey,r as wrapKey};
@@ -0,0 +1,64 @@
1
+ import {
2
+ CryptoErrorCode,
3
+ DStorageError,
4
+ KeyDeriver,
5
+ XChaChaScheme,
6
+ base64urlToBytes,
7
+ buildKeyEnvelope,
8
+ bytesToBase64url,
9
+ computeBlake3,
10
+ computeBlake3Hex,
11
+ decryptStorageIdXChaCha,
12
+ decryptXChaCha,
13
+ deriveKek,
14
+ deriveOwnerSecret,
15
+ deriveSymmetricKeyFromSeed,
16
+ deserializeXChaChaPayload,
17
+ encryptStorageIdXChaCha,
18
+ encryptXChaCha,
19
+ findWrapper,
20
+ generateDek,
21
+ hexToBytes,
22
+ isDStorageError,
23
+ mlkemGenerateKeypair,
24
+ mlkemGenerateKeypairFromSeed,
25
+ mlkemUnwrapDek,
26
+ mlkemWrapDek,
27
+ parseKeyEnvelope,
28
+ serializeKeyEnvelope,
29
+ serializeXChaChaPayload,
30
+ unwrapKey,
31
+ wrapKey
32
+ } from "./chunk-BWLEAAFW.mjs";
33
+ export {
34
+ CryptoErrorCode,
35
+ DStorageError,
36
+ KeyDeriver,
37
+ XChaChaScheme,
38
+ base64urlToBytes,
39
+ buildKeyEnvelope,
40
+ bytesToBase64url,
41
+ computeBlake3,
42
+ computeBlake3Hex,
43
+ decryptStorageIdXChaCha,
44
+ decryptXChaCha,
45
+ deriveKek,
46
+ deriveOwnerSecret,
47
+ deriveSymmetricKeyFromSeed,
48
+ deserializeXChaChaPayload,
49
+ encryptStorageIdXChaCha,
50
+ encryptXChaCha,
51
+ findWrapper,
52
+ generateDek,
53
+ hexToBytes,
54
+ isDStorageError,
55
+ mlkemGenerateKeypair,
56
+ mlkemGenerateKeypairFromSeed,
57
+ mlkemUnwrapDek,
58
+ mlkemWrapDek,
59
+ parseKeyEnvelope,
60
+ serializeKeyEnvelope,
61
+ serializeXChaChaPayload,
62
+ unwrapKey,
63
+ wrapKey
64
+ };
@@ -0,0 +1,65 @@
1
+ import {
2
+ CryptoErrorCode,
3
+ DStorageError,
4
+ KeyDeriver,
5
+ XChaChaScheme,
6
+ base64urlToBytes,
7
+ buildKeyEnvelope,
8
+ bytesToBase64url,
9
+ computeBlake3,
10
+ computeBlake3Hex,
11
+ decryptStorageIdXChaCha,
12
+ decryptXChaCha,
13
+ deriveKek,
14
+ deriveOwnerSecret,
15
+ deriveSymmetricKeyFromSeed,
16
+ deserializeXChaChaPayload,
17
+ encryptStorageIdXChaCha,
18
+ encryptXChaCha,
19
+ findWrapper,
20
+ generateDek,
21
+ hexToBytes,
22
+ isDStorageError,
23
+ mlkemGenerateKeypair,
24
+ mlkemGenerateKeypairFromSeed,
25
+ mlkemUnwrapDek,
26
+ mlkemWrapDek,
27
+ parseKeyEnvelope,
28
+ serializeKeyEnvelope,
29
+ serializeXChaChaPayload,
30
+ unwrapKey,
31
+ wrapKey
32
+ } from "./chunk-TSZ37JDY.mjs";
33
+ import "./chunk-UJCSKKID.mjs";
34
+ export {
35
+ CryptoErrorCode,
36
+ DStorageError,
37
+ KeyDeriver,
38
+ XChaChaScheme,
39
+ base64urlToBytes,
40
+ buildKeyEnvelope,
41
+ bytesToBase64url,
42
+ computeBlake3,
43
+ computeBlake3Hex,
44
+ decryptStorageIdXChaCha,
45
+ decryptXChaCha,
46
+ deriveKek,
47
+ deriveOwnerSecret,
48
+ deriveSymmetricKeyFromSeed,
49
+ deserializeXChaChaPayload,
50
+ encryptStorageIdXChaCha,
51
+ encryptXChaCha,
52
+ findWrapper,
53
+ generateDek,
54
+ hexToBytes,
55
+ isDStorageError,
56
+ mlkemGenerateKeypair,
57
+ mlkemGenerateKeypairFromSeed,
58
+ mlkemUnwrapDek,
59
+ mlkemWrapDek,
60
+ parseKeyEnvelope,
61
+ serializeKeyEnvelope,
62
+ serializeXChaChaPayload,
63
+ unwrapKey,
64
+ wrapKey
65
+ };