@aztec/pxe 4.0.0-nightly.20260113 → 4.0.0-nightly.20260114

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 (42) hide show
  1. package/dest/contract_function_simulator/oracle/interfaces.d.ts +3 -3
  2. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  3. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +4 -4
  4. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  5. package/dest/contract_function_simulator/oracle/note_packing_utils.js +5 -5
  6. package/dest/contract_function_simulator/oracle/oracle.js +1 -1
  7. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -1
  8. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  9. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +2 -1
  10. package/dest/events/event_service.d.ts +1 -1
  11. package/dest/events/event_service.d.ts.map +1 -1
  12. package/dest/events/event_service.js +8 -12
  13. package/dest/notes/note_service.d.ts +2 -2
  14. package/dest/notes/note_service.d.ts.map +1 -1
  15. package/dest/notes/note_service.js +14 -22
  16. package/dest/private_kernel/private_kernel_oracle.d.ts +23 -28
  17. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  18. package/dest/private_kernel/private_kernel_oracle.js +92 -2
  19. package/dest/pxe.d.ts +7 -36
  20. package/dest/pxe.d.ts.map +1 -1
  21. package/dest/pxe.js +8 -58
  22. package/dest/storage/note_store/note_store.d.ts +3 -4
  23. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  24. package/dest/storage/note_store/note_store.js +63 -70
  25. package/dest/storage/private_event_store/private_event_store.d.ts +10 -5
  26. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  27. package/dest/storage/private_event_store/private_event_store.js +55 -41
  28. package/package.json +16 -16
  29. package/src/contract_function_simulator/oracle/interfaces.ts +2 -2
  30. package/src/contract_function_simulator/oracle/note_packing_utils.ts +6 -6
  31. package/src/contract_function_simulator/oracle/oracle.ts +1 -1
  32. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +1 -0
  33. package/src/events/event_service.ts +12 -26
  34. package/src/notes/note_service.ts +14 -23
  35. package/src/private_kernel/private_kernel_oracle.ts +119 -37
  36. package/src/pxe.ts +8 -81
  37. package/src/storage/note_store/note_store.ts +66 -65
  38. package/src/storage/private_event_store/private_event_store.ts +72 -45
  39. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
  40. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
  41. package/dest/private_kernel/private_kernel_oracle_impl.js +0 -85
  42. package/src/private_kernel/private_kernel_oracle_impl.ts +0 -127
@@ -1 +0,0 @@
1
- {"version":3,"file":"private_kernel_oracle_impl.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_oracle_impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAA2C,MAAM,kBAAkB,CAAC;AAClG,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAE/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,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,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,uB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IC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
2
- import { createLogger } from '@aztec/foundation/log';
3
- import { MembershipWitness } from '@aztec/foundation/trees';
4
- import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
5
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
6
- import { computeContractClassIdPreimage, computeSaltedInitializationHash } from '@aztec/stdlib/contract';
7
- import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
8
- import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
9
- import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
10
- // TODO: Block number should not be "latest".
11
- // It should be fixed at the time the proof is being simulated. I.e., it should be the same as the value defined in the constant data.
12
- /**
13
- * A data oracle that provides information needed for simulating a transaction.
14
- */ export class PrivateKernelOracleImpl {
15
- contractStore;
16
- keyStore;
17
- node;
18
- blockNumber;
19
- log;
20
- constructor(contractStore, keyStore, node, blockNumber = 'latest', log = createLogger('pxe:kernel_oracle')){
21
- this.contractStore = contractStore;
22
- this.keyStore = keyStore;
23
- this.node = node;
24
- this.blockNumber = blockNumber;
25
- this.log = log;
26
- }
27
- async getContractAddressPreimage(address) {
28
- const instance = await this.contractStore.getContractInstance(address);
29
- if (!instance) {
30
- throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
31
- }
32
- return {
33
- saltedInitializationHash: await computeSaltedInitializationHash(instance),
34
- ...instance
35
- };
36
- }
37
- async getContractClassIdPreimage(contractClassId) {
38
- const contractClass = await this.contractStore.getContractClass(contractClassId);
39
- if (!contractClass) {
40
- throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
41
- }
42
- return computeContractClassIdPreimage(contractClass);
43
- }
44
- async getFunctionMembershipWitness(contractClassId, selector) {
45
- const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
46
- if (!membershipWitness) {
47
- throw new Error(`Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`);
48
- }
49
- return membershipWitness;
50
- }
51
- getVkMembershipWitness(vk) {
52
- const leafIndex = getVKIndex(vk);
53
- return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
54
- }
55
- getNoteHashMembershipWitness(noteHash) {
56
- return this.node.getNoteHashMembershipWitness(this.blockNumber, noteHash);
57
- }
58
- getNullifierMembershipWitness(nullifier) {
59
- return this.node.getNullifierMembershipWitness(this.blockNumber, nullifier);
60
- }
61
- async getNoteHashTreeRoot() {
62
- const header = await this.node.getBlockHeader(this.blockNumber);
63
- if (!header) {
64
- throw new Error(`No block header found for block number ${this.blockNumber}`);
65
- }
66
- return header.state.partial.noteHashTree.root;
67
- }
68
- getMasterSecretKey(masterPublicKey) {
69
- return this.keyStore.getMasterSecretKey(masterPublicKey);
70
- }
71
- getDebugFunctionName(contractAddress, selector) {
72
- return this.contractStore.getDebugFunctionName(contractAddress, selector);
73
- }
74
- async getUpdatedClassIdHints(contractAddress) {
75
- const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
76
- const hashLeafSlot = await computePublicDataTreeLeafSlot(ProtocolContractAddress.ContractInstanceRegistry, delayedPublicMutableHashSlot);
77
- const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockNumber, hashLeafSlot);
78
- if (!updatedClassIdWitness) {
79
- throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
80
- }
81
- const readStorage = (storageSlot)=>this.node.getPublicStorageAt(this.blockNumber, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
82
- const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, readStorage);
83
- return new UpdatedClassIdHints(new MembershipWitness(PUBLIC_DATA_TREE_HEIGHT, updatedClassIdWitness.index, updatedClassIdWitness.siblingPath.toTuple()), updatedClassIdWitness.leafPreimage, delayedPublicMutableValues);
84
- }
85
- }
@@ -1,127 +0,0 @@
1
- import { NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
2
- import type { Fr } from '@aztec/foundation/curves/bn254';
3
- import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
4
- import { createLogger } from '@aztec/foundation/log';
5
- import { MembershipWitness } from '@aztec/foundation/trees';
6
- import type { KeyStore } from '@aztec/key-store';
7
- import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
8
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
9
- import type { FunctionSelector } from '@aztec/stdlib/abi';
10
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
11
- import type { BlockParameter } from '@aztec/stdlib/block';
12
- import { computeContractClassIdPreimage, computeSaltedInitializationHash } from '@aztec/stdlib/contract';
13
- import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
14
- import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
15
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
16
- import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
17
- import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
18
- import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
19
-
20
- import type { ContractStore } from '../storage/contract_store/contract_store.js';
21
- import type { PrivateKernelOracle } from './private_kernel_oracle.js';
22
-
23
- // TODO: Block number should not be "latest".
24
- // It should be fixed at the time the proof is being simulated. I.e., it should be the same as the value defined in the constant data.
25
-
26
- /**
27
- * A data oracle that provides information needed for simulating a transaction.
28
- */
29
- export class PrivateKernelOracleImpl implements PrivateKernelOracle {
30
- constructor(
31
- private contractStore: ContractStore,
32
- private keyStore: KeyStore,
33
- private node: AztecNode,
34
- private blockNumber: BlockParameter = 'latest',
35
- private log = createLogger('pxe:kernel_oracle'),
36
- ) {}
37
-
38
- public async getContractAddressPreimage(address: AztecAddress) {
39
- const instance = await this.contractStore.getContractInstance(address);
40
- if (!instance) {
41
- throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
42
- }
43
- return {
44
- saltedInitializationHash: await computeSaltedInitializationHash(instance),
45
- ...instance,
46
- };
47
- }
48
-
49
- public async getContractClassIdPreimage(contractClassId: Fr) {
50
- const contractClass = await this.contractStore.getContractClass(contractClassId);
51
- if (!contractClass) {
52
- throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
53
- }
54
- return computeContractClassIdPreimage(contractClass);
55
- }
56
-
57
- public async getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector) {
58
- const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
59
- if (!membershipWitness) {
60
- throw new Error(
61
- `Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`,
62
- );
63
- }
64
- return membershipWitness;
65
- }
66
-
67
- public getVkMembershipWitness(vk: VerificationKeyAsFields) {
68
- const leafIndex = getVKIndex(vk);
69
- return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
70
- }
71
-
72
- getNoteHashMembershipWitness(noteHash: Fr): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
73
- return this.node.getNoteHashMembershipWitness(this.blockNumber, noteHash);
74
- }
75
-
76
- getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined> {
77
- return this.node.getNullifierMembershipWitness(this.blockNumber, nullifier);
78
- }
79
-
80
- async getNoteHashTreeRoot(): Promise<Fr> {
81
- const header = await this.node.getBlockHeader(this.blockNumber);
82
- if (!header) {
83
- throw new Error(`No block header found for block number ${this.blockNumber}`);
84
- }
85
- return header.state.partial.noteHashTree.root;
86
- }
87
-
88
- public getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar> {
89
- return this.keyStore.getMasterSecretKey(masterPublicKey);
90
- }
91
-
92
- public getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string> {
93
- return this.contractStore.getDebugFunctionName(contractAddress, selector);
94
- }
95
-
96
- public async getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints> {
97
- const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } =
98
- await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
99
-
100
- const hashLeafSlot = await computePublicDataTreeLeafSlot(
101
- ProtocolContractAddress.ContractInstanceRegistry,
102
- delayedPublicMutableHashSlot,
103
- );
104
- const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockNumber, hashLeafSlot);
105
-
106
- if (!updatedClassIdWitness) {
107
- throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
108
- }
109
-
110
- const readStorage = (storageSlot: Fr) =>
111
- this.node.getPublicStorageAt(this.blockNumber, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
112
- const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(
113
- delayedPublicMutableSlot,
114
- readStorage,
115
- );
116
-
117
- return new UpdatedClassIdHints(
118
- new MembershipWitness(
119
- PUBLIC_DATA_TREE_HEIGHT,
120
- updatedClassIdWitness.index,
121
- updatedClassIdWitness.siblingPath.toTuple(),
122
- ),
123
- updatedClassIdWitness.leafPreimage,
124
- delayedPublicMutableValues,
125
- );
126
- }
127
- }