@aztec/pxe 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/contract_data_oracle/index.d.ts +9 -0
- package/dest/contract_data_oracle/index.d.ts.map +1 -1
- package/dest/contract_data_oracle/index.js +13 -1
- package/dest/contract_tree/index.js +2 -2
- package/dest/database/database.d.ts +17 -28
- package/dest/database/database.d.ts.map +1 -1
- package/dest/database/index.d.ts +0 -1
- package/dest/database/index.d.ts.map +1 -1
- package/dest/database/index.js +1 -2
- package/dest/database/memory_db.d.ts +8 -8
- package/dest/database/memory_db.d.ts.map +1 -1
- package/dest/database/memory_db.js +27 -19
- package/dest/database/note_dao.d.ts +61 -0
- package/dest/database/note_dao.d.ts.map +1 -0
- package/dest/database/note_dao.js +83 -0
- package/dest/kernel_oracle/index.js +2 -2
- package/dest/kernel_prover/kernel_prover.d.ts +4 -4
- package/dest/kernel_prover/kernel_prover.js +2 -2
- package/dest/note_processor/note_processor.d.ts +7 -6
- package/dest/note_processor/note_processor.d.ts.map +1 -1
- package/dest/note_processor/note_processor.js +31 -36
- package/dest/pxe_http/pxe_http_server.d.ts.map +1 -1
- package/dest/pxe_http/pxe_http_server.js +4 -3
- package/dest/pxe_service/pxe_service.d.ts +4 -4
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +32 -37
- package/dest/simulator_oracle/index.d.ts +2 -1
- package/dest/simulator_oracle/index.d.ts.map +1 -1
- package/dest/simulator_oracle/index.js +16 -5
- package/package.json +9 -9
- package/src/contract_data_oracle/index.ts +13 -0
- package/src/contract_tree/index.ts +1 -1
- package/src/database/database.ts +17 -28
- package/src/database/index.ts +0 -1
- package/src/database/memory_db.ts +33 -23
- package/src/database/note_dao.ts +90 -0
- package/src/kernel_oracle/index.ts +1 -1
- package/src/kernel_prover/kernel_prover.ts +4 -4
- package/src/note_processor/note_processor.ts +50 -48
- package/src/pxe_http/pxe_http_server.ts +4 -2
- package/src/pxe_service/pxe_service.ts +50 -50
- package/src/simulator_oracle/index.ts +28 -14
- package/dest/database/note_spending_info_dao.d.ts +0 -50
- package/dest/database/note_spending_info_dao.d.ts.map +0 -1
- package/dest/database/note_spending_info_dao.js +0 -24
- package/src/database/note_spending_info_dao.ts +0 -75
|
@@ -7,12 +7,13 @@ import {
|
|
|
7
7
|
CompleteAddress,
|
|
8
8
|
ContractData,
|
|
9
9
|
ExtendedContractData,
|
|
10
|
+
ExtendedNote,
|
|
10
11
|
ExtendedUnencryptedL2Log,
|
|
11
12
|
L2Block,
|
|
12
13
|
L2BlockL2Logs,
|
|
13
14
|
L2Tx,
|
|
14
15
|
LogId,
|
|
15
|
-
|
|
16
|
+
Note,
|
|
16
17
|
PXE,
|
|
17
18
|
Tx,
|
|
18
19
|
TxExecutionRequest,
|
|
@@ -47,7 +48,8 @@ export function createPXERpcServer(pxeService: PXE): JsonRpcServer {
|
|
|
47
48
|
Point,
|
|
48
49
|
Fr,
|
|
49
50
|
GrumpkinScalar,
|
|
50
|
-
|
|
51
|
+
Note,
|
|
52
|
+
ExtendedNote,
|
|
51
53
|
AuthWitness,
|
|
52
54
|
L2Block,
|
|
53
55
|
L2Tx,
|
|
@@ -22,7 +22,7 @@ import { encodeArguments } from '@aztec/foundation/abi';
|
|
|
22
22
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
23
23
|
import { Fr } from '@aztec/foundation/fields';
|
|
24
24
|
import { DebugLogger, createDebugLogger } from '@aztec/foundation/log';
|
|
25
|
-
import NoirVersion from '@aztec/noir-compiler/noir-version';
|
|
25
|
+
import { NoirVersion } from '@aztec/noir-compiler/noir-version';
|
|
26
26
|
import {
|
|
27
27
|
AuthWitness,
|
|
28
28
|
AztecNode,
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
ContractData,
|
|
31
31
|
DeployedContract,
|
|
32
32
|
ExtendedContractData,
|
|
33
|
+
ExtendedNote,
|
|
33
34
|
FunctionCall,
|
|
34
35
|
GetUnencryptedLogsResponse,
|
|
35
36
|
KeyStore,
|
|
@@ -38,7 +39,7 @@ import {
|
|
|
38
39
|
LogFilter,
|
|
39
40
|
MerkleTreeId,
|
|
40
41
|
NodeInfo,
|
|
41
|
-
|
|
42
|
+
NoteFilter,
|
|
42
43
|
PXE,
|
|
43
44
|
SimulationError,
|
|
44
45
|
Tx,
|
|
@@ -55,6 +56,7 @@ import {
|
|
|
55
56
|
import { PXEServiceConfig, getPackageInfo } from '../config/index.js';
|
|
56
57
|
import { ContractDataOracle } from '../contract_data_oracle/index.js';
|
|
57
58
|
import { Database } from '../database/index.js';
|
|
59
|
+
import { NoteDao } from '../database/note_dao.js';
|
|
58
60
|
import { KernelOracle } from '../kernel_oracle/index.js';
|
|
59
61
|
import { KernelProver } from '../kernel_prover/kernel_prover.js';
|
|
60
62
|
import { getAcirSimulator } from '../simulator/index.js';
|
|
@@ -192,40 +194,40 @@ export class PXEService implements PXE {
|
|
|
192
194
|
return await this.node.getPublicStorageAt(contract, storageSlot.value);
|
|
193
195
|
}
|
|
194
196
|
|
|
195
|
-
public async
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
197
|
+
public async getNotes(filter: NoteFilter): Promise<ExtendedNote[]> {
|
|
198
|
+
const noteDaos = await this.db.getNotes(filter);
|
|
199
|
+
|
|
200
|
+
// TODO(benesjan): Refactor --> This type conversion is ugly but I decided to keep it this way for now because
|
|
201
|
+
// key derivation will affect all this
|
|
202
|
+
const extendedNotes = noteDaos.map(async dao => {
|
|
203
|
+
let owner = filter.owner;
|
|
204
|
+
if (owner === undefined) {
|
|
205
|
+
const completeAddresses = (await this.db.getCompleteAddresses()).find(address =>
|
|
206
|
+
address.publicKey.equals(dao.publicKey),
|
|
207
|
+
);
|
|
208
|
+
if (completeAddresses === undefined) {
|
|
209
|
+
throw new Error(`Cannot find complete address for public key ${dao.publicKey.toString()}`);
|
|
210
|
+
}
|
|
211
|
+
owner = completeAddresses.address;
|
|
212
|
+
}
|
|
213
|
+
return new ExtendedNote(dao.note, owner, dao.contractAddress, dao.storageSlot, dao.txHash);
|
|
214
|
+
});
|
|
215
|
+
return Promise.all(extendedNotes);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
public async addNote(note: ExtendedNote) {
|
|
219
|
+
const { publicKey } = (await this.db.getCompleteAddress(note.owner)) ?? {};
|
|
216
220
|
if (!publicKey) {
|
|
217
221
|
throw new Error('Unknown account.');
|
|
218
222
|
}
|
|
219
223
|
|
|
224
|
+
const [nonce] = await this.getNoteNonces(note);
|
|
220
225
|
if (!nonce) {
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
if (!nonce) {
|
|
224
|
-
throw new Error(`Cannot find the note in tx: ${txHash}.`);
|
|
226
|
+
throw new Error(`Cannot find the note in tx: ${note.txHash}.`);
|
|
225
227
|
}
|
|
226
228
|
|
|
227
229
|
const { innerNoteHash, siloedNoteHash, uniqueSiloedNoteHash, innerNullifier } =
|
|
228
|
-
await this.simulator.computeNoteHashAndNullifier(contractAddress, nonce, storageSlot,
|
|
230
|
+
await this.simulator.computeNoteHashAndNullifier(note.contractAddress, nonce, note.storageSlot, note.note);
|
|
229
231
|
|
|
230
232
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1386)
|
|
231
233
|
// This can always be `uniqueSiloedNoteHash` once notes added from public also include nonces.
|
|
@@ -236,33 +238,31 @@ export class PXEService implements PXE {
|
|
|
236
238
|
}
|
|
237
239
|
|
|
238
240
|
const wasm = await CircuitsWasm.get();
|
|
239
|
-
const siloedNullifier = siloNullifier(wasm, contractAddress, innerNullifier!);
|
|
241
|
+
const siloedNullifier = siloNullifier(wasm, note.contractAddress, innerNullifier!);
|
|
240
242
|
const nullifierIndex = await this.node.findLeafIndex(MerkleTreeId.NULLIFIER_TREE, siloedNullifier.toBuffer());
|
|
241
243
|
if (nullifierIndex !== undefined) {
|
|
242
244
|
throw new Error('The note has been destroyed.');
|
|
243
245
|
}
|
|
244
246
|
|
|
245
|
-
await this.db.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
247
|
+
await this.db.addNote(
|
|
248
|
+
new NoteDao(
|
|
249
|
+
note.note,
|
|
250
|
+
note.contractAddress,
|
|
251
|
+
note.storageSlot,
|
|
252
|
+
note.txHash,
|
|
253
|
+
nonce,
|
|
254
|
+
innerNoteHash,
|
|
255
|
+
siloedNullifier,
|
|
256
|
+
index,
|
|
257
|
+
publicKey,
|
|
258
|
+
),
|
|
259
|
+
);
|
|
255
260
|
}
|
|
256
261
|
|
|
257
|
-
public async getNoteNonces(
|
|
258
|
-
|
|
259
|
-
storageSlot: Fr,
|
|
260
|
-
preimage: NotePreimage,
|
|
261
|
-
txHash: TxHash,
|
|
262
|
-
): Promise<Fr[]> {
|
|
263
|
-
const tx = await this.node.getTx(txHash);
|
|
262
|
+
public async getNoteNonces(note: ExtendedNote): Promise<Fr[]> {
|
|
263
|
+
const tx = await this.node.getTx(note.txHash);
|
|
264
264
|
if (!tx) {
|
|
265
|
-
throw new Error(`Unknown tx: ${txHash}`);
|
|
265
|
+
throw new Error(`Unknown tx: ${note.txHash}`);
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
const wasm = await CircuitsWasm.get();
|
|
@@ -276,10 +276,10 @@ export class PXEService implements PXE {
|
|
|
276
276
|
|
|
277
277
|
const nonce = computeCommitmentNonce(wasm, firstNullifier, i);
|
|
278
278
|
const { siloedNoteHash, uniqueSiloedNoteHash } = await this.simulator.computeNoteHashAndNullifier(
|
|
279
|
-
contractAddress,
|
|
279
|
+
note.contractAddress,
|
|
280
280
|
nonce,
|
|
281
|
-
storageSlot,
|
|
282
|
-
|
|
281
|
+
note.storageSlot,
|
|
282
|
+
note.note,
|
|
283
283
|
);
|
|
284
284
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1386)
|
|
285
285
|
// Remove this once notes added from public also include nonces.
|
|
@@ -45,19 +45,17 @@ export class SimulatorOracle implements DBOracle {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
async getNotes(contractAddress: AztecAddress, storageSlot: Fr) {
|
|
48
|
-
const noteDaos = await this.db.
|
|
49
|
-
return noteDaos.map(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}),
|
|
60
|
-
);
|
|
48
|
+
const noteDaos = await this.db.getNotes({ contractAddress, storageSlot });
|
|
49
|
+
return noteDaos.map(({ contractAddress, storageSlot, nonce, note, innerNoteHash, siloedNullifier, index }) => ({
|
|
50
|
+
contractAddress,
|
|
51
|
+
storageSlot,
|
|
52
|
+
nonce,
|
|
53
|
+
note,
|
|
54
|
+
innerNoteHash,
|
|
55
|
+
siloedNullifier,
|
|
56
|
+
// PXE can use this index to get full MembershipWitness
|
|
57
|
+
index,
|
|
58
|
+
}));
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
async getFunctionArtifact(
|
|
@@ -72,6 +70,22 @@ export class SimulatorOracle implements DBOracle {
|
|
|
72
70
|
};
|
|
73
71
|
}
|
|
74
72
|
|
|
73
|
+
async getFunctionArtifactByName(
|
|
74
|
+
contractAddress: AztecAddress,
|
|
75
|
+
functionName: string,
|
|
76
|
+
): Promise<FunctionArtifactWithDebugMetadata | undefined> {
|
|
77
|
+
const artifact = await this.contractDataOracle.getFunctionArtifactByName(contractAddress, functionName);
|
|
78
|
+
if (!artifact) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const debug = await this.contractDataOracle.getFunctionDebugMetadata(contractAddress, artifact.selector);
|
|
83
|
+
return {
|
|
84
|
+
...artifact,
|
|
85
|
+
debug,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
75
89
|
async getPortalContractAddress(contractAddress: AztecAddress): Promise<EthAddress> {
|
|
76
90
|
return await this.contractDataOracle.getPortalContractAddress(contractAddress);
|
|
77
91
|
}
|
|
@@ -88,7 +102,7 @@ export class SimulatorOracle implements DBOracle {
|
|
|
88
102
|
const messageAndIndex = await this.stateInfoProvider.getL1ToL2MessageAndIndex(msgKey);
|
|
89
103
|
const message = messageAndIndex.message.toFieldArray();
|
|
90
104
|
const index = messageAndIndex.index;
|
|
91
|
-
const siblingPath = await this.stateInfoProvider.
|
|
105
|
+
const siblingPath = await this.stateInfoProvider.getL1ToL2MessageSiblingPath(index);
|
|
92
106
|
return {
|
|
93
107
|
message,
|
|
94
108
|
siblingPath: siblingPath.toFieldArray(),
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { AztecAddress, Fr, PublicKey } from '@aztec/circuits.js';
|
|
2
|
-
import { NotePreimage } from '@aztec/types';
|
|
3
|
-
/**
|
|
4
|
-
* Represents the data access object for auxiliary transaction data.
|
|
5
|
-
* Contains properties from the decrypted note, computed properties, and information about
|
|
6
|
-
* the public key used for encryption, as well as the location of the data in the tree.
|
|
7
|
-
*/
|
|
8
|
-
export interface NoteSpendingInfoDao {
|
|
9
|
-
/**
|
|
10
|
-
* The contract address this note is created in.
|
|
11
|
-
*/
|
|
12
|
-
contractAddress: AztecAddress;
|
|
13
|
-
/**
|
|
14
|
-
* The nonce of the note.
|
|
15
|
-
*/
|
|
16
|
-
nonce: Fr;
|
|
17
|
-
/**
|
|
18
|
-
* The specific storage location of the note on the contract.
|
|
19
|
-
*/
|
|
20
|
-
storageSlot: Fr;
|
|
21
|
-
/**
|
|
22
|
-
* The preimage of the note, containing essential information about the note.
|
|
23
|
-
*/
|
|
24
|
-
notePreimage: NotePreimage;
|
|
25
|
-
/**
|
|
26
|
-
* Inner note hash of the note. This is customizable by the app circuit.
|
|
27
|
-
* We can use this value to compute siloedNoteHash and uniqueSiloedNoteHash.
|
|
28
|
-
*/
|
|
29
|
-
innerNoteHash: Fr;
|
|
30
|
-
/**
|
|
31
|
-
* The nullifier of the note (siloed by contract address).
|
|
32
|
-
*/
|
|
33
|
-
siloedNullifier: Fr;
|
|
34
|
-
/**
|
|
35
|
-
* The location of the relevant note in the note hash tree.
|
|
36
|
-
*/
|
|
37
|
-
index: bigint;
|
|
38
|
-
/**
|
|
39
|
-
* The public key that was used to encrypt the data.
|
|
40
|
-
*/
|
|
41
|
-
publicKey: PublicKey;
|
|
42
|
-
}
|
|
43
|
-
export declare const createRandomNoteSpendingInfoDao: ({ contractAddress, nonce, storageSlot, notePreimage, innerNoteHash, siloedNullifier, index, publicKey, }?: Partial<NoteSpendingInfoDao>) => NoteSpendingInfoDao;
|
|
44
|
-
/**
|
|
45
|
-
* Returns the size in bytes of a note spending info dao.
|
|
46
|
-
* @param note - The note.
|
|
47
|
-
* @returns - Its size in bytes.
|
|
48
|
-
*/
|
|
49
|
-
export declare function getNoteSpendingInfoDaoSize(note: NoteSpendingInfoDao): number;
|
|
50
|
-
//# sourceMappingURL=note_spending_info_dao.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"note_spending_info_dao.d.ts","sourceRoot":"","sources":["../../src/database/note_spending_info_dao.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,eAAe,EAAE,YAAY,CAAC;IAC9B;;OAEG;IACH,KAAK,EAAE,EAAE,CAAC;IACV;;OAEG;IACH,WAAW,EAAE,EAAE,CAAC;IAChB;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC;IAC3B;;;OAGG;IACH,aAAa,EAAE,EAAE,CAAC;IAClB;;OAEG;IACH,eAAe,EAAE,EAAE,CAAC;IACpB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,+BAA+B,8GASzC,QAAQ,mBAAmB,CAAC,KAAQ,mBASrC,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,mBAAmB,UAInE"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { AztecAddress, Fr } from '@aztec/circuits.js';
|
|
2
|
-
import { Point } from '@aztec/foundation/fields';
|
|
3
|
-
import { NotePreimage } from '@aztec/types';
|
|
4
|
-
export const createRandomNoteSpendingInfoDao = ({ contractAddress = AztecAddress.random(), nonce = Fr.random(), storageSlot = Fr.random(), notePreimage = NotePreimage.random(), innerNoteHash = Fr.random(), siloedNullifier = Fr.random(), index = Fr.random().value, publicKey = Point.random(), } = {}) => ({
|
|
5
|
-
contractAddress,
|
|
6
|
-
nonce,
|
|
7
|
-
storageSlot,
|
|
8
|
-
notePreimage,
|
|
9
|
-
innerNoteHash,
|
|
10
|
-
siloedNullifier,
|
|
11
|
-
index,
|
|
12
|
-
publicKey,
|
|
13
|
-
});
|
|
14
|
-
/**
|
|
15
|
-
* Returns the size in bytes of a note spending info dao.
|
|
16
|
-
* @param note - The note.
|
|
17
|
-
* @returns - Its size in bytes.
|
|
18
|
-
*/
|
|
19
|
-
export function getNoteSpendingInfoDaoSize(note) {
|
|
20
|
-
// 7 fields + 1 bigint + 1 buffer size (4 bytes) + 1 buffer
|
|
21
|
-
const indexSize = Math.ceil(Math.log2(Number(note.index)));
|
|
22
|
-
return 7 * Fr.SIZE_IN_BYTES + indexSize + 4 + note.notePreimage.items.length * Fr.SIZE_IN_BYTES;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90ZV9zcGVuZGluZ19pbmZvX2Rhby5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kYXRhYmFzZS9ub3RlX3NwZW5kaW5nX2luZm9fZGFvLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsRUFBRSxFQUFhLE1BQU0sb0JBQW9CLENBQUM7QUFDakUsT0FBTyxFQUFFLEtBQUssRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBQ2pELE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxjQUFjLENBQUM7QUEyQzVDLE1BQU0sQ0FBQyxNQUFNLCtCQUErQixHQUFHLENBQUMsRUFDOUMsZUFBZSxHQUFHLFlBQVksQ0FBQyxNQUFNLEVBQUUsRUFDdkMsS0FBSyxHQUFHLEVBQUUsQ0FBQyxNQUFNLEVBQUUsRUFDbkIsV0FBVyxHQUFHLEVBQUUsQ0FBQyxNQUFNLEVBQUUsRUFDekIsWUFBWSxHQUFHLFlBQVksQ0FBQyxNQUFNLEVBQUUsRUFDcEMsYUFBYSxHQUFHLEVBQUUsQ0FBQyxNQUFNLEVBQUUsRUFDM0IsZUFBZSxHQUFHLEVBQUUsQ0FBQyxNQUFNLEVBQUUsRUFDN0IsS0FBSyxHQUFHLEVBQUUsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxLQUFLLEVBQ3pCLFNBQVMsR0FBRyxLQUFLLENBQUMsTUFBTSxFQUFFLE1BQ00sRUFBRSxFQUF1QixFQUFFLENBQUMsQ0FBQztJQUM3RCxlQUFlO0lBQ2YsS0FBSztJQUNMLFdBQVc7SUFDWCxZQUFZO0lBQ1osYUFBYTtJQUNiLGVBQWU7SUFDZixLQUFLO0lBQ0wsU0FBUztDQUNWLENBQUMsQ0FBQztBQUVIOzs7O0dBSUc7QUFDSCxNQUFNLFVBQVUsMEJBQTBCLENBQUMsSUFBeUI7SUFDbEUsMkRBQTJEO0lBQzNELE1BQU0sU0FBUyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUMzRCxPQUFPLENBQUMsR0FBRyxFQUFFLENBQUMsYUFBYSxHQUFHLFNBQVMsR0FBRyxDQUFDLEdBQUcsSUFBSSxDQUFDLFlBQVksQ0FBQyxLQUFLLENBQUMsTUFBTSxHQUFHLEVBQUUsQ0FBQyxhQUFhLENBQUM7QUFDbEcsQ0FBQyJ9
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { AztecAddress, Fr, PublicKey } from '@aztec/circuits.js';
|
|
2
|
-
import { Point } from '@aztec/foundation/fields';
|
|
3
|
-
import { NotePreimage } from '@aztec/types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Represents the data access object for auxiliary transaction data.
|
|
7
|
-
* Contains properties from the decrypted note, computed properties, and information about
|
|
8
|
-
* the public key used for encryption, as well as the location of the data in the tree.
|
|
9
|
-
*/
|
|
10
|
-
export interface NoteSpendingInfoDao {
|
|
11
|
-
/**
|
|
12
|
-
* The contract address this note is created in.
|
|
13
|
-
*/
|
|
14
|
-
contractAddress: AztecAddress;
|
|
15
|
-
/**
|
|
16
|
-
* The nonce of the note.
|
|
17
|
-
*/
|
|
18
|
-
nonce: Fr;
|
|
19
|
-
/**
|
|
20
|
-
* The specific storage location of the note on the contract.
|
|
21
|
-
*/
|
|
22
|
-
storageSlot: Fr;
|
|
23
|
-
/**
|
|
24
|
-
* The preimage of the note, containing essential information about the note.
|
|
25
|
-
*/
|
|
26
|
-
notePreimage: NotePreimage;
|
|
27
|
-
/**
|
|
28
|
-
* Inner note hash of the note. This is customizable by the app circuit.
|
|
29
|
-
* We can use this value to compute siloedNoteHash and uniqueSiloedNoteHash.
|
|
30
|
-
*/
|
|
31
|
-
innerNoteHash: Fr;
|
|
32
|
-
/**
|
|
33
|
-
* The nullifier of the note (siloed by contract address).
|
|
34
|
-
*/
|
|
35
|
-
siloedNullifier: Fr;
|
|
36
|
-
/**
|
|
37
|
-
* The location of the relevant note in the note hash tree.
|
|
38
|
-
*/
|
|
39
|
-
index: bigint;
|
|
40
|
-
/**
|
|
41
|
-
* The public key that was used to encrypt the data.
|
|
42
|
-
*/
|
|
43
|
-
publicKey: PublicKey;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const createRandomNoteSpendingInfoDao = ({
|
|
47
|
-
contractAddress = AztecAddress.random(),
|
|
48
|
-
nonce = Fr.random(),
|
|
49
|
-
storageSlot = Fr.random(),
|
|
50
|
-
notePreimage = NotePreimage.random(),
|
|
51
|
-
innerNoteHash = Fr.random(),
|
|
52
|
-
siloedNullifier = Fr.random(),
|
|
53
|
-
index = Fr.random().value,
|
|
54
|
-
publicKey = Point.random(),
|
|
55
|
-
}: Partial<NoteSpendingInfoDao> = {}): NoteSpendingInfoDao => ({
|
|
56
|
-
contractAddress,
|
|
57
|
-
nonce,
|
|
58
|
-
storageSlot,
|
|
59
|
-
notePreimage,
|
|
60
|
-
innerNoteHash,
|
|
61
|
-
siloedNullifier,
|
|
62
|
-
index,
|
|
63
|
-
publicKey,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Returns the size in bytes of a note spending info dao.
|
|
68
|
-
* @param note - The note.
|
|
69
|
-
* @returns - Its size in bytes.
|
|
70
|
-
*/
|
|
71
|
-
export function getNoteSpendingInfoDaoSize(note: NoteSpendingInfoDao) {
|
|
72
|
-
// 7 fields + 1 bigint + 1 buffer size (4 bytes) + 1 buffer
|
|
73
|
-
const indexSize = Math.ceil(Math.log2(Number(note.index)));
|
|
74
|
-
return 7 * Fr.SIZE_IN_BYTES + indexSize + 4 + note.notePreimage.items.length * Fr.SIZE_IN_BYTES;
|
|
75
|
-
}
|