@aztec/pxe 0.0.1-commit.c7c42ec → 0.0.1-commit.c949de6bc
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.
- package/dest/access_scopes.d.ts +9 -0
- package/dest/access_scopes.d.ts.map +1 -0
- package/dest/access_scopes.js +6 -0
- package/dest/bin/check_oracle_version.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +13 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +74 -20
- package/dest/config/index.d.ts +3 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +17 -0
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +57 -34
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +199 -81
- package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +45 -28
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
- package/dest/contract_function_simulator/index.d.ts +2 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +2 -2
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +17 -13
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts +12 -10
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +67 -44
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +1 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +45 -47
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +91 -60
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +67 -33
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +131 -110
- package/dest/contract_logging.d.ts +22 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +23 -0
- package/dest/contract_sync/contract_sync_service.d.ts +43 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +97 -0
- package/dest/contract_sync/helpers.d.ts +29 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/helpers.js +55 -0
- package/dest/debug/pxe_debug_utils.d.ts +24 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +28 -17
- package/dest/entrypoints/client/bundle/index.d.ts +4 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +31 -8
- package/dest/entrypoints/client/lazy/index.d.ts +4 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +32 -9
- package/dest/entrypoints/pxe_creation_options.d.ts +5 -3
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +5 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +39 -16
- package/dest/events/event_service.d.ts +6 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +19 -22
- package/dest/events/private_event_filter_validator.d.ts +5 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +5 -6
- package/dest/job_coordinator/job_coordinator.d.ts +75 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +94 -0
- package/dest/logs/log_service.d.ts +8 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +31 -33
- package/dest/notes/note_service.d.ts +10 -9
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +34 -38
- package/dest/notes_filter.d.ts +25 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +4 -3
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +3 -3
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +2 -2
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +29 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +141 -74
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +24 -17
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -24
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +94 -2
- package/dest/pxe.d.ts +76 -58
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +151 -136
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +12 -11
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
- package/dest/storage/capsule_store/capsule_store.d.ts +24 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +130 -23
- package/dest/storage/contract_store/contract_store.d.ts +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +157 -72
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +50 -51
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +284 -263
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +47 -7
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +231 -73
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +16 -9
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +88 -19
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +20 -10
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +254 -102
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +10 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +60 -0
- package/dest/tagging/index.d.ts +4 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +3 -11
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +13 -13
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +7 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +16 -12
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +9 -12
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +5 -8
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +7 -7
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +23 -19
- package/package.json +27 -18
- package/src/access_scopes.ts +9 -0
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +93 -32
- package/src/config/index.ts +14 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +353 -140
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
- package/src/contract_function_simulator/index.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +6 -2
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +22 -12
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +79 -47
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -69
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +131 -140
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +198 -115
- package/src/contract_logging.ts +39 -0
- package/src/contract_sync/contract_sync_service.ts +152 -0
- package/src/contract_sync/helpers.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +63 -18
- package/src/entrypoints/client/bundle/index.ts +3 -0
- package/src/entrypoints/client/bundle/utils.ts +23 -16
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/client/lazy/utils.ts +24 -17
- package/src/entrypoints/pxe_creation_options.ts +4 -2
- package/src/entrypoints/server/index.ts +4 -0
- package/src/entrypoints/server/utils.ts +33 -41
- package/src/events/event_service.ts +19 -25
- package/src/events/private_event_filter_validator.ts +3 -5
- package/src/job_coordinator/job_coordinator.ts +150 -0
- package/src/logs/log_service.ts +51 -40
- package/src/notes/note_service.ts +41 -45
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +4 -3
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +2 -2
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +196 -138
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +27 -19
- package/src/private_kernel/private_kernel_oracle.ts +116 -36
- package/src/pxe.ts +283 -202
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
- package/src/storage/capsule_store/capsule_store.ts +159 -23
- package/src/storage/contract_store/contract_store.ts +186 -76
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +326 -320
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +301 -79
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +111 -21
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +297 -112
- package/src/tagging/constants.ts +10 -0
- package/src/tagging/get_all_logs_by_tags.ts +92 -0
- package/src/tagging/index.ts +3 -12
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +27 -16
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +17 -16
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +13 -15
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -13
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +26 -23
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
- package/dest/public_storage/public_storage_service.d.ts +0 -24
- package/dest/public_storage/public_storage_service.d.ts.map +0 -1
- package/dest/public_storage/public_storage_service.js +0 -26
- package/dest/tree_membership/tree_membership_service.d.ts +0 -52
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -84
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/tree_membership/tree_membership_service.ts +0 -112
|
@@ -0,0 +1,203 @@
|
|
|
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
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LoggerBindings } from '@aztec/foundation/log';
|
|
1
2
|
import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
2
3
|
import { type PrivateKernelExecutionProofOutput, type PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
3
4
|
import { type PrivateExecutionResult, TxRequest } from '@aztec/stdlib/tx';
|
|
@@ -18,7 +19,7 @@ export declare class PrivateKernelExecutionProver {
|
|
|
18
19
|
private proofCreator;
|
|
19
20
|
private fakeProofs;
|
|
20
21
|
private log;
|
|
21
|
-
constructor(oracle: PrivateKernelOracle, proofCreator: PrivateKernelProver, fakeProofs?: boolean);
|
|
22
|
+
constructor(oracle: PrivateKernelOracle, proofCreator: PrivateKernelProver, fakeProofs?: boolean, bindings?: LoggerBindings);
|
|
22
23
|
/**
|
|
23
24
|
* Generate a proof for a given transaction request and execution result.
|
|
24
25
|
* The function iterates through the nested executions in the execution result, creates private call data,
|
|
@@ -41,4 +42,4 @@ export declare class PrivateKernelExecutionProver {
|
|
|
41
42
|
private getVkData;
|
|
42
43
|
private createPrivateCallData;
|
|
43
44
|
}
|
|
44
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
45
|
+
//# sourceM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FRLEVBQzFCLFFBQVEsQ0FBQyxFQUFFLGNBQWMsRUFHMUI7SUFFRDs7Ozs7Ozs7OztPQVVHO0lBQ0csZ0JBQWdCLENBQ3BCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLGVBQWUsRUFBRSxzQkFBc0IsRUFDdkMsRUFBRSxRQUFRLEVBQUUsa0JBQWtCLEVBQUUsV0FBVyxFQUFFLEdBQUUsa0NBSTlDLEdBQ0EsT0FBTyxDQUFDLGlDQUFpQyxDQUFDLG9DQUFvQyxDQUFDLENBQUMsQ0EyUmxGO0lBRUQ7Ozs7O09BS0c7SUFDSCxPQUFPLENBQUMsdUJBQXVCO1lBb0JqQixTQUFTO1lBU1QscUJBQXFCO0NBK0JwQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_kernel_execution_prover.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_execution_prover.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"private_kernel_execution_prover.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_execution_prover.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAMvF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAQL,KAAK,iCAAiC,EAKtC,KAAK,oCAAoC,EAE1C,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,KAAK,sBAAsB,EAC3B,SAAS,EAGV,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAStE,MAAM,WAAW,kCAAkC;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,GAAG,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;CAC5D;AAED;;;;;GAKG;AACH,qBAAa,4BAA4B;IAIrC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,UAAU;IALpB,OAAO,CAAC,GAAG,CAAS;IAEpB,YACU,MAAM,EAAE,mBAAmB,EAC3B,YAAY,EAAE,mBAAmB,EACjC,UAAU,UAAQ,EAC1B,QAAQ,CAAC,EAAE,cAAc,EAG1B;IAED;;;;;;;;;;OAUG;IACG,gBAAgB,CACpB,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,sBAAsB,EACvC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAE,kCAI9C,GACA,OAAO,CAAC,iCAAiC,CAAC,oCAAoC,CAAC,CAAC,CA2RlF;IAED;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;YAoBjB,SAAS;YAST,qBAAqB;CA+BpC"}
|
|
@@ -8,9 +8,9 @@ import { ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
|
8
8
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
9
|
import { HidingKernelToPublicPrivateInputs, HidingKernelToRollupPrivateInputs, PaddedSideEffectAmounts, PrivateCallData, PrivateKernelCircuitPublicInputs, PrivateKernelData, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelTailCircuitPrivateInputs, PrivateVerificationKeyHints } from '@aztec/stdlib/kernel';
|
|
10
10
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
11
|
-
import {
|
|
11
|
+
import { collectNoteHashNullifierCounterMap, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
|
|
12
12
|
import { VerificationKeyAsFields, VerificationKeyData, VkData } from '@aztec/stdlib/vks';
|
|
13
|
-
import { PrivateKernelResetPrivateInputsBuilder } from './hints/
|
|
13
|
+
import { PrivateKernelResetPrivateInputsBuilder } from './hints/private_kernel_reset_private_inputs_builder.js';
|
|
14
14
|
const NULL_SIMULATE_OUTPUT = {
|
|
15
15
|
publicInputs: PrivateKernelCircuitPublicInputs.empty(),
|
|
16
16
|
verificationKey: VerificationKeyData.empty(),
|
|
@@ -27,11 +27,11 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
27
27
|
proofCreator;
|
|
28
28
|
fakeProofs;
|
|
29
29
|
log;
|
|
30
|
-
constructor(oracle, proofCreator, fakeProofs = false){
|
|
30
|
+
constructor(oracle, proofCreator, fakeProofs = false, bindings){
|
|
31
31
|
this.oracle = oracle;
|
|
32
32
|
this.proofCreator = proofCreator;
|
|
33
33
|
this.fakeProofs = fakeProofs;
|
|
34
|
-
this.log = createLogger('pxe:private-kernel-execution-prover');
|
|
34
|
+
this.log = createLogger('pxe:private-kernel-execution-prover', bindings);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Generate a proof for a given transaction request and execution result.
|
|
@@ -60,7 +60,6 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
60
60
|
let firstIteration = true;
|
|
61
61
|
let output = NULL_SIMULATE_OUTPUT;
|
|
62
62
|
const executionSteps = [];
|
|
63
|
-
const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
|
|
64
63
|
const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
|
|
65
64
|
const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(executionResult);
|
|
66
65
|
const splitCounter = isPrivateOnlyTx ? 0 : minRevertibleSideEffectCounter;
|
|
@@ -68,8 +67,9 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
68
67
|
if (!firstIteration) {
|
|
69
68
|
let resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, executionStack, noteHashNullifierCounterMap, splitCounter);
|
|
70
69
|
while(resetBuilder.needsReset()){
|
|
70
|
+
// Inner reset: without siloing.
|
|
71
71
|
const witgenTimer = new Timer();
|
|
72
|
-
const privateInputs = await resetBuilder.build(this.oracle
|
|
72
|
+
const privateInputs = await resetBuilder.build(this.oracle);
|
|
73
73
|
output = generateWitnesses ? await this.proofCreator.generateResetOutput(privateInputs) : await this.proofCreator.simulateReset(privateInputs);
|
|
74
74
|
executionSteps.push({
|
|
75
75
|
functionName: 'private_kernel_reset',
|
|
@@ -133,11 +133,19 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
133
133
|
}
|
|
134
134
|
firstIteration = false;
|
|
135
135
|
}
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
// Final reset: include siloing of note hashes, nullifiers and private logs.
|
|
137
|
+
const finalResetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, splitCounter);
|
|
138
|
+
if (!finalResetBuilder.needsReset()) {
|
|
139
|
+
// The final reset must be performed exactly once, because each tx has at least one nullifier that requires
|
|
140
|
+
// siloing, and siloing cannot be done multiple times.
|
|
141
|
+
// While, in theory, it might be possible to silo note hashes first and then run another reset to silo nullifiers
|
|
142
|
+
// and/or private logs, we currently don't have standalone dimensions for the arrays that require siloing. As a
|
|
143
|
+
// result, all necessary siloing must be done together in a single reset.
|
|
144
|
+
// Refer to the possible combinations of dimensions in private_kernel_reset_config.json.
|
|
145
|
+
throw new Error('Nothing to reset for the final reset.');
|
|
146
|
+
} else {
|
|
139
147
|
const witgenTimer = new Timer();
|
|
140
|
-
const privateInputs = await
|
|
148
|
+
const privateInputs = await finalResetBuilder.build(this.oracle);
|
|
141
149
|
output = generateWitnesses ? await this.proofCreator.generateResetOutput(privateInputs) : await this.proofCreator.simulateReset(privateInputs);
|
|
142
150
|
executionSteps.push({
|
|
143
151
|
functionName: 'private_kernel_reset',
|
|
@@ -148,7 +156,6 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
148
156
|
witgen: witgenTimer.ms()
|
|
149
157
|
}
|
|
150
158
|
});
|
|
151
|
-
resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, splitCounter);
|
|
152
159
|
}
|
|
153
160
|
if (output.publicInputs.feePayer.isZero() && skipFeeEnforcement) {
|
|
154
161
|
if (!skipProofGeneration) {
|
|
@@ -162,14 +169,14 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
162
169
|
this.log.debug(`Calling private kernel tail with hwm ${previousKernelData.publicInputs.minRevertibleSideEffectCounter}`);
|
|
163
170
|
// TODO: Enable padding once we better understand the final amounts to pad to.
|
|
164
171
|
const paddedSideEffectAmounts = PaddedSideEffectAmounts.empty();
|
|
165
|
-
// Use the aggregated
|
|
166
|
-
// TODO: Call `
|
|
167
|
-
const
|
|
172
|
+
// Use the aggregated expirationTimestamp set throughout the tx execution.
|
|
173
|
+
// TODO: Call `computeTxExpirationTimestamp` to round the value down and reduce precision, improving privacy.
|
|
174
|
+
const expirationTimestampUpperBound = previousKernelData.publicInputs.expirationTimestamp;
|
|
168
175
|
const anchorBlockTimestamp = previousKernelData.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp;
|
|
169
|
-
if (
|
|
170
|
-
throw new Error(`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${
|
|
176
|
+
if (expirationTimestampUpperBound <= anchorBlockTimestamp) {
|
|
177
|
+
throw new Error(`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${expirationTimestampUpperBound}.`);
|
|
171
178
|
}
|
|
172
|
-
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(previousKernelData, paddedSideEffectAmounts,
|
|
179
|
+
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(previousKernelData, paddedSideEffectAmounts, expirationTimestampUpperBound);
|
|
173
180
|
const witgenTimer = new Timer();
|
|
174
181
|
const tailOutput = generateWitnesses ? await this.proofCreator.generateTailOutput(privateInputs) : await this.proofCreator.simulateTail(privateInputs);
|
|
175
182
|
executionSteps.push({
|
|
@@ -2,62 +2,62 @@ import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, VK_TREE_HEIGHT } from '@az
|
|
|
2
2
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
|
|
4
4
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
|
+
import type { KeyStore } from '@aztec/key-store';
|
|
5
6
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
6
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
9
|
+
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
10
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
7
11
|
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
8
|
-
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
9
12
|
import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
|
|
10
13
|
import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
|
|
14
|
+
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
11
15
|
/**
|
|
12
16
|
* Provides functionality needed by the private kernel for interacting with our state trees.
|
|
13
|
-
* This is either PrivateKernelOracleImpl, or a mocked test implementation.
|
|
14
17
|
*/
|
|
15
|
-
export
|
|
18
|
+
export declare class PrivateKernelOracle {
|
|
19
|
+
private contractStore;
|
|
20
|
+
private keyStore;
|
|
21
|
+
private node;
|
|
22
|
+
private blockHash;
|
|
23
|
+
constructor(contractStore: ContractStore, keyStore: KeyStore, node: AztecNode, blockHash: BlockHash);
|
|
16
24
|
/** Retrieves the preimage of a contract address from the registered contract instances db. */
|
|
17
|
-
getContractAddressPreimage(address: AztecAddress): Promise<{
|
|
25
|
+
getContractAddressPreimage(address: AztecAddress): Promise<ContractInstanceWithAddress & {
|
|
18
26
|
saltedInitializationHash: Fr;
|
|
19
|
-
publicKeys: PublicKeys;
|
|
20
|
-
currentContractClassId: Fr;
|
|
21
|
-
originalContractClassId: Fr;
|
|
22
27
|
}>;
|
|
23
28
|
/** Retrieves the preimage of a contract class id from the contract classes db. */
|
|
24
29
|
getContractClassIdPreimage(contractClassId: Fr): Promise<{
|
|
25
30
|
artifactHash: Fr;
|
|
26
|
-
publicBytecodeCommitment: Fr;
|
|
27
31
|
privateFunctionsRoot: Fr;
|
|
32
|
+
publicBytecodeCommitment: Fr;
|
|
28
33
|
}>;
|
|
29
|
-
/**
|
|
30
|
-
* Returns a membership witness with the sibling path and leaf index in our private functions tree.
|
|
31
|
-
*/
|
|
34
|
+
/** Returns a membership witness with the sibling path and leaf index in our private functions tree. */
|
|
32
35
|
getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>>;
|
|
33
36
|
/**
|
|
34
37
|
* Returns a membership witness with the sibling path and leaf index in our protocol VK indexed merkle tree.
|
|
35
38
|
* Used to validate the previous kernel's verification key.
|
|
36
39
|
*/
|
|
37
40
|
getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<typeof VK_TREE_HEIGHT>>;
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree.
|
|
43
|
-
*/
|
|
41
|
+
/** Returns a membership witness with the sibling path and leaf index in our note hash tree. */
|
|
42
|
+
getNoteHashMembershipWitness(noteHash: Fr): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
|
|
43
|
+
/** Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree. */
|
|
44
44
|
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
|
|
45
|
-
/**
|
|
46
|
-
* Returns the root of our note hash merkle tree.
|
|
47
|
-
*/
|
|
45
|
+
/** Returns the root of our note hash merkle tree. */
|
|
48
46
|
getNoteHashTreeRoot(): Promise<Fr>;
|
|
49
47
|
/**
|
|
50
48
|
* Retrieves the sk_m corresponding to the pk_m.
|
|
51
49
|
* @throws If the provided public key is not associated with any of the registered accounts.
|
|
52
|
-
* @param
|
|
50
|
+
* @param masterPublicKey - The master public key to get secret key for.
|
|
53
51
|
* @returns A Promise that resolves to sk_m.
|
|
54
52
|
* @dev Used when feeding the sk_m to the kernel circuit for keys verification.
|
|
55
53
|
*/
|
|
56
54
|
getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar>;
|
|
57
55
|
/** Use debug data to get the function name corresponding to a selector. */
|
|
58
56
|
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
57
|
+
/**
|
|
58
|
+
* Returns a membership witness and leaf index to our public data indexed merkle tree,
|
|
59
|
+
* along with an associated DelayedPublicMutable containing the class ID to update.
|
|
60
|
+
*/
|
|
61
61
|
getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
|
|
62
62
|
}
|
|
63
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
63
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9rZXJuZWxfb3JhY2xlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHJpdmF0ZV9rZXJuZWwvcHJpdmF0ZV9rZXJuZWxfb3JhY2xlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxxQkFBcUIsRUFBMkIsY0FBYyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDeEgsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLEtBQUssRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBQy9FLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLHlCQ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UFlLEVBQUUsWUFBWSxHQUFHLE9BQU8sQ0FBQyxtQkFBbUIsQ0FBQyxDQThCL0Y7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_kernel_oracle.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_oracle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"private_kernel_oracle.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_oracle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAA2B,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACxH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,KAAK,2BAA2B,EAAmC,MAAM,wBAAwB,CAAC;AAG3G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEjF;;GAEG;AACH,qBAAa,mBAAmB;IAE5B,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,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA8B/F;CACF"}
|
|
@@ -1,4 +1,96 @@
|
|
|
1
|
+
import { PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
3
|
+
import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
4
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
|
+
import { computeSaltedInitializationHash } from '@aztec/stdlib/contract';
|
|
6
|
+
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
7
|
+
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
8
|
+
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
1
9
|
/**
|
|
2
10
|
* Provides functionality needed by the private kernel for interacting with our state trees.
|
|
3
|
-
|
|
4
|
-
|
|
11
|
+
*/ export class PrivateKernelOracle {
|
|
12
|
+
contractStore;
|
|
13
|
+
keyStore;
|
|
14
|
+
node;
|
|
15
|
+
blockHash;
|
|
16
|
+
constructor(contractStore, keyStore, node, blockHash){
|
|
17
|
+
this.contractStore = contractStore;
|
|
18
|
+
this.keyStore = keyStore;
|
|
19
|
+
this.node = node;
|
|
20
|
+
this.blockHash = blockHash;
|
|
21
|
+
}
|
|
22
|
+
/** Retrieves the preimage of a contract address from the registered contract instances db. */ async getContractAddressPreimage(address) {
|
|
23
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
24
|
+
if (!instance) {
|
|
25
|
+
throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
saltedInitializationHash: await computeSaltedInitializationHash(instance),
|
|
29
|
+
...instance
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Retrieves the preimage of a contract class id from the contract classes db. */ async getContractClassIdPreimage(contractClassId) {
|
|
33
|
+
const contractClass = await this.contractStore.getContractClassWithPreimage(contractClassId);
|
|
34
|
+
if (!contractClass) {
|
|
35
|
+
throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
artifactHash: contractClass.artifactHash,
|
|
39
|
+
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
40
|
+
publicBytecodeCommitment: contractClass.publicBytecodeCommitment
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Returns a membership witness with the sibling path and leaf index in our private functions tree. */ async getFunctionMembershipWitness(contractClassId, selector) {
|
|
44
|
+
const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
|
|
45
|
+
if (!membershipWitness) {
|
|
46
|
+
throw new Error(`Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`);
|
|
47
|
+
}
|
|
48
|
+
return membershipWitness;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns a membership witness with the sibling path and leaf index in our protocol VK indexed merkle tree.
|
|
52
|
+
* Used to validate the previous kernel's verification key.
|
|
53
|
+
*/ getVkMembershipWitness(vk) {
|
|
54
|
+
const leafIndex = getVKIndex(vk);
|
|
55
|
+
return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
|
|
56
|
+
}
|
|
57
|
+
/** Returns a membership witness with the sibling path and leaf index in our note hash tree. */ getNoteHashMembershipWitness(noteHash) {
|
|
58
|
+
return this.node.getNoteHashMembershipWitness(this.blockHash, noteHash);
|
|
59
|
+
}
|
|
60
|
+
/** Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree. */ getNullifierMembershipWitness(nullifier) {
|
|
61
|
+
return this.node.getNullifierMembershipWitness(this.blockHash, nullifier);
|
|
62
|
+
}
|
|
63
|
+
/** Returns the root of our note hash merkle tree. */ async getNoteHashTreeRoot() {
|
|
64
|
+
const header = await this.node.getBlockHeader(this.blockHash);
|
|
65
|
+
if (!header) {
|
|
66
|
+
throw new Error(`No block header found for block hash ${this.blockHash}`);
|
|
67
|
+
}
|
|
68
|
+
return header.state.partial.noteHashTree.root;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves the sk_m corresponding to the pk_m.
|
|
72
|
+
* @throws If the provided public key is not associated with any of the registered accounts.
|
|
73
|
+
* @param masterPublicKey - The master public key to get secret key for.
|
|
74
|
+
* @returns A Promise that resolves to sk_m.
|
|
75
|
+
* @dev Used when feeding the sk_m to the kernel circuit for keys verification.
|
|
76
|
+
*/ getMasterSecretKey(masterPublicKey) {
|
|
77
|
+
return this.keyStore.getMasterSecretKey(masterPublicKey);
|
|
78
|
+
}
|
|
79
|
+
/** Use debug data to get the function name corresponding to a selector. */ getDebugFunctionName(contractAddress, selector) {
|
|
80
|
+
return this.contractStore.getDebugFunctionName(contractAddress, selector);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns a membership witness and leaf index to our public data indexed merkle tree,
|
|
84
|
+
* along with an associated DelayedPublicMutable containing the class ID to update.
|
|
85
|
+
*/ async getUpdatedClassIdHints(contractAddress) {
|
|
86
|
+
const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
87
|
+
const hashLeafSlot = await computePublicDataTreeLeafSlot(ProtocolContractAddress.ContractInstanceRegistry, delayedPublicMutableHashSlot);
|
|
88
|
+
const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockHash, hashLeafSlot);
|
|
89
|
+
if (!updatedClassIdWitness) {
|
|
90
|
+
throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
|
|
91
|
+
}
|
|
92
|
+
const readStorage = (storageSlot)=>this.node.getPublicStorageAt(this.blockHash, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
|
|
93
|
+
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, readStorage);
|
|
94
|
+
return new UpdatedClassIdHints(new MembershipWitness(PUBLIC_DATA_TREE_HEIGHT, updatedClassIdWitness.index, updatedClassIdWitness.siblingPath.toTuple()), updatedClassIdWitness.leafPreimage, delayedPublicMutableValues);
|
|
95
|
+
}
|
|
96
|
+
}
|