@aztec/stdlib 3.0.0-nightly.20251223 → 3.0.0-nightly.20251224

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 (36) hide show
  1. package/dest/contract/contract_class_id.js +1 -1
  2. package/dest/hash/hash.d.ts +1 -9
  3. package/dest/hash/hash.d.ts.map +1 -1
  4. package/dest/hash/hash.js +0 -12
  5. package/dest/interfaces/archiver.d.ts +1 -1
  6. package/dest/interfaces/archiver.d.ts.map +1 -1
  7. package/dest/interfaces/archiver.js +4 -1
  8. package/dest/interfaces/aztec-node.d.ts +10 -10
  9. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  10. package/dest/interfaces/aztec-node.js +3 -3
  11. package/dest/interfaces/l2_logs_source.d.ts +12 -8
  12. package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
  13. package/dest/kernel/private_circuit_public_inputs.d.ts +47 -47
  14. package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
  15. package/dest/kernel/private_circuit_public_inputs.js +59 -59
  16. package/dest/logs/index.d.ts +3 -1
  17. package/dest/logs/index.d.ts.map +1 -1
  18. package/dest/logs/index.js +2 -0
  19. package/dest/logs/siloed_tag.d.ts +23 -0
  20. package/dest/logs/siloed_tag.d.ts.map +1 -0
  21. package/dest/logs/siloed_tag.js +30 -0
  22. package/dest/logs/tag.d.ts +21 -0
  23. package/dest/logs/tag.d.ts.map +1 -0
  24. package/dest/logs/tag.js +30 -0
  25. package/dest/logs/tx_scoped_l2_log.js +1 -1
  26. package/package.json +8 -8
  27. package/src/contract/contract_class_id.ts +1 -1
  28. package/src/hash/hash.ts +0 -11
  29. package/src/interfaces/archiver.ts +8 -2
  30. package/src/interfaces/aztec-node.ts +17 -14
  31. package/src/interfaces/l2_logs_source.ts +12 -7
  32. package/src/kernel/private_circuit_public_inputs.ts +85 -85
  33. package/src/logs/index.ts +2 -0
  34. package/src/logs/siloed_tag.ts +44 -0
  35. package/src/logs/tag.ts +42 -0
  36. package/src/logs/tx_scoped_l2_log.ts +1 -1
@@ -57,6 +57,18 @@ export class PrivateCircuitPublicInputs {
57
57
  * Pedersen hash of the return values of the corresponding function call.
58
58
  */
59
59
  public returnsHash: Fr,
60
+ /**
61
+ * Header of a block whose state is used during private execution (not the block the transaction is included in).
62
+ */
63
+ public anchorBlockHeader: BlockHeader,
64
+ /**
65
+ * Transaction context.
66
+ *
67
+ * Note: The chainId and version in the txContext are not redundant to the values in self.anchor_block_header.global_variables because
68
+ * they can be different in case of a protocol upgrade. In such a situation we could be using header from a block
69
+ * before the upgrade took place but be using the updated protocol to execute and prove the transaction.
70
+ */
71
+ public txContext: TxContext,
60
72
  /**
61
73
  * The side-effect counter under which all side effects are non-revertible.
62
74
  */
@@ -69,6 +81,22 @@ export class PrivateCircuitPublicInputs {
69
81
  * The highest timestamp of a block in which the transaction can still be included.
70
82
  */
71
83
  public includeByTimestamp: UInt64,
84
+ /**
85
+ * The side effect counter at the start of this call.
86
+ */
87
+ public startSideEffectCounter: Fr,
88
+ /**
89
+ * The end side effect counter for this call.
90
+ */
91
+ public endSideEffectCounter: Fr,
92
+ /**
93
+ * The expected non revertible side effect counter for this call.
94
+ */
95
+ public expectedNonRevertibleSideEffectCounter: Fr,
96
+ /**
97
+ * The expected revertible side effect counter for this call.
98
+ */
99
+ public expectedRevertibleSideEffectCounter: Fr,
72
100
  /**
73
101
  * Read requests created by the corresponding function call.
74
102
  */
@@ -84,14 +112,6 @@ export class PrivateCircuitPublicInputs {
84
112
  KeyValidationRequestAndGenerator,
85
113
  typeof MAX_KEY_VALIDATION_REQUESTS_PER_CALL
86
114
  >,
87
- /**
88
- * New note hashes created by the corresponding function call.
89
- */
90
- public noteHashes: ClaimedLengthArray<NoteHash, typeof MAX_NOTE_HASHES_PER_CALL>,
91
- /**
92
- * New nullifiers created by the corresponding function call.
93
- */
94
- public nullifiers: ClaimedLengthArray<Nullifier, typeof MAX_NULLIFIERS_PER_CALL>,
95
115
  /**
96
116
  * Private call requests made within the current kernel iteration.
97
117
  */
@@ -104,6 +124,14 @@ export class PrivateCircuitPublicInputs {
104
124
  * Hash of the public teardown function.
105
125
  */
106
126
  public publicTeardownCallRequest: PublicCallRequest,
127
+ /**
128
+ * New note hashes created by the corresponding function call.
129
+ */
130
+ public noteHashes: ClaimedLengthArray<NoteHash, typeof MAX_NOTE_HASHES_PER_CALL>,
131
+ /**
132
+ * New nullifiers created by the corresponding function call.
133
+ */
134
+ public nullifiers: ClaimedLengthArray<Nullifier, typeof MAX_NULLIFIERS_PER_CALL>,
107
135
  /**
108
136
  * New L2 to L1 messages created by the corresponding function call.
109
137
  */
@@ -116,34 +144,6 @@ export class PrivateCircuitPublicInputs {
116
144
  * Hash of the contract class logs emitted in this function call.
117
145
  */
118
146
  public contractClassLogsHashes: ClaimedLengthArray<CountedLogHash, typeof MAX_CONTRACT_CLASS_LOGS_PER_CALL>,
119
- /**
120
- * The side effect counter at the start of this call.
121
- */
122
- public startSideEffectCounter: Fr,
123
- /**
124
- * The end side effect counter for this call.
125
- */
126
- public endSideEffectCounter: Fr,
127
- /**
128
- * The expected non revertible side effect counter for this call.
129
- */
130
- public expectedNonRevertibleSideEffectCounter: Fr,
131
- /**
132
- * The expected revertible side effect counter for this call.
133
- */
134
- public expectedRevertibleSideEffectCounter: Fr,
135
- /**
136
- * Header of a block whose state is used during private execution (not the block the transaction is included in).
137
- */
138
- public anchorBlockHeader: BlockHeader,
139
- /**
140
- * Transaction context.
141
- *
142
- * Note: The chainId and version in the txContext are not redundant to the values in self.anchor_block_header.global_variables because
143
- * they can be different in case of a protocol upgrade. In such a situation we could be using header from a block
144
- * before the upgrade took place but be using the updated protocol to execute and prove the transaction.
145
- */
146
- public txContext: TxContext,
147
147
  ) {}
148
148
 
149
149
  /**
@@ -166,28 +166,28 @@ export class PrivateCircuitPublicInputs {
166
166
  reader.readObject(CallContext),
167
167
  reader.readObject(Fr),
168
168
  reader.readObject(Fr),
169
+ reader.readObject(BlockHeader),
170
+ reader.readObject(TxContext),
169
171
  reader.readObject(Fr),
170
172
  reader.readBoolean(),
171
173
  reader.readUInt64(),
174
+ reader.readObject(Fr),
175
+ reader.readObject(Fr),
176
+ reader.readObject(Fr),
177
+ reader.readObject(Fr),
172
178
  reader.readObject(ClaimedLengthArrayFromBuffer(ScopedReadRequest, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL)),
173
179
  reader.readObject(ClaimedLengthArrayFromBuffer(ScopedReadRequest, MAX_NULLIFIER_READ_REQUESTS_PER_CALL)),
174
180
  reader.readObject(
175
181
  ClaimedLengthArrayFromBuffer(KeyValidationRequestAndGenerator, MAX_KEY_VALIDATION_REQUESTS_PER_CALL),
176
182
  ),
177
- reader.readObject(ClaimedLengthArrayFromBuffer(NoteHash, MAX_NOTE_HASHES_PER_CALL)),
178
- reader.readObject(ClaimedLengthArrayFromBuffer(Nullifier, MAX_NULLIFIERS_PER_CALL)),
179
183
  reader.readObject(ClaimedLengthArrayFromBuffer(PrivateCallRequest, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL)),
180
184
  reader.readObject(ClaimedLengthArrayFromBuffer(CountedPublicCallRequest, MAX_ENQUEUED_CALLS_PER_CALL)),
181
185
  reader.readObject(PublicCallRequest),
186
+ reader.readObject(ClaimedLengthArrayFromBuffer(NoteHash, MAX_NOTE_HASHES_PER_CALL)),
187
+ reader.readObject(ClaimedLengthArrayFromBuffer(Nullifier, MAX_NULLIFIERS_PER_CALL)),
182
188
  reader.readObject(ClaimedLengthArrayFromBuffer(CountedL2ToL1Message, MAX_L2_TO_L1_MSGS_PER_CALL)),
183
189
  reader.readObject(ClaimedLengthArrayFromBuffer(PrivateLogData, MAX_PRIVATE_LOGS_PER_CALL)),
184
190
  reader.readObject(ClaimedLengthArrayFromBuffer(CountedLogHash, MAX_CONTRACT_CLASS_LOGS_PER_CALL)),
185
- reader.readObject(Fr),
186
- reader.readObject(Fr),
187
- reader.readObject(Fr),
188
- reader.readObject(Fr),
189
- reader.readObject(BlockHeader),
190
- reader.readObject(TxContext),
191
191
  );
192
192
  }
193
193
 
@@ -197,28 +197,28 @@ export class PrivateCircuitPublicInputs {
197
197
  reader.readObject(CallContext),
198
198
  reader.readField(),
199
199
  reader.readField(),
200
+ reader.readObject(BlockHeader),
201
+ reader.readObject(TxContext),
200
202
  reader.readField(),
201
203
  reader.readBoolean(),
202
204
  reader.readU64(),
205
+ reader.readField(),
206
+ reader.readField(),
207
+ reader.readField(),
208
+ reader.readField(),
203
209
  reader.readObject(ClaimedLengthArrayFromFields(ScopedReadRequest, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL)),
204
210
  reader.readObject(ClaimedLengthArrayFromFields(ScopedReadRequest, MAX_NULLIFIER_READ_REQUESTS_PER_CALL)),
205
211
  reader.readObject(
206
212
  ClaimedLengthArrayFromFields(KeyValidationRequestAndGenerator, MAX_KEY_VALIDATION_REQUESTS_PER_CALL),
207
213
  ),
208
- reader.readObject(ClaimedLengthArrayFromFields(NoteHash, MAX_NOTE_HASHES_PER_CALL)),
209
- reader.readObject(ClaimedLengthArrayFromFields(Nullifier, MAX_NULLIFIERS_PER_CALL)),
210
214
  reader.readObject(ClaimedLengthArrayFromFields(PrivateCallRequest, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL)),
211
215
  reader.readObject(ClaimedLengthArrayFromFields(CountedPublicCallRequest, MAX_ENQUEUED_CALLS_PER_CALL)),
212
216
  reader.readObject(PublicCallRequest),
217
+ reader.readObject(ClaimedLengthArrayFromFields(NoteHash, MAX_NOTE_HASHES_PER_CALL)),
218
+ reader.readObject(ClaimedLengthArrayFromFields(Nullifier, MAX_NULLIFIERS_PER_CALL)),
213
219
  reader.readObject(ClaimedLengthArrayFromFields(CountedL2ToL1Message, MAX_L2_TO_L1_MSGS_PER_CALL)),
214
220
  reader.readObject(ClaimedLengthArrayFromFields(PrivateLogData, MAX_PRIVATE_LOGS_PER_CALL)),
215
221
  reader.readObject(ClaimedLengthArrayFromFields(CountedLogHash, MAX_CONTRACT_CLASS_LOGS_PER_CALL)),
216
- reader.readField(),
217
- reader.readField(),
218
- reader.readField(),
219
- reader.readField(),
220
- reader.readObject(BlockHeader),
221
- reader.readObject(TxContext),
222
222
  );
223
223
  }
224
224
 
@@ -231,26 +231,26 @@ export class PrivateCircuitPublicInputs {
231
231
  CallContext.empty(),
232
232
  Fr.ZERO,
233
233
  Fr.ZERO,
234
+ BlockHeader.empty(),
235
+ TxContext.empty(),
234
236
  Fr.ZERO,
235
237
  false,
236
238
  0n,
239
+ Fr.ZERO,
240
+ Fr.ZERO,
241
+ Fr.ZERO,
242
+ Fr.ZERO,
237
243
  ClaimedLengthArray.empty(ScopedReadRequest, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL),
238
244
  ClaimedLengthArray.empty(ScopedReadRequest, MAX_NULLIFIER_READ_REQUESTS_PER_CALL),
239
245
  ClaimedLengthArray.empty(KeyValidationRequestAndGenerator, MAX_KEY_VALIDATION_REQUESTS_PER_CALL),
240
- ClaimedLengthArray.empty(NoteHash, MAX_NOTE_HASHES_PER_CALL),
241
- ClaimedLengthArray.empty(Nullifier, MAX_NULLIFIERS_PER_CALL),
242
246
  ClaimedLengthArray.empty(PrivateCallRequest, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL),
243
247
  ClaimedLengthArray.empty(CountedPublicCallRequest, MAX_ENQUEUED_CALLS_PER_CALL),
244
248
  PublicCallRequest.empty(),
249
+ ClaimedLengthArray.empty(NoteHash, MAX_NOTE_HASHES_PER_CALL),
250
+ ClaimedLengthArray.empty(Nullifier, MAX_NULLIFIERS_PER_CALL),
245
251
  ClaimedLengthArray.empty(CountedL2ToL1Message, MAX_L2_TO_L1_MSGS_PER_CALL),
246
252
  ClaimedLengthArray.empty(PrivateLogData, MAX_PRIVATE_LOGS_PER_CALL),
247
253
  ClaimedLengthArray.empty(CountedLogHash, MAX_CONTRACT_CLASS_LOGS_PER_CALL),
248
- Fr.ZERO,
249
- Fr.ZERO,
250
- Fr.ZERO,
251
- Fr.ZERO,
252
- BlockHeader.empty(),
253
- TxContext.empty(),
254
254
  );
255
255
  }
256
256
 
@@ -259,26 +259,26 @@ export class PrivateCircuitPublicInputs {
259
259
  this.callContext.isEmpty() &&
260
260
  this.argsHash.isZero() &&
261
261
  this.returnsHash.isZero() &&
262
+ this.anchorBlockHeader.isEmpty() &&
263
+ this.txContext.isEmpty() &&
262
264
  this.minRevertibleSideEffectCounter.isZero() &&
263
265
  !this.isFeePayer &&
264
266
  !this.includeByTimestamp &&
267
+ this.startSideEffectCounter.isZero() &&
268
+ this.endSideEffectCounter.isZero() &&
269
+ this.expectedNonRevertibleSideEffectCounter.isZero() &&
270
+ this.expectedRevertibleSideEffectCounter.isZero() &&
265
271
  this.noteHashReadRequests.isEmpty() &&
266
272
  this.nullifierReadRequests.isEmpty() &&
267
273
  this.keyValidationRequestsAndGenerators.isEmpty() &&
268
- this.noteHashes.isEmpty() &&
269
- this.nullifiers.isEmpty() &&
270
274
  this.privateCallRequests.isEmpty() &&
271
275
  this.publicCallRequests.isEmpty() &&
272
276
  this.publicTeardownCallRequest.isEmpty() &&
277
+ this.noteHashes.isEmpty() &&
278
+ this.nullifiers.isEmpty() &&
273
279
  this.l2ToL1Msgs.isEmpty() &&
274
280
  this.privateLogs.isEmpty() &&
275
- this.contractClassLogsHashes.isEmpty() &&
276
- this.startSideEffectCounter.isZero() &&
277
- this.endSideEffectCounter.isZero() &&
278
- this.expectedNonRevertibleSideEffectCounter.isZero() &&
279
- this.expectedRevertibleSideEffectCounter.isZero() &&
280
- this.anchorBlockHeader.isEmpty() &&
281
- this.txContext.isEmpty()
281
+ this.contractClassLogsHashes.isEmpty()
282
282
  );
283
283
  }
284
284
 
@@ -292,26 +292,26 @@ export class PrivateCircuitPublicInputs {
292
292
  fields.callContext,
293
293
  fields.argsHash,
294
294
  fields.returnsHash,
295
+ fields.anchorBlockHeader,
296
+ fields.txContext,
295
297
  fields.minRevertibleSideEffectCounter,
296
298
  fields.isFeePayer,
297
299
  fields.includeByTimestamp,
300
+ fields.startSideEffectCounter,
301
+ fields.endSideEffectCounter,
302
+ fields.expectedNonRevertibleSideEffectCounter,
303
+ fields.expectedRevertibleSideEffectCounter,
298
304
  fields.noteHashReadRequests,
299
305
  fields.nullifierReadRequests,
300
306
  fields.keyValidationRequestsAndGenerators,
301
- fields.noteHashes,
302
- fields.nullifiers,
303
307
  fields.privateCallRequests,
304
308
  fields.publicCallRequests,
305
309
  fields.publicTeardownCallRequest,
310
+ fields.noteHashes,
311
+ fields.nullifiers,
306
312
  fields.l2ToL1Msgs,
307
313
  fields.privateLogs,
308
314
  fields.contractClassLogsHashes,
309
- fields.startSideEffectCounter,
310
- fields.endSideEffectCounter,
311
- fields.expectedNonRevertibleSideEffectCounter,
312
- fields.expectedRevertibleSideEffectCounter,
313
- fields.anchorBlockHeader,
314
- fields.txContext,
315
315
  ] as const;
316
316
  }
317
317
 
@@ -326,26 +326,26 @@ export class PrivateCircuitPublicInputs {
326
326
  this.callContext,
327
327
  this.argsHash,
328
328
  this.returnsHash,
329
+ this.anchorBlockHeader,
330
+ this.txContext,
329
331
  this.minRevertibleSideEffectCounter,
330
332
  this.isFeePayer,
331
333
  bigintToUInt64BE(this.includeByTimestamp),
334
+ this.startSideEffectCounter,
335
+ this.endSideEffectCounter,
336
+ this.expectedNonRevertibleSideEffectCounter,
337
+ this.expectedRevertibleSideEffectCounter,
332
338
  this.noteHashReadRequests,
333
339
  this.nullifierReadRequests,
334
340
  this.keyValidationRequestsAndGenerators,
335
- this.noteHashes,
336
- this.nullifiers,
337
341
  this.privateCallRequests,
338
342
  this.publicCallRequests,
339
343
  this.publicTeardownCallRequest,
344
+ this.noteHashes,
345
+ this.nullifiers,
340
346
  this.l2ToL1Msgs,
341
347
  this.privateLogs,
342
348
  this.contractClassLogsHashes,
343
- this.startSideEffectCounter,
344
- this.endSideEffectCounter,
345
- this.expectedNonRevertibleSideEffectCounter,
346
- this.expectedRevertibleSideEffectCounter,
347
- this.anchorBlockHeader,
348
- this.txContext,
349
349
  ]);
350
350
  }
351
351
 
package/src/logs/index.ts CHANGED
@@ -13,3 +13,5 @@ export * from './shared_secret_derivation.js';
13
13
  export * from './tx_scoped_l2_log.js';
14
14
  export * from './message_context.js';
15
15
  export * from './debug_log.js';
16
+ export * from './tag.js';
17
+ export * from './siloed_tag.js';
@@ -0,0 +1,44 @@
1
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { ZodFor } from '@aztec/foundation/schemas';
4
+
5
+ import type { AztecAddress } from '../aztec-address/index.js';
6
+ import { schemas } from '../schemas/schemas.js';
7
+ import type { Tag } from './tag.js';
8
+
9
+ /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
10
+
11
+ /** Branding to ensure fields are not interchangeable types. */
12
+ export interface SiloedTag {
13
+ /** Brand. */
14
+ _branding: 'SiloedTag';
15
+ }
16
+
17
+ /**
18
+ * Represents a tag used in private log as it "appears on the chain" - that is the tag is siloed with a contract
19
+ * address that emitted the log.
20
+ */
21
+ export class SiloedTag {
22
+ constructor(public readonly value: Fr) {}
23
+
24
+ static async compute(tag: Tag, app: AztecAddress): Promise<SiloedTag> {
25
+ const siloedTag = await poseidon2Hash([app, tag.value]);
26
+ return new SiloedTag(siloedTag);
27
+ }
28
+
29
+ toString(): string {
30
+ return this.value.toString();
31
+ }
32
+
33
+ toJSON(): string {
34
+ return this.value.toString();
35
+ }
36
+
37
+ equals(other: SiloedTag): boolean {
38
+ return this.value.equals(other.value);
39
+ }
40
+
41
+ static get schema(): ZodFor<SiloedTag> {
42
+ return schemas.Fr.transform((fr: Fr) => new SiloedTag(fr));
43
+ }
44
+ }
@@ -0,0 +1,42 @@
1
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { ZodFor } from '@aztec/foundation/schemas';
4
+
5
+ import { schemas } from '../schemas/schemas.js';
6
+ import type { PreTag } from './pre_tag.js';
7
+
8
+ /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
9
+
10
+ export interface Tag {
11
+ /** Brand. */
12
+ _branding: 'Tag';
13
+ }
14
+
15
+ /**
16
+ * Represents a tag of a private log. This is not the tag that "appears" on the chain as this tag is first siloed
17
+ * with a contract address by kernels before being included in the final log.
18
+ */
19
+ export class Tag {
20
+ constructor(public readonly value: Fr) {}
21
+
22
+ static async compute(preTag: PreTag): Promise<Tag> {
23
+ const tag = await poseidon2Hash([preTag.secret.value, preTag.index]);
24
+ return new Tag(tag);
25
+ }
26
+
27
+ toString(): string {
28
+ return this.value.toString();
29
+ }
30
+
31
+ toJSON(): string {
32
+ return this.value.toString();
33
+ }
34
+
35
+ equals(other: Tag): boolean {
36
+ return this.value.equals(other.value);
37
+ }
38
+
39
+ static get schema(): ZodFor<Tag> {
40
+ return schemas.Fr.transform((fr: Fr) => new Tag(fr));
41
+ }
42
+ }
@@ -95,7 +95,7 @@ export class TxScopedL2Log {
95
95
 
96
96
  static async random(isFromPublic = Math.random() < 0.5) {
97
97
  const log = isFromPublic ? await PublicLog.random() : PrivateLog.random();
98
- return new TxScopedL2Log(TxHash.random(), 1, 1, BlockNumber(1), L2BlockHash.random(), BigInt(1), log);
98
+ return new TxScopedL2Log(TxHash.random(), 1, 1, BlockNumber(1), L2BlockHash.random(), 1n, log);
99
99
  }
100
100
 
101
101
  equals(other: TxScopedL2Log) {