@rohan-protocol/sdk 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +49 -177
  2. package/dist/client.d.ts +8 -37
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +86 -134
  5. package/dist/client.js.map +1 -1
  6. package/dist/generated/compiler/contract-info.json +33 -19
  7. package/dist/generated/contract/index.d.ts +22 -12
  8. package/dist/generated/contract/index.js +377 -101
  9. package/dist/generated/contract/index.js.map +2 -2
  10. package/dist/generated/keys/initial_setup.prover +0 -0
  11. package/dist/generated/keys/initial_setup.verifier +0 -0
  12. package/dist/generated/keys/verify_batched_handshakes.prover +0 -0
  13. package/dist/generated/keys/verify_batched_handshakes.verifier +0 -0
  14. package/dist/generated/zkir/initial_setup.bzkir +0 -0
  15. package/dist/generated/zkir/initial_setup.zkir +80 -14
  16. package/dist/generated/zkir/verify_batched_handshakes.bzkir +0 -0
  17. package/dist/generated/zkir/verify_batched_handshakes.zkir +126 -35
  18. package/dist/index.d.ts +0 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +0 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/security/zeroize.d.ts +6 -6
  23. package/dist/security/zeroize.d.ts.map +1 -1
  24. package/dist/security/zeroize.js +13 -15
  25. package/dist/security/zeroize.js.map +1 -1
  26. package/dist/types.d.ts +21 -45
  27. package/dist/types.d.ts.map +1 -1
  28. package/package.json +1 -1
  29. package/src/generated/compiler/contract-info.json +33 -19
  30. package/src/generated/contract/index.d.ts +22 -12
  31. package/src/generated/contract/index.js +377 -101
  32. package/src/generated/contract/index.js.map +2 -2
  33. package/src/generated/keys/initial_setup.prover +0 -0
  34. package/src/generated/keys/initial_setup.verifier +0 -0
  35. package/src/generated/keys/verify_batched_handshakes.prover +0 -0
  36. package/src/generated/keys/verify_batched_handshakes.verifier +0 -0
  37. package/src/generated/zkir/initial_setup.bzkir +0 -0
  38. package/src/generated/zkir/initial_setup.zkir +80 -14
  39. package/src/generated/zkir/verify_batched_handshakes.bzkir +0 -0
  40. package/src/generated/zkir/verify_batched_handshakes.zkir +126 -35
  41. package/dist/prover.d.ts +0 -11
  42. package/dist/prover.d.ts.map +0 -1
  43. package/dist/prover.js +0 -34
  44. package/dist/prover.js.map +0 -1
  45. package/dist/verifier.d.ts +0 -21
  46. package/dist/verifier.d.ts.map +0 -1
  47. package/dist/verifier.js +0 -43
  48. package/dist/verifier.js.map +0 -1
@@ -1,51 +1,49 @@
1
1
  import * as __compactRuntime from '@midnight-ntwrk/compact-runtime';
2
- // __compactRuntime.checkRuntimeVersion('0.14.0');
2
+ __compactRuntime.checkRuntimeVersion('0.16.0');
3
3
 
4
- const _descriptor_0 = new __compactRuntime.CompactTypeBytes(32);
4
+ const _descriptor_0 = new __compactRuntime.CompactTypeUnsignedInteger(18446744073709551615n, 8);
5
5
 
6
- const _descriptor_1 = new __compactRuntime.CompactTypeBytes(128);
6
+ const _descriptor_1 = new __compactRuntime.CompactTypeBytes(32);
7
7
 
8
- const _descriptor_2 = new __compactRuntime.CompactTypeUnsignedInteger(18446744073709551615n, 8);
9
-
10
- const _descriptor_3 = __compactRuntime.CompactTypeBoolean;
8
+ const _descriptor_2 = __compactRuntime.CompactTypeBoolean;
11
9
 
12
10
  class _Either_0 {
13
11
  alignment() {
14
- return _descriptor_3.alignment().concat(_descriptor_0.alignment().concat(_descriptor_0.alignment()));
12
+ return _descriptor_2.alignment().concat(_descriptor_1.alignment().concat(_descriptor_1.alignment()));
15
13
  }
16
14
  fromValue(value_0) {
17
15
  return {
18
- is_left: _descriptor_3.fromValue(value_0),
19
- left: _descriptor_0.fromValue(value_0),
20
- right: _descriptor_0.fromValue(value_0)
16
+ is_left: _descriptor_2.fromValue(value_0),
17
+ left: _descriptor_1.fromValue(value_0),
18
+ right: _descriptor_1.fromValue(value_0)
21
19
  }
22
20
  }
23
21
  toValue(value_0) {
24
- return _descriptor_3.toValue(value_0.is_left).concat(_descriptor_0.toValue(value_0.left).concat(_descriptor_0.toValue(value_0.right)));
22
+ return _descriptor_2.toValue(value_0.is_left).concat(_descriptor_1.toValue(value_0.left).concat(_descriptor_1.toValue(value_0.right)));
25
23
  }
26
24
  }
27
25
 
28
- const _descriptor_4 = new _Either_0();
26
+ const _descriptor_3 = new _Either_0();
29
27
 
30
- const _descriptor_5 = new __compactRuntime.CompactTypeUnsignedInteger(340282366920938463463374607431768211455n, 16);
28
+ const _descriptor_4 = new __compactRuntime.CompactTypeUnsignedInteger(340282366920938463463374607431768211455n, 16);
31
29
 
32
30
  class _ContractAddress_0 {
33
31
  alignment() {
34
- return _descriptor_0.alignment();
32
+ return _descriptor_1.alignment();
35
33
  }
36
34
  fromValue(value_0) {
37
35
  return {
38
- bytes: _descriptor_0.fromValue(value_0)
36
+ bytes: _descriptor_1.fromValue(value_0)
39
37
  }
40
38
  }
41
39
  toValue(value_0) {
42
- return _descriptor_0.toValue(value_0.bytes);
40
+ return _descriptor_1.toValue(value_0.bytes);
43
41
  }
44
42
  }
45
43
 
46
- const _descriptor_6 = new _ContractAddress_0();
44
+ const _descriptor_5 = new _ContractAddress_0();
47
45
 
48
- const _descriptor_7 = new __compactRuntime.CompactTypeUnsignedInteger(255n, 1);
46
+ const _descriptor_6 = new __compactRuntime.CompactTypeUnsignedInteger(255n, 1);
49
47
 
50
48
  export class Contract {
51
49
  witnesses;
@@ -59,113 +57,131 @@ export class Contract {
59
57
  }
60
58
  this.witnesses = witnesses_0;
61
59
  this.circuits = {
62
- verify_batched_handshakes: (...args_1) => {
63
- if (args_1.length !== 5) {
64
- throw new __compactRuntime.CompactError(`verify_batched_handshakes: expected 5 arguments (as invoked from Typescript), received ${args_1.length}`);
60
+ initial_setup: (...args_1) => {
61
+ if (args_1.length !== 3) {
62
+ throw new __compactRuntime.CompactError(`initial_setup: expected 3 arguments (as invoked from Typescript), received ${args_1.length}`);
65
63
  }
66
64
  const contextOrig_0 = args_1[0];
67
- const previous_root_0 = args_1[1];
68
- const new_root_0 = args_1[2];
69
- const batched_proof_data_0 = args_1[3];
70
- const total_toll_collected_0 = args_1[4];
65
+ const initial_root_0 = args_1[1];
66
+ const relayer_identity_0 = args_1[2];
71
67
  if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.currentQueryContext != undefined)) {
72
- __compactRuntime.typeError('verify_batched_handshakes',
68
+ __compactRuntime.typeError('initial_setup',
73
69
  'argument 1 (as invoked from Typescript)',
74
- 'rohan_handshake.compact line 18 char 1',
70
+ 'rohan_handshake.compact line 17 char 1',
75
71
  'CircuitContext',
76
72
  contextOrig_0)
77
73
  }
78
- if (!(previous_root_0.buffer instanceof ArrayBuffer && previous_root_0.BYTES_PER_ELEMENT === 1 && previous_root_0.length === 32)) {
79
- __compactRuntime.typeError('verify_batched_handshakes',
74
+ if (!(initial_root_0.buffer instanceof ArrayBuffer && initial_root_0.BYTES_PER_ELEMENT === 1 && initial_root_0.length === 32)) {
75
+ __compactRuntime.typeError('initial_setup',
80
76
  'argument 1 (argument 2 as invoked from Typescript)',
81
- 'rohan_handshake.compact line 18 char 1',
77
+ 'rohan_handshake.compact line 17 char 1',
82
78
  'Bytes<32>',
83
- previous_root_0)
79
+ initial_root_0)
84
80
  }
85
- if (!(new_root_0.buffer instanceof ArrayBuffer && new_root_0.BYTES_PER_ELEMENT === 1 && new_root_0.length === 32)) {
86
- __compactRuntime.typeError('verify_batched_handshakes',
81
+ if (!(relayer_identity_0.buffer instanceof ArrayBuffer && relayer_identity_0.BYTES_PER_ELEMENT === 1 && relayer_identity_0.length === 32)) {
82
+ __compactRuntime.typeError('initial_setup',
87
83
  'argument 2 (argument 3 as invoked from Typescript)',
88
- 'rohan_handshake.compact line 18 char 1',
84
+ 'rohan_handshake.compact line 17 char 1',
89
85
  'Bytes<32>',
90
- new_root_0)
91
- }
92
- if (!(batched_proof_data_0.buffer instanceof ArrayBuffer && batched_proof_data_0.BYTES_PER_ELEMENT === 1 && batched_proof_data_0.length === 128)) {
93
- __compactRuntime.typeError('verify_batched_handshakes',
94
- 'argument 3 (argument 4 as invoked from Typescript)',
95
- 'rohan_handshake.compact line 18 char 1',
96
- 'Bytes<128>',
97
- batched_proof_data_0)
98
- }
99
- if (!(typeof(total_toll_collected_0) === 'bigint' && total_toll_collected_0 >= 0n && total_toll_collected_0 <= 18446744073709551615n)) {
100
- __compactRuntime.typeError('verify_batched_handshakes',
101
- 'argument 4 (argument 5 as invoked from Typescript)',
102
- 'rohan_handshake.compact line 18 char 1',
103
- 'Uint<0..18446744073709551616>',
104
- total_toll_collected_0)
86
+ relayer_identity_0)
105
87
  }
106
88
  const context = { ...contextOrig_0, gasCost: __compactRuntime.emptyRunningCost() };
107
89
  const partialProofData = {
108
90
  input: {
109
- value: _descriptor_0.toValue(previous_root_0).concat(_descriptor_0.toValue(new_root_0).concat(_descriptor_1.toValue(batched_proof_data_0).concat(_descriptor_2.toValue(total_toll_collected_0)))),
110
- alignment: _descriptor_0.alignment().concat(_descriptor_0.alignment().concat(_descriptor_1.alignment().concat(_descriptor_2.alignment())))
91
+ value: _descriptor_1.toValue(initial_root_0).concat(_descriptor_1.toValue(relayer_identity_0)),
92
+ alignment: _descriptor_1.alignment().concat(_descriptor_1.alignment())
111
93
  },
112
94
  output: undefined,
113
95
  publicTranscript: [],
114
96
  privateTranscriptOutputs: []
115
97
  };
116
- const result_0 = this._verify_batched_handshakes_0(context,
117
- partialProofData,
118
- previous_root_0,
119
- new_root_0,
120
- batched_proof_data_0,
121
- total_toll_collected_0);
98
+ const result_0 = this._initial_setup_0(context,
99
+ partialProofData,
100
+ initial_root_0,
101
+ relayer_identity_0);
122
102
  partialProofData.output = { value: [], alignment: [] };
123
103
  return { result: result_0, context: context, proofData: partialProofData, gasCost: context.gasCost };
124
104
  },
125
- initial_setup: (...args_1) => {
126
- if (args_1.length !== 2) {
127
- throw new __compactRuntime.CompactError(`initial_setup: expected 2 arguments (as invoked from Typescript), received ${args_1.length}`);
105
+ verify_batched_handshakes: (...args_1) => {
106
+ if (args_1.length !== 6) {
107
+ throw new __compactRuntime.CompactError(`verify_batched_handshakes: expected 6 arguments (as invoked from Typescript), received ${args_1.length}`);
128
108
  }
129
109
  const contextOrig_0 = args_1[0];
130
- const initial_root_0 = args_1[1];
110
+ const previous_root_0 = args_1[1];
111
+ const new_root_0 = args_1[2];
112
+ const proof_commitment_0 = args_1[3];
113
+ const caller_identity_0 = args_1[4];
114
+ const toll_amount_0 = args_1[5];
131
115
  if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.currentQueryContext != undefined)) {
132
- __compactRuntime.typeError('initial_setup',
116
+ __compactRuntime.typeError('verify_batched_handshakes',
133
117
  'argument 1 (as invoked from Typescript)',
134
- 'rohan_handshake.compact line 52 char 1',
118
+ 'rohan_handshake.compact line 35 char 1',
135
119
  'CircuitContext',
136
120
  contextOrig_0)
137
121
  }
138
- if (!(initial_root_0.buffer instanceof ArrayBuffer && initial_root_0.BYTES_PER_ELEMENT === 1 && initial_root_0.length === 32)) {
139
- __compactRuntime.typeError('initial_setup',
122
+ if (!(previous_root_0.buffer instanceof ArrayBuffer && previous_root_0.BYTES_PER_ELEMENT === 1 && previous_root_0.length === 32)) {
123
+ __compactRuntime.typeError('verify_batched_handshakes',
140
124
  'argument 1 (argument 2 as invoked from Typescript)',
141
- 'rohan_handshake.compact line 52 char 1',
125
+ 'rohan_handshake.compact line 35 char 1',
142
126
  'Bytes<32>',
143
- initial_root_0)
127
+ previous_root_0)
128
+ }
129
+ if (!(new_root_0.buffer instanceof ArrayBuffer && new_root_0.BYTES_PER_ELEMENT === 1 && new_root_0.length === 32)) {
130
+ __compactRuntime.typeError('verify_batched_handshakes',
131
+ 'argument 2 (argument 3 as invoked from Typescript)',
132
+ 'rohan_handshake.compact line 35 char 1',
133
+ 'Bytes<32>',
134
+ new_root_0)
135
+ }
136
+ if (!(proof_commitment_0.buffer instanceof ArrayBuffer && proof_commitment_0.BYTES_PER_ELEMENT === 1 && proof_commitment_0.length === 32)) {
137
+ __compactRuntime.typeError('verify_batched_handshakes',
138
+ 'argument 3 (argument 4 as invoked from Typescript)',
139
+ 'rohan_handshake.compact line 35 char 1',
140
+ 'Bytes<32>',
141
+ proof_commitment_0)
142
+ }
143
+ if (!(caller_identity_0.buffer instanceof ArrayBuffer && caller_identity_0.BYTES_PER_ELEMENT === 1 && caller_identity_0.length === 32)) {
144
+ __compactRuntime.typeError('verify_batched_handshakes',
145
+ 'argument 4 (argument 5 as invoked from Typescript)',
146
+ 'rohan_handshake.compact line 35 char 1',
147
+ 'Bytes<32>',
148
+ caller_identity_0)
149
+ }
150
+ if (!(typeof(toll_amount_0) === 'bigint' && toll_amount_0 >= 0n && toll_amount_0 <= 18446744073709551615n)) {
151
+ __compactRuntime.typeError('verify_batched_handshakes',
152
+ 'argument 5 (argument 6 as invoked from Typescript)',
153
+ 'rohan_handshake.compact line 35 char 1',
154
+ 'Uint<0..18446744073709551616>',
155
+ toll_amount_0)
144
156
  }
145
157
  const context = { ...contextOrig_0, gasCost: __compactRuntime.emptyRunningCost() };
146
158
  const partialProofData = {
147
159
  input: {
148
- value: _descriptor_0.toValue(initial_root_0),
149
- alignment: _descriptor_0.alignment()
160
+ value: _descriptor_1.toValue(previous_root_0).concat(_descriptor_1.toValue(new_root_0).concat(_descriptor_1.toValue(proof_commitment_0).concat(_descriptor_1.toValue(caller_identity_0).concat(_descriptor_0.toValue(toll_amount_0))))),
161
+ alignment: _descriptor_1.alignment().concat(_descriptor_1.alignment().concat(_descriptor_1.alignment().concat(_descriptor_1.alignment().concat(_descriptor_0.alignment()))))
150
162
  },
151
163
  output: undefined,
152
164
  publicTranscript: [],
153
165
  privateTranscriptOutputs: []
154
166
  };
155
- const result_0 = this._initial_setup_0(context,
156
- partialProofData,
157
- initial_root_0);
167
+ const result_0 = this._verify_batched_handshakes_0(context,
168
+ partialProofData,
169
+ previous_root_0,
170
+ new_root_0,
171
+ proof_commitment_0,
172
+ caller_identity_0,
173
+ toll_amount_0);
158
174
  partialProofData.output = { value: [], alignment: [] };
159
175
  return { result: result_0, context: context, proofData: partialProofData, gasCost: context.gasCost };
160
176
  }
161
177
  };
162
178
  this.impureCircuits = {
163
- verify_batched_handshakes: this.circuits.verify_batched_handshakes,
164
- initial_setup: this.circuits.initial_setup
179
+ initial_setup: this.circuits.initial_setup,
180
+ verify_batched_handshakes: this.circuits.verify_batched_handshakes
165
181
  };
166
182
  this.provableCircuits = {
167
- verify_batched_handshakes: this.circuits.verify_batched_handshakes,
168
- initial_setup: this.circuits.initial_setup
183
+ initial_setup: this.circuits.initial_setup,
184
+ verify_batched_handshakes: this.circuits.verify_batched_handshakes
169
185
  };
170
186
  }
171
187
  initialState(...args_0) {
@@ -185,9 +201,12 @@ export class Contract {
185
201
  const state_0 = new __compactRuntime.ContractState();
186
202
  let stateValue_0 = __compactRuntime.StateValue.newArray();
187
203
  stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
204
+ stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
205
+ stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
206
+ stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
188
207
  state_0.data = new __compactRuntime.ChargedState(stateValue_0);
189
- state_0.setOperation('verify_batched_handshakes', new __compactRuntime.ContractOperation());
190
208
  state_0.setOperation('initial_setup', new __compactRuntime.ContractOperation());
209
+ state_0.setOperation('verify_batched_handshakes', new __compactRuntime.ContractOperation());
191
210
  const context = __compactRuntime.createCircuitContext(__compactRuntime.dummyContractAddress(), constructorContext_0.initialZswapLocalState.coinPublicKey, state_0.data, constructorContext_0.initialPrivateState);
192
211
  const partialProofData = {
193
212
  input: { value: [], alignment: [] },
@@ -199,12 +218,42 @@ export class Contract {
199
218
  partialProofData,
200
219
  [
201
220
  { push: { storage: false,
202
- value: __compactRuntime.StateValue.newCell({ value: _descriptor_7.toValue(0n),
203
- alignment: _descriptor_7.alignment() }).encode() } },
221
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_6.toValue(0n),
222
+ alignment: _descriptor_6.alignment() }).encode() } },
223
+ { push: { storage: true,
224
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_1.toValue(new Uint8Array(32)),
225
+ alignment: _descriptor_1.alignment() }).encode() } },
226
+ { ins: { cached: false, n: 1 } }]);
227
+ __compactRuntime.queryLedgerState(context,
228
+ partialProofData,
229
+ [
230
+ { push: { storage: false,
231
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_6.toValue(1n),
232
+ alignment: _descriptor_6.alignment() }).encode() } },
233
+ { push: { storage: true,
234
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(0n),
235
+ alignment: _descriptor_0.alignment() }).encode() } },
236
+ { ins: { cached: false, n: 1 } }]);
237
+ __compactRuntime.queryLedgerState(context,
238
+ partialProofData,
239
+ [
240
+ { push: { storage: false,
241
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_6.toValue(2n),
242
+ alignment: _descriptor_6.alignment() }).encode() } },
204
243
  { push: { storage: true,
205
- value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(new Uint8Array(32)),
244
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(0n),
206
245
  alignment: _descriptor_0.alignment() }).encode() } },
207
246
  { ins: { cached: false, n: 1 } }]);
247
+ __compactRuntime.queryLedgerState(context,
248
+ partialProofData,
249
+ [
250
+ { push: { storage: false,
251
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_6.toValue(3n),
252
+ alignment: _descriptor_6.alignment() }).encode() } },
253
+ { push: { storage: true,
254
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_1.toValue(new Uint8Array(32)),
255
+ alignment: _descriptor_1.alignment() }).encode() } },
256
+ { ins: { cached: false, n: 1 } }]);
208
257
  state_0.data = new __compactRuntime.ChargedState(context.currentQueryContext.state.state);
209
258
  return {
210
259
  currentContractState: state_0,
@@ -212,15 +261,8 @@ export class Contract {
212
261
  currentZswapLocalState: context.currentZswapLocalState
213
262
  }
214
263
  }
215
- _verify_batched_handshakes_0(context,
216
- partialProofData,
217
- previous_root_0,
218
- new_root_0,
219
- batched_proof_data_0,
220
- total_toll_collected_0)
264
+ _initial_setup_0(context, partialProofData, initial_root_0, relayer_identity_0)
221
265
  {
222
- __compactRuntime.assert(true,
223
- 'Prover is not authorized to submit batch roots');
224
266
  __compactRuntime.assert(this._equal_0(_descriptor_0.fromValue(__compactRuntime.queryLedgerState(context,
225
267
  partialProofData,
226
268
  [
@@ -229,40 +271,218 @@ export class Contract {
229
271
  pushPath: false,
230
272
  path: [
231
273
  { tag: 'value',
232
- value: { value: _descriptor_7.toValue(0n),
233
- alignment: _descriptor_7.alignment() } }] } },
274
+ value: { value: _descriptor_6.toValue(1n),
275
+ alignment: _descriptor_6.alignment() } }] } },
234
276
  { popeq: { cached: false,
235
277
  result: undefined } }]).value),
236
- previous_root_0),
237
- 'Previous Root mismatch! Cannot append batch.');
238
- __compactRuntime.assert(total_toll_collected_0 >= 100n,
239
- 'Insufficient DUST/Toll fee collected for batch');
278
+ 0n),
279
+ 'Protocol already initialized: Setup circuit is locked');
280
+ __compactRuntime.queryLedgerState(context,
281
+ partialProofData,
282
+ [
283
+ { push: { storage: false,
284
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_6.toValue(0n),
285
+ alignment: _descriptor_6.alignment() }).encode() } },
286
+ { push: { storage: true,
287
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_1.toValue(initial_root_0),
288
+ alignment: _descriptor_1.alignment() }).encode() } },
289
+ { ins: { cached: false, n: 1 } }]);
290
+ __compactRuntime.queryLedgerState(context,
291
+ partialProofData,
292
+ [
293
+ { push: { storage: false,
294
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_6.toValue(3n),
295
+ alignment: _descriptor_6.alignment() }).encode() } },
296
+ { push: { storage: true,
297
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_1.toValue(relayer_identity_0),
298
+ alignment: _descriptor_1.alignment() }).encode() } },
299
+ { ins: { cached: false, n: 1 } }]);
300
+ const tmp_0 = 1n;
301
+ __compactRuntime.queryLedgerState(context,
302
+ partialProofData,
303
+ [
304
+ { push: { storage: false,
305
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_6.toValue(1n),
306
+ alignment: _descriptor_6.alignment() }).encode() } },
307
+ { push: { storage: true,
308
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(tmp_0),
309
+ alignment: _descriptor_0.alignment() }).encode() } },
310
+ { ins: { cached: false, n: 1 } }]);
311
+ const tmp_1 = 0n;
240
312
  __compactRuntime.queryLedgerState(context,
241
313
  partialProofData,
242
314
  [
243
315
  { push: { storage: false,
244
- value: __compactRuntime.StateValue.newCell({ value: _descriptor_7.toValue(0n),
245
- alignment: _descriptor_7.alignment() }).encode() } },
316
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_6.toValue(2n),
317
+ alignment: _descriptor_6.alignment() }).encode() } },
246
318
  { push: { storage: true,
247
- value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(new_root_0),
319
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(tmp_1),
248
320
  alignment: _descriptor_0.alignment() }).encode() } },
249
321
  { ins: { cached: false, n: 1 } }]);
250
322
  return [];
251
323
  }
252
- _initial_setup_0(context, partialProofData, initial_root_0) {
324
+ _verify_batched_handshakes_0(context,
325
+ partialProofData,
326
+ previous_root_0,
327
+ new_root_0,
328
+ proof_commitment_0,
329
+ caller_identity_0,
330
+ toll_amount_0)
331
+ {
332
+ __compactRuntime.assert(this._equal_1(caller_identity_0,
333
+ _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
334
+ partialProofData,
335
+ [
336
+ { dup: { n: 0 } },
337
+ { idx: { cached: false,
338
+ pushPath: false,
339
+ path: [
340
+ { tag: 'value',
341
+ value: { value: _descriptor_6.toValue(3n),
342
+ alignment: _descriptor_6.alignment() } }] } },
343
+ { popeq: { cached: false,
344
+ result: undefined } }]).value)),
345
+ 'Unauthorized: Prover is not permitted to submit state transitions');
346
+ __compactRuntime.assert(this._equal_2(previous_root_0,
347
+ _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
348
+ partialProofData,
349
+ [
350
+ { dup: { n: 0 } },
351
+ { idx: { cached: false,
352
+ pushPath: false,
353
+ path: [
354
+ { tag: 'value',
355
+ value: { value: _descriptor_6.toValue(0n),
356
+ alignment: _descriptor_6.alignment() } }] } },
357
+ { popeq: { cached: false,
358
+ result: undefined } }]).value)),
359
+ 'Previous root mismatch: Stale state transition rejected');
360
+ __compactRuntime.assert(!this._equal_3(new_root_0, previous_root_0),
361
+ 'Invalid transition: New root cannot be identical to previous root');
362
+ __compactRuntime.assert(!this._equal_4(proof_commitment_0,
363
+ Uint8Array.from([0n,
364
+ 0n,
365
+ 0n,
366
+ 0n,
367
+ 0n,
368
+ 0n,
369
+ 0n,
370
+ 0n,
371
+ 0n,
372
+ 0n,
373
+ 0n,
374
+ 0n,
375
+ 0n,
376
+ 0n,
377
+ 0n,
378
+ 0n,
379
+ 0n,
380
+ 0n,
381
+ 0n,
382
+ 0n,
383
+ 0n,
384
+ 0n,
385
+ 0n,
386
+ 0n,
387
+ 0n,
388
+ 0n,
389
+ 0n,
390
+ 0n,
391
+ 0n,
392
+ 0n,
393
+ 0n,
394
+ 0n],
395
+ Number)),
396
+ 'Cryptographic violation: Empty proof commitment rejected');
397
+ __compactRuntime.assert(toll_amount_0 >= 100n,
398
+ 'Insufficient toll fee: Minimum toll of 100 required');
399
+ __compactRuntime.queryLedgerState(context,
400
+ partialProofData,
401
+ [
402
+ { push: { storage: false,
403
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_6.toValue(0n),
404
+ alignment: _descriptor_6.alignment() }).encode() } },
405
+ { push: { storage: true,
406
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_1.toValue(new_root_0),
407
+ alignment: _descriptor_1.alignment() }).encode() } },
408
+ { ins: { cached: false, n: 1 } }]);
409
+ const tmp_0 = ((t1) => {
410
+ if (t1 > 18446744073709551615n) {
411
+ throw new __compactRuntime.CompactError('rohan_handshake.compact line 64 char 23: cast from Field or Uint value to smaller Uint value failed: ' + t1 + ' is greater than 18446744073709551615');
412
+ }
413
+ return t1;
414
+ })(_descriptor_0.fromValue(__compactRuntime.queryLedgerState(context,
415
+ partialProofData,
416
+ [
417
+ { dup: { n: 0 } },
418
+ { idx: { cached: false,
419
+ pushPath: false,
420
+ path: [
421
+ { tag: 'value',
422
+ value: { value: _descriptor_6.toValue(1n),
423
+ alignment: _descriptor_6.alignment() } }] } },
424
+ { popeq: { cached: false,
425
+ result: undefined } }]).value)
426
+ +
427
+ 1n);
428
+ __compactRuntime.queryLedgerState(context,
429
+ partialProofData,
430
+ [
431
+ { push: { storage: false,
432
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_6.toValue(1n),
433
+ alignment: _descriptor_6.alignment() }).encode() } },
434
+ { push: { storage: true,
435
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(tmp_0),
436
+ alignment: _descriptor_0.alignment() }).encode() } },
437
+ { ins: { cached: false, n: 1 } }]);
438
+ const tmp_1 = ((t1) => {
439
+ if (t1 > 18446744073709551615n) {
440
+ throw new __compactRuntime.CompactError('rohan_handshake.compact line 65 char 18: cast from Field or Uint value to smaller Uint value failed: ' + t1 + ' is greater than 18446744073709551615');
441
+ }
442
+ return t1;
443
+ })(_descriptor_0.fromValue(__compactRuntime.queryLedgerState(context,
444
+ partialProofData,
445
+ [
446
+ { dup: { n: 0 } },
447
+ { idx: { cached: false,
448
+ pushPath: false,
449
+ path: [
450
+ { tag: 'value',
451
+ value: { value: _descriptor_6.toValue(2n),
452
+ alignment: _descriptor_6.alignment() } }] } },
453
+ { popeq: { cached: false,
454
+ result: undefined } }]).value)
455
+ +
456
+ toll_amount_0);
253
457
  __compactRuntime.queryLedgerState(context,
254
458
  partialProofData,
255
459
  [
256
460
  { push: { storage: false,
257
- value: __compactRuntime.StateValue.newCell({ value: _descriptor_7.toValue(0n),
258
- alignment: _descriptor_7.alignment() }).encode() } },
461
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_6.toValue(2n),
462
+ alignment: _descriptor_6.alignment() }).encode() } },
259
463
  { push: { storage: true,
260
- value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(initial_root_0),
464
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(tmp_1),
261
465
  alignment: _descriptor_0.alignment() }).encode() } },
262
466
  { ins: { cached: false, n: 1 } }]);
263
467
  return [];
264
468
  }
265
469
  _equal_0(x0, y0) {
470
+ if (x0 !== y0) { return false; }
471
+ return true;
472
+ }
473
+ _equal_1(x0, y0) {
474
+ if (!x0.every((x, i) => y0[i] === x)) { return false; }
475
+ return true;
476
+ }
477
+ _equal_2(x0, y0) {
478
+ if (!x0.every((x, i) => y0[i] === x)) { return false; }
479
+ return true;
480
+ }
481
+ _equal_3(x0, y0) {
482
+ if (!x0.every((x, i) => y0[i] === x)) { return false; }
483
+ return true;
484
+ }
485
+ _equal_4(x0, y0) {
266
486
  if (!x0.every((x, i) => y0[i] === x)) { return false; }
267
487
  return true;
268
488
  }
@@ -281,6 +501,62 @@ export function ledger(stateOrChargedState) {
281
501
  privateTranscriptOutputs: []
282
502
  };
283
503
  return {
504
+ get state_root() {
505
+ return _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
506
+ partialProofData,
507
+ [
508
+ { dup: { n: 0 } },
509
+ { idx: { cached: false,
510
+ pushPath: false,
511
+ path: [
512
+ { tag: 'value',
513
+ value: { value: _descriptor_6.toValue(0n),
514
+ alignment: _descriptor_6.alignment() } }] } },
515
+ { popeq: { cached: false,
516
+ result: undefined } }]).value);
517
+ },
518
+ get sequence_number() {
519
+ return _descriptor_0.fromValue(__compactRuntime.queryLedgerState(context,
520
+ partialProofData,
521
+ [
522
+ { dup: { n: 0 } },
523
+ { idx: { cached: false,
524
+ pushPath: false,
525
+ path: [
526
+ { tag: 'value',
527
+ value: { value: _descriptor_6.toValue(1n),
528
+ alignment: _descriptor_6.alignment() } }] } },
529
+ { popeq: { cached: false,
530
+ result: undefined } }]).value);
531
+ },
532
+ get total_toll() {
533
+ return _descriptor_0.fromValue(__compactRuntime.queryLedgerState(context,
534
+ partialProofData,
535
+ [
536
+ { dup: { n: 0 } },
537
+ { idx: { cached: false,
538
+ pushPath: false,
539
+ path: [
540
+ { tag: 'value',
541
+ value: { value: _descriptor_6.toValue(2n),
542
+ alignment: _descriptor_6.alignment() } }] } },
543
+ { popeq: { cached: false,
544
+ result: undefined } }]).value);
545
+ },
546
+ get authorized_relayer() {
547
+ return _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
548
+ partialProofData,
549
+ [
550
+ { dup: { n: 0 } },
551
+ { idx: { cached: false,
552
+ pushPath: false,
553
+ path: [
554
+ { tag: 'value',
555
+ value: { value: _descriptor_6.toValue(3n),
556
+ alignment: _descriptor_6.alignment() } }] } },
557
+ { popeq: { cached: false,
558
+ result: undefined } }]).value);
559
+ }
284
560
  };
285
561
  }
286
562
  const _emptyContext = {