@aztec/pxe 0.0.1-commit.96dac018d → 0.0.1-commit.993d52e

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 (61) hide show
  1. package/dest/config/package_info.js +1 -1
  2. package/dest/contract_function_simulator/contract_function_simulator.js +3 -3
  3. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
  4. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  5. package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
  6. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  7. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
  8. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
  9. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -1
  10. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  11. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +18 -10
  12. package/dest/logs/log_service.d.ts +1 -1
  13. package/dest/logs/log_service.d.ts.map +1 -1
  14. package/dest/logs/log_service.js +4 -4
  15. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +3 -4
  16. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  17. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +64 -125
  18. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  19. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  20. package/dest/private_kernel/private_kernel_execution_prover.js +5 -13
  21. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  22. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  23. package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
  24. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  25. package/dest/storage/tagging_store/sender_tagging_store.js +4 -4
  26. package/dest/tagging/index.d.ts +2 -2
  27. package/dest/tagging/index.d.ts.map +1 -1
  28. package/dest/tagging/index.js +1 -1
  29. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
  30. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  31. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +3 -3
  32. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
  33. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  34. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  35. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
  36. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  37. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +3 -6
  38. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -7
  39. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  40. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +14 -15
  41. package/package.json +16 -16
  42. package/src/config/package_info.ts +1 -1
  43. package/src/contract_function_simulator/contract_function_simulator.ts +10 -3
  44. package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
  45. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  46. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  47. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +23 -11
  48. package/src/logs/log_service.ts +10 -5
  49. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +110 -157
  50. package/src/private_kernel/private_kernel_execution_prover.ts +6 -13
  51. package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
  52. package/src/storage/tagging_store/sender_tagging_store.ts +8 -8
  53. package/src/tagging/index.ts +1 -1
  54. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +3 -6
  55. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
  56. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +4 -9
  57. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +11 -20
  58. package/dest/private_kernel/hints/test_utils.d.ts +0 -122
  59. package/dest/private_kernel/hints/test_utils.d.ts.map +0 -1
  60. package/dest/private_kernel/hints/test_utils.js +0 -203
  61. package/src/private_kernel/hints/test_utils.ts +0 -325
@@ -1,32 +1,27 @@
1
1
  import type { BlockNumber } from '@aztec/foundation/branded-types';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
2
  import type { BlockHash } from '@aztec/stdlib/block';
4
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
5
- import type { DirectionalAppTaggingSecret, PreTag, TxScopedL2Log } from '@aztec/stdlib/logs';
6
- import { SiloedTag, Tag } from '@aztec/stdlib/logs';
4
+ import type { ExtendedDirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
5
+ import { SiloedTag } from '@aztec/stdlib/logs';
7
6
 
8
7
  import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
9
8
 
10
9
  /**
11
- * Gets private logs with their corresponding block timestamps and tagging indexes for the given index range, `app` and
12
- * `secret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and `end` is
13
- * exclusive.
10
+ * Gets private logs with their corresponding block timestamps and tagging indexes for the given index range and
11
+ * `extendedSecret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and
12
+ * `end` is exclusive.
14
13
  */
15
14
  export async function loadLogsForRange(
16
- secret: DirectionalAppTaggingSecret,
17
- app: AztecAddress,
15
+ extendedSecret: ExtendedDirectionalAppTaggingSecret,
18
16
  aztecNode: AztecNode,
19
17
  start: number,
20
18
  end: number,
21
19
  anchorBlockNumber: BlockNumber,
22
20
  anchorBlockHash: BlockHash,
23
21
  ): Promise<Array<{ log: TxScopedL2Log; taggingIndex: number }>> {
24
- // Derive tags for the window
25
- const preTags: PreTag[] = Array(end - start)
26
- .fill(0)
27
- .map((_, i) => ({ secret, index: start + i }));
28
- const siloedTags = await Promise.all(preTags.map(preTag => Tag.compute(preTag))).then(tags =>
29
- Promise.all(tags.map(tag => SiloedTag.compute(tag, app))),
22
+ // Derive siloed tags for the window
23
+ const siloedTags = await Promise.all(
24
+ Array.from({ length: end - start }, (_, i) => SiloedTag.compute({ extendedSecret, index: start + i })),
30
25
  );
31
26
 
32
27
  // We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
@@ -37,7 +32,7 @@ export async function loadLogsForRange(
37
32
  const logsWithIndexes: Array<{ log: TxScopedL2Log; taggingIndex: number }> = [];
38
33
  for (let i = 0; i < logs.length; i++) {
39
34
  const logsForTag = logs[i];
40
- const taggingIndex = preTags[i].index;
35
+ const taggingIndex = start + i;
41
36
  for (const log of logsForTag) {
42
37
  if (log.blockNumber <= anchorBlockNumber) {
43
38
  logsWithIndexes.push({ log, taggingIndex });
@@ -1,7 +1,6 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
1
  import type { BlockHash } from '@aztec/stdlib/block';
3
2
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
4
- import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
3
+ import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
5
4
 
6
5
  import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
7
6
  import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
@@ -11,11 +10,8 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
11
10
  /**
12
11
  * Syncs tagging indexes. This function needs to be called whenever a private log is being sent.
13
12
  *
14
- * @param secret - The secret that's unique for (sender, recipient, contract) tuple while the direction of
13
+ * @param secret - The secret that's unique for (sender, recipient, app) tuple while the direction of
15
14
  * sender -> recipient matters.
16
- * @param app - The address of the contract that the logs are tagged for. Needs to be provided because we perform
17
- * second round of siloing in this function which is necessary because kernels do it as well (they silo first field
18
- * of the private log which corresponds to the tag).
19
15
  * @remarks When syncing the indexes as sender we don't care about the log contents - we only care about the highest
20
16
  * pending and highest finalized indexes as that guides the next index choice when sending a log. The next index choice
21
17
  * is simply the highest pending index plus one (or finalized if pending is undefined).
@@ -23,8 +19,7 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
23
19
  * updates its status accordingly.
24
20
  */
25
21
  export async function syncSenderTaggingIndexes(
26
- secret: DirectionalAppTaggingSecret,
27
- app: AztecAddress,
22
+ secret: ExtendedDirectionalAppTaggingSecret,
28
23
  aztecNode: AztecNode,
29
24
  taggingStore: SenderTaggingStore,
30
25
  anchorBlockHash: BlockHash,
@@ -59,7 +54,7 @@ export async function syncSenderTaggingIndexes(
59
54
  while (true) {
60
55
  // Load and store indexes for the current window. These indexes may already exist in the database if txs using
61
56
  // them were previously sent from this PXE. Any duplicates are handled by the tagging data provider.
62
- await loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, anchorBlockHash, jobId);
57
+ await loadAndStoreNewTaggingIndexes(secret, start, end, aztecNode, taggingStore, anchorBlockHash, jobId);
63
58
 
64
59
  // Retrieve all indexes within the current window from storage and update their status accordingly.
65
60
  const pendingTxHashes = await taggingStore.getTxHashesOfPendingIndexes(secret, start, end, jobId);
@@ -1,8 +1,7 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
1
  import type { BlockHash } from '@aztec/stdlib/block';
3
2
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
4
- import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
5
- import { SiloedTag, Tag } from '@aztec/stdlib/logs';
3
+ import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
4
+ import { SiloedTag } from '@aztec/stdlib/logs';
6
5
  import { TxHash } from '@aztec/stdlib/tx';
7
6
 
8
7
  import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_tagging_store.js';
@@ -12,9 +11,7 @@ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
12
11
  * Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
13
12
  * @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
14
13
  * place is when a tx is being sent from this PXE.
15
- * @param secret - The directional app tagging secret that's unique for (sender, recipient, contract) tuple.
16
- * @param app - The address of the contract that the logs are tagged for. Used for siloing tags to match
17
- * kernel circuit behavior.
14
+ * @param extendedSecret - The extended directional app tagging secret that's unique for (sender, recipient, app) tuple.
18
15
  * @param start - The starting index (inclusive) of the window to process.
19
16
  * @param end - The ending index (exclusive) of the window to process.
20
17
  * @param aztecNode - The Aztec node instance to query for logs.
@@ -23,8 +20,7 @@ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
23
20
  * preserving way.
24
21
  */
25
22
  export async function loadAndStoreNewTaggingIndexes(
26
- secret: DirectionalAppTaggingSecret,
27
- app: AztecAddress,
23
+ extendedSecret: ExtendedDirectionalAppTaggingSecret,
28
24
  start: number,
29
25
  end: number,
30
26
  aztecNode: AztecNode,
@@ -33,20 +29,17 @@ export async function loadAndStoreNewTaggingIndexes(
33
29
  jobId: string,
34
30
  ) {
35
31
  // We compute the tags for the current window of indexes
36
- const preTagsForWindow: PreTag[] = Array(end - start)
37
- .fill(0)
38
- .map((_, i) => ({ secret, index: start + i }));
39
32
  const siloedTagsForWindow = await Promise.all(
40
- preTagsForWindow.map(async preTag => SiloedTag.compute(await Tag.compute(preTag), app)),
33
+ Array.from({ length: end - start }, (_, i) => SiloedTag.compute({ extendedSecret, index: start + i })),
41
34
  );
42
35
 
43
36
  const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
44
- const highestIndexMap = getTxHighestIndexMap(txsForTags, preTagsForWindow);
37
+ const highestIndexMap = getTxHighestIndexMap(txsForTags, start, siloedTagsForWindow.length);
45
38
 
46
39
  // Now we iterate over the map, reconstruct the preTags and tx hash and store them in the db.
47
40
  for (const [txHashStr, highestIndex] of highestIndexMap.entries()) {
48
41
  const txHash = TxHash.fromString(txHashStr);
49
- await taggingStore.storePendingIndexes([{ secret, index: highestIndex }], txHash, jobId);
42
+ await taggingStore.storePendingIndexes([{ extendedSecret, index: highestIndex }], txHash, jobId);
50
43
  }
51
44
  }
52
45
 
@@ -64,16 +57,14 @@ async function getTxsContainingTags(
64
57
  }
65
58
 
66
59
  // Returns a map of txHash to the highest index for that txHash.
67
- function getTxHighestIndexMap(txHashesForTags: TxHash[][], preTagsForWindow: PreTag[]): Map<string, number> {
68
- if (txHashesForTags.length !== preTagsForWindow.length) {
69
- throw new Error(
70
- `Number of tx hashes arrays does not match number of pre-tags. ${txHashesForTags.length} !== ${preTagsForWindow.length}`,
71
- );
60
+ function getTxHighestIndexMap(txHashesForTags: TxHash[][], start: number, count: number): Map<string, number> {
61
+ if (txHashesForTags.length !== count) {
62
+ throw new Error(`Number of tx hashes arrays does not match number of tags. ${txHashesForTags.length} !== ${count}`);
72
63
  }
73
64
 
74
65
  const highestIndexMap = new Map<string, number>();
75
66
  for (let i = 0; i < txHashesForTags.length; i++) {
76
- const taggingIndex = preTagsForWindow[i].index;
67
+ const taggingIndex = start + i;
77
68
  const txHashesForTag = txHashesForTags[i];
78
69
  for (const txHash of txHashesForTag) {
79
70
  const key = txHash.toString();
@@ -1,122 +0,0 @@
1
- import { Fr } from '@aztec/foundation/curves/bn254';
2
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import { PrivateCircuitPublicInputs, PrivateKernelCircuitPublicInputs, type PrivateKernelSimulateOutput } from '@aztec/stdlib/kernel';
4
- import { PrivateCallExecutionResult } from '@aztec/stdlib/tx';
5
- /** Builder for PrivateKernelCircuitPublicInputs with fluent API for adding side effects. */
6
- export declare class PrivateKernelCircuitPublicInputsBuilder {
7
- private contractAddress;
8
- private noteHashes;
9
- private nullifiers;
10
- private noteHashReadRequests;
11
- private nullifierReadRequests;
12
- private keyValidationRequests;
13
- private privateLogs;
14
- private nextCounter;
15
- constructor(contractAddress?: AztecAddress, startCounter?: number);
16
- private getCounter;
17
- /** Adds a note hash to the accumulated data. Defaults are generated randomly. */
18
- addNoteHash(opts?: {
19
- value?: Fr;
20
- counter?: number;
21
- contractAddress?: AztecAddress;
22
- }): this;
23
- /** Adds a nullifier to the accumulated data. Defaults are generated randomly. */
24
- addNullifier(opts?: {
25
- value?: Fr;
26
- noteHash?: Fr;
27
- counter?: number;
28
- contractAddress?: AztecAddress;
29
- }): this;
30
- /** Adds a pending note hash read request (non-empty contract address, can match a pending note hash). */
31
- addPendingNoteHashReadRequest(opts?: {
32
- value?: Fr;
33
- counter?: number;
34
- contractAddress?: AztecAddress;
35
- }): this;
36
- /** Adds a settled note hash read request (empty contract address, resolved against the note hash tree). */
37
- addSettledNoteHashReadRequest(opts?: {
38
- value?: Fr;
39
- counter?: number;
40
- }): this;
41
- /** Adds a pending nullifier read request (non-empty contract address, can match a pending nullifier). */
42
- addPendingNullifierReadRequest(opts?: {
43
- value?: Fr;
44
- counter?: number;
45
- contractAddress?: AztecAddress;
46
- }): this;
47
- /** Adds a settled nullifier read request (empty contract address, resolved against the nullifier tree). */
48
- addSettledNullifierReadRequest(opts?: {
49
- value?: Fr;
50
- counter?: number;
51
- }): this;
52
- /** Adds a key validation request to validation requests. */
53
- addKeyValidationRequest(opts?: {
54
- contractAddress?: AztecAddress;
55
- }): this;
56
- /** Adds a private log to the accumulated data. Defaults are generated randomly. */
57
- addPrivateLog(opts?: {
58
- noteHashCounter?: number;
59
- counter?: number;
60
- contractAddress?: AztecAddress;
61
- }): this;
62
- /** Builds the PrivateKernelCircuitPublicInputs with all added side effects. */
63
- build(): PrivateKernelCircuitPublicInputs;
64
- }
65
- /** Builder for PrivateCircuitPublicInputs (call-level) with fluent API for adding side effects. */
66
- export declare class PrivateCircuitPublicInputsBuilder {
67
- private contractAddress;
68
- private noteHashes;
69
- private nullifiers;
70
- private noteHashReadRequests;
71
- private nullifierReadRequests;
72
- private keyValidationRequests;
73
- private privateLogs;
74
- private nextCounter;
75
- constructor(contractAddress?: AztecAddress, startCounter?: number);
76
- private getCounter;
77
- /** Adds a note hash. Defaults are generated randomly. */
78
- addNoteHash(opts?: {
79
- value?: Fr;
80
- counter?: number;
81
- }): this;
82
- /** Adds a nullifier. Defaults are generated randomly. */
83
- addNullifier(opts?: {
84
- value?: Fr;
85
- noteHash?: Fr;
86
- counter?: number;
87
- }): this;
88
- /** Adds a pending note hash read request (non-empty contract address, can match a pending note hash). */
89
- addPendingNoteHashReadRequest(opts?: {
90
- value?: Fr;
91
- counter?: number;
92
- }): this;
93
- /** Adds a settled note hash read request (empty contract address, resolved against the note hash tree). */
94
- addSettledNoteHashReadRequest(opts?: {
95
- value?: Fr;
96
- counter?: number;
97
- }): this;
98
- /** Adds a pending nullifier read request (non-empty contract address, can match a pending nullifier). */
99
- addPendingNullifierReadRequest(opts?: {
100
- value?: Fr;
101
- counter?: number;
102
- }): this;
103
- /** Adds a settled nullifier read request (empty contract address, resolved against the nullifier tree). */
104
- addSettledNullifierReadRequest(opts?: {
105
- value?: Fr;
106
- counter?: number;
107
- }): this;
108
- /** Adds a key validation request. */
109
- addKeyValidationRequest(): this;
110
- /** Adds a private log. Defaults are generated randomly. */
111
- addPrivateLog(opts?: {
112
- noteHashCounter?: number;
113
- counter?: number;
114
- }): this;
115
- /** Builds the PrivateCircuitPublicInputs with all added side effects. */
116
- build(): PrivateCircuitPublicInputs;
117
- }
118
- /** Wraps a PrivateKernelCircuitPublicInputs in a PrivateKernelSimulateOutput. */
119
- export declare function makeKernelOutput(publicInputs?: PrivateKernelCircuitPublicInputs): PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>;
120
- /** Wraps a PrivateCircuitPublicInputs in a PrivateCallExecutionResult. */
121
- export declare function makeExecutionResult(publicInputs?: PrivateCircuitPublicInputs): PrivateCallExecutionResult;
122
- //# sourceMappingURL=data:application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;IAC3G,8BAA8B,CAAC,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAK5E;IAED,qCAAqC;IACrC,uBAAuB,IAAI,IAAI,CAQ9B;IAED,2DAA2D;IAC3D,aAAa,CAAC,IAAI,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAKzE;IAED,yEAAyE;IACzE,KAAK,IAAI,0BAA0B,CAsBlC;CACF;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAC9B,YAAY,CAAC,EAAE,gCAAgC,GAC9C,2BAA2B,CAAC,gCAAgC,CAAC,CAO/D;AAED,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,YAAY,CAAC,EAAE,0BAA0B,GAAG,0BAA0B,CAczG"}
@@ -1,203 +0,0 @@
1
- import { MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_KEY_VALIDATION_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_CALL, MAX_NOTE_HASHES_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_CALL, MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PRIVATE_LOGS_PER_CALL, MAX_PRIVATE_LOGS_PER_TX } from '@aztec/constants';
2
- import { makeTuple } from '@aztec/foundation/array';
3
- import { Fr } from '@aztec/foundation/curves/bn254';
4
- import { Point } from '@aztec/foundation/curves/grumpkin';
5
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
- import { ClaimedLengthArray, KeyValidationRequest, KeyValidationRequestAndSeparator, NoteHash, Nullifier, PrivateCircuitPublicInputs, PrivateKernelCircuitPublicInputs, ReadRequest, ScopedKeyValidationRequestAndSeparator, ScopedNoteHash, ScopedNullifier, ScopedReadRequest } from '@aztec/stdlib/kernel';
7
- import { PrivateLogData, ScopedPrivateLogData } from '@aztec/stdlib/kernel';
8
- import { PrivateLog } from '@aztec/stdlib/logs';
9
- import { PrivateCallExecutionResult } from '@aztec/stdlib/tx';
10
- import { VerificationKeyData } from '@aztec/stdlib/vks';
11
- const DEFAULT_CONTRACT_ADDRESS = AztecAddress.fromBigInt(987654n);
12
- /**
13
- * Builds a ClaimedLengthArray from a list of items, padding to the required size.
14
- */ function makeClaimed(items, emptyFactory, maxSize) {
15
- const padded = makeTuple(maxSize, (i)=>items[i] ?? emptyFactory.empty());
16
- return new ClaimedLengthArray(padded, items.length);
17
- }
18
- /** Builder for PrivateKernelCircuitPublicInputs with fluent API for adding side effects. */ export class PrivateKernelCircuitPublicInputsBuilder {
19
- contractAddress;
20
- noteHashes;
21
- nullifiers;
22
- noteHashReadRequests;
23
- nullifierReadRequests;
24
- keyValidationRequests;
25
- privateLogs;
26
- nextCounter;
27
- constructor(contractAddress = DEFAULT_CONTRACT_ADDRESS, startCounter = 1){
28
- this.contractAddress = contractAddress;
29
- this.noteHashes = [];
30
- this.nullifiers = [];
31
- this.noteHashReadRequests = [];
32
- this.nullifierReadRequests = [];
33
- this.keyValidationRequests = [];
34
- this.privateLogs = [];
35
- this.nextCounter = startCounter;
36
- }
37
- getCounter(sideEffectCounter) {
38
- if (sideEffectCounter !== undefined) {
39
- this.nextCounter = sideEffectCounter + 1;
40
- return sideEffectCounter;
41
- }
42
- return this.nextCounter++;
43
- }
44
- /** Adds a note hash to the accumulated data. Defaults are generated randomly. */ addNoteHash(opts) {
45
- const value = opts?.value ?? Fr.random();
46
- const counter = this.getCounter(opts?.counter);
47
- const addr = opts?.contractAddress ?? this.contractAddress;
48
- this.noteHashes.push(new NoteHash(value, counter).scope(addr));
49
- return this;
50
- }
51
- /** Adds a nullifier to the accumulated data. Defaults are generated randomly. */ addNullifier(opts) {
52
- const value = opts?.value ?? Fr.random();
53
- const noteHash = opts?.noteHash ?? Fr.ZERO;
54
- const counter = this.getCounter(opts?.counter);
55
- const addr = opts?.contractAddress ?? this.contractAddress;
56
- this.nullifiers.push(new Nullifier(value, noteHash, counter).scope(addr));
57
- return this;
58
- }
59
- /** Adds a pending note hash read request (non-empty contract address, can match a pending note hash). */ addPendingNoteHashReadRequest(opts) {
60
- const value = opts?.value ?? Fr.random();
61
- const counter = this.getCounter(opts?.counter);
62
- const addr = opts?.contractAddress ?? this.contractAddress;
63
- this.noteHashReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), addr));
64
- return this;
65
- }
66
- /** Adds a settled note hash read request (empty contract address, resolved against the note hash tree). */ addSettledNoteHashReadRequest(opts) {
67
- const value = opts?.value ?? Fr.random();
68
- const counter = this.getCounter(opts?.counter);
69
- this.noteHashReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), AztecAddress.ZERO));
70
- return this;
71
- }
72
- /** Adds a pending nullifier read request (non-empty contract address, can match a pending nullifier). */ addPendingNullifierReadRequest(opts) {
73
- const value = opts?.value ?? Fr.random();
74
- const counter = this.getCounter(opts?.counter);
75
- const addr = opts?.contractAddress ?? this.contractAddress;
76
- this.nullifierReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), addr));
77
- return this;
78
- }
79
- /** Adds a settled nullifier read request (empty contract address, resolved against the nullifier tree). */ addSettledNullifierReadRequest(opts) {
80
- const value = opts?.value ?? Fr.random();
81
- const counter = this.getCounter(opts?.counter);
82
- this.nullifierReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), AztecAddress.ZERO));
83
- return this;
84
- }
85
- /** Adds a key validation request to validation requests. */ addKeyValidationRequest(opts) {
86
- const addr = opts?.contractAddress ?? this.contractAddress;
87
- this.keyValidationRequests.push(new ScopedKeyValidationRequestAndSeparator(new KeyValidationRequestAndSeparator(new KeyValidationRequest(new Point(Fr.random(), Fr.random(), false), Fr.random()), Fr.random()), addr));
88
- return this;
89
- }
90
- /** Adds a private log to the accumulated data. Defaults are generated randomly. */ addPrivateLog(opts) {
91
- const noteHashCounter = opts?.noteHashCounter ?? 0;
92
- const counter = this.getCounter(opts?.counter);
93
- const addr = opts?.contractAddress ?? this.contractAddress;
94
- this.privateLogs.push(new ScopedPrivateLogData(new PrivateLogData(PrivateLog.empty(), noteHashCounter, counter), addr));
95
- return this;
96
- }
97
- /** Builds the PrivateKernelCircuitPublicInputs with all added side effects. */ build() {
98
- const publicInputs = PrivateKernelCircuitPublicInputs.empty();
99
- publicInputs.end.noteHashes = makeClaimed(this.noteHashes, ScopedNoteHash, MAX_NOTE_HASHES_PER_TX);
100
- publicInputs.end.nullifiers = makeClaimed(this.nullifiers, ScopedNullifier, MAX_NULLIFIERS_PER_TX);
101
- publicInputs.end.privateLogs = makeClaimed(this.privateLogs, ScopedPrivateLogData, MAX_PRIVATE_LOGS_PER_TX);
102
- publicInputs.validationRequests.noteHashReadRequests = makeClaimed(this.noteHashReadRequests, ScopedReadRequest, MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
103
- publicInputs.validationRequests.nullifierReadRequests = makeClaimed(this.nullifierReadRequests, ScopedReadRequest, MAX_NULLIFIER_READ_REQUESTS_PER_TX);
104
- publicInputs.validationRequests.scopedKeyValidationRequestsAndSeparators = makeClaimed(this.keyValidationRequests, ScopedKeyValidationRequestAndSeparator, MAX_KEY_VALIDATION_REQUESTS_PER_TX);
105
- return publicInputs;
106
- }
107
- }
108
- /** Builder for PrivateCircuitPublicInputs (call-level) with fluent API for adding side effects. */ export class PrivateCircuitPublicInputsBuilder {
109
- contractAddress;
110
- noteHashes;
111
- nullifiers;
112
- noteHashReadRequests;
113
- nullifierReadRequests;
114
- keyValidationRequests;
115
- privateLogs;
116
- nextCounter;
117
- constructor(contractAddress = DEFAULT_CONTRACT_ADDRESS, startCounter = 1){
118
- this.contractAddress = contractAddress;
119
- this.noteHashes = [];
120
- this.nullifiers = [];
121
- this.noteHashReadRequests = [];
122
- this.nullifierReadRequests = [];
123
- this.keyValidationRequests = [];
124
- this.privateLogs = [];
125
- this.nextCounter = startCounter;
126
- }
127
- getCounter(sideEffectCounter) {
128
- if (sideEffectCounter !== undefined) {
129
- this.nextCounter = sideEffectCounter + 1;
130
- return sideEffectCounter;
131
- }
132
- return this.nextCounter++;
133
- }
134
- /** Adds a note hash. Defaults are generated randomly. */ addNoteHash(opts) {
135
- const value = opts?.value ?? Fr.random();
136
- const counter = this.getCounter(opts?.counter);
137
- this.noteHashes.push(new NoteHash(value, counter));
138
- return this;
139
- }
140
- /** Adds a nullifier. Defaults are generated randomly. */ addNullifier(opts) {
141
- const value = opts?.value ?? Fr.random();
142
- const noteHash = opts?.noteHash ?? Fr.ZERO;
143
- const counter = this.getCounter(opts?.counter);
144
- this.nullifiers.push(new Nullifier(value, noteHash, counter));
145
- return this;
146
- }
147
- /** Adds a pending note hash read request (non-empty contract address, can match a pending note hash). */ addPendingNoteHashReadRequest(opts) {
148
- const value = opts?.value ?? Fr.random();
149
- const counter = this.getCounter(opts?.counter);
150
- this.noteHashReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), this.contractAddress));
151
- return this;
152
- }
153
- /** Adds a settled note hash read request (empty contract address, resolved against the note hash tree). */ addSettledNoteHashReadRequest(opts) {
154
- const value = opts?.value ?? Fr.random();
155
- const counter = this.getCounter(opts?.counter);
156
- this.noteHashReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), AztecAddress.ZERO));
157
- return this;
158
- }
159
- /** Adds a pending nullifier read request (non-empty contract address, can match a pending nullifier). */ addPendingNullifierReadRequest(opts) {
160
- const value = opts?.value ?? Fr.random();
161
- const counter = this.getCounter(opts?.counter);
162
- this.nullifierReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), this.contractAddress));
163
- return this;
164
- }
165
- /** Adds a settled nullifier read request (empty contract address, resolved against the nullifier tree). */ addSettledNullifierReadRequest(opts) {
166
- const value = opts?.value ?? Fr.random();
167
- const counter = this.getCounter(opts?.counter);
168
- this.nullifierReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), AztecAddress.ZERO));
169
- return this;
170
- }
171
- /** Adds a key validation request. */ addKeyValidationRequest() {
172
- this.keyValidationRequests.push(new KeyValidationRequestAndSeparator(new KeyValidationRequest(new Point(Fr.random(), Fr.random(), false), Fr.random()), Fr.random()));
173
- return this;
174
- }
175
- /** Adds a private log. Defaults are generated randomly. */ addPrivateLog(opts) {
176
- const noteHashCounter = opts?.noteHashCounter ?? 0;
177
- const counter = this.getCounter(opts?.counter);
178
- this.privateLogs.push(new PrivateLogData(PrivateLog.empty(), noteHashCounter, counter));
179
- return this;
180
- }
181
- /** Builds the PrivateCircuitPublicInputs with all added side effects. */ build() {
182
- const publicInputs = PrivateCircuitPublicInputs.empty();
183
- publicInputs.callContext.contractAddress = this.contractAddress;
184
- publicInputs.noteHashes = makeClaimed(this.noteHashes, NoteHash, MAX_NOTE_HASHES_PER_CALL);
185
- publicInputs.nullifiers = makeClaimed(this.nullifiers, Nullifier, MAX_NULLIFIERS_PER_CALL);
186
- publicInputs.privateLogs = makeClaimed(this.privateLogs, PrivateLogData, MAX_PRIVATE_LOGS_PER_CALL);
187
- publicInputs.noteHashReadRequests = makeClaimed(this.noteHashReadRequests, ScopedReadRequest, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL);
188
- publicInputs.nullifierReadRequests = makeClaimed(this.nullifierReadRequests, ScopedReadRequest, MAX_NULLIFIER_READ_REQUESTS_PER_CALL);
189
- publicInputs.keyValidationRequestsAndSeparators = makeClaimed(this.keyValidationRequests, KeyValidationRequestAndSeparator, MAX_KEY_VALIDATION_REQUESTS_PER_CALL);
190
- return publicInputs;
191
- }
192
- }
193
- /** Wraps a PrivateKernelCircuitPublicInputs in a PrivateKernelSimulateOutput. */ export function makeKernelOutput(publicInputs) {
194
- return {
195
- publicInputs: publicInputs ?? PrivateKernelCircuitPublicInputs.empty(),
196
- verificationKey: VerificationKeyData.empty(),
197
- outputWitness: new Map(),
198
- bytecode: Buffer.from([])
199
- };
200
- }
201
- /** Wraps a PrivateCircuitPublicInputs in a PrivateCallExecutionResult. */ export function makeExecutionResult(publicInputs) {
202
- return new PrivateCallExecutionResult(Buffer.alloc(0), Buffer.alloc(0), new Map(), publicInputs ?? PrivateCircuitPublicInputs.empty(), [], new Map(), [], [], [], [], []);
203
- }