@aztec/pxe 0.80.0 → 0.81.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/pxe_oracle_interface/pxe_oracle_interface.d.ts +7 -6
- package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/pxe_oracle_interface/pxe_oracle_interface.js +41 -76
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +6 -6
- package/dest/storage/note_data_provider/note_dao.d.ts +9 -13
- package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_dao.js +11 -15
- package/dest/storage/note_data_provider/note_data_provider.d.ts +2 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +18 -19
- package/dest/synchronizer/synchronizer.js +1 -1
- package/package.json +15 -15
- package/src/pxe_oracle_interface/pxe_oracle_interface.ts +52 -113
- package/src/pxe_service/pxe_service.ts +10 -17
- package/src/storage/note_data_provider/note_dao.ts +9 -18
- package/src/storage/note_data_provider/note_data_provider.ts +22 -28
- package/src/synchronizer/synchronizer.ts +1 -1
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
- package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
- package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { type L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { Fr, Point } from '@aztec/foundation/fields';
|
|
3
3
|
import type { KeyStore } from '@aztec/key-store';
|
|
4
|
-
import { AcirSimulator, type ExecutionDataProvider, type SimulationProvider } from '@aztec/simulator/client';
|
|
5
|
-
import { MessageLoadOracleInputs } from '@aztec/simulator/client';
|
|
4
|
+
import { AcirSimulator, type ExecutionDataProvider, MessageLoadOracleInputs, type SimulationProvider } from '@aztec/simulator/client';
|
|
6
5
|
import { type FunctionArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
|
-
import
|
|
6
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
7
|
import type { L2Block } from '@aztec/stdlib/block';
|
|
9
8
|
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
|
|
10
9
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
@@ -143,17 +142,19 @@ export declare class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
143
142
|
syncTaggedLogs(contractAddress: AztecAddress, maxBlockNumber: number, scopes?: AztecAddress[]): Promise<Map<string, TxScopedL2Log[]>>;
|
|
144
143
|
/**
|
|
145
144
|
* Processes the tagged logs returned by syncTaggedLogs by decrypting them and storing them in the database.
|
|
145
|
+
* @param contractAddress - The address of the contract that the logs are tagged for.
|
|
146
146
|
* @param logs - The logs to process.
|
|
147
147
|
* @param recipient - The recipient of the logs.
|
|
148
148
|
*/
|
|
149
|
-
processTaggedLogs(logs: TxScopedL2Log[], recipient: AztecAddress, simulator?: AcirSimulator): Promise<void>;
|
|
149
|
+
processTaggedLogs(contractAddress: AztecAddress, logs: TxScopedL2Log[], recipient: AztecAddress, simulator?: AcirSimulator): Promise<void>;
|
|
150
150
|
deliverNote(contractAddress: AztecAddress, storageSlot: Fr, nonce: Fr, content: Fr[], noteHash: Fr, nullifier: Fr, txHash: Fr, recipient: AztecAddress): Promise<void>;
|
|
151
151
|
getLogByTag(tag: Fr): Promise<LogWithTxData | null>;
|
|
152
152
|
removeNullifiedNotes(contractAddress: AztecAddress): Promise<void>;
|
|
153
|
-
callProcessLog(contractAddress: AztecAddress,
|
|
153
|
+
callProcessLog(contractAddress: AztecAddress, logCiphertext: Fr[], txHash: TxHash, noteHashes: Fr[], firstNullifier: Fr, recipient: AztecAddress, simulator?: AcirSimulator): Promise<void>;
|
|
154
154
|
storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void>;
|
|
155
155
|
loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null>;
|
|
156
156
|
deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void>;
|
|
157
157
|
copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void>;
|
|
158
|
+
getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point>;
|
|
158
159
|
}
|
|
159
160
|
//# sourceMappingURL=pxe_oracle_interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pxe_oracle_interface.d.ts","sourceRoot":"","sources":["../../src/pxe_oracle_interface/pxe_oracle_interface.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"pxe_oracle_interface.d.ts","sourceRoot":"","sources":["../../src/pxe_oracle_interface/pxe_oracle_interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,wBAAwB,EAAsD,MAAM,kBAAkB,CAAC;AAGrH,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,aAAa,EACb,KAAK,qBAAqB,EAC1B,uBAAuB,EACvB,KAAK,kBAAkB,EACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,gBAAgB,EAErB,gBAAgB,EAIjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAW,OAAO,EAAiB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC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,YAAY,EACvB,SAAS,CAAC,EAAE,aAAa;IAqC3B,YAAY,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAInF,WAAW,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC;IAI1E,aAAa,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrE,WAAW,CAAC,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjG,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;CAS3E"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import { MAX_NOTE_HASHES_PER_TX, PRIVATE_LOG_SIZE_IN_FIELDS
|
|
1
|
+
import { MAX_NOTE_HASHES_PER_TX, PRIVATE_LOG_SIZE_IN_FIELDS } from '@aztec/constants';
|
|
2
2
|
import { timesParallel } from '@aztec/foundation/collection';
|
|
3
3
|
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { MessageLoadOracleInputs } from '@aztec/simulator/client';
|
|
9
|
-
import { FunctionSelector, FunctionType, NoteSelector, encodeArguments, getFunctionArtifact } from '@aztec/stdlib/abi';
|
|
6
|
+
import { AcirSimulator, MessageLoadOracleInputs } from '@aztec/simulator/client';
|
|
7
|
+
import { FunctionSelector, FunctionType, encodeArguments, getFunctionArtifact } from '@aztec/stdlib/abi';
|
|
10
8
|
import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
11
9
|
import { computeAddressSecret, computeTaggingSecretPoint } from '@aztec/stdlib/keys';
|
|
12
|
-
import { IndexedTaggingSecret,
|
|
10
|
+
import { IndexedTaggingSecret, LogWithTxData, deriveEcdhSharedSecret } from '@aztec/stdlib/logs';
|
|
13
11
|
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
14
12
|
import { Note } from '@aztec/stdlib/note';
|
|
15
13
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
16
14
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
17
|
-
import { getOrderedNoteItems } from '../note_decryption_utils/add_public_values_to_payload.js';
|
|
18
15
|
import { NoteDao } from '../storage/note_data_provider/note_dao.js';
|
|
19
16
|
import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndexesMap } from './tagging_utils.js';
|
|
20
17
|
/**
|
|
@@ -365,7 +362,7 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
365
362
|
const recipients = scopes ? scopes : await this.keyStore.getAccounts();
|
|
366
363
|
// A map of logs going from recipient address to logs. Note that the logs might have been processed before
|
|
367
364
|
// due to us having a sliding window that "looks back" for logs as well. (We look back as there is no guarantee
|
|
368
|
-
// that a logs will be received ordered by a given
|
|
365
|
+
// that a logs will be received ordered by a given tag index and that the tags won't be reused).
|
|
369
366
|
const logsMap = new Map();
|
|
370
367
|
const contractName = await this.contractDataProvider.getDebugContractName(contractAddress);
|
|
371
368
|
for (const recipient of recipients){
|
|
@@ -401,19 +398,18 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
401
398
|
const logsByTags = await this.aztecNode.getLogsByTags(tagsForTheWholeWindow);
|
|
402
399
|
logsByTags.forEach((logsByTag, logIndex)=>{
|
|
403
400
|
if (logsByTag.length > 0) {
|
|
404
|
-
//
|
|
405
|
-
const
|
|
406
|
-
if (
|
|
407
|
-
|
|
408
|
-
this.log.warn(`Discarded ${logsByTag.length - checkedLogsbyTag.length} public logs with mismatched contract address ${contractAddress}:`, discarded.map((l)=>PublicLog.fromBuffer(l.logData)));
|
|
401
|
+
// Discard public logs
|
|
402
|
+
const filteredLogsByTag = logsByTag.filter((l)=>!l.isFromPublic);
|
|
403
|
+
if (filteredLogsByTag.length < logsByTag.length) {
|
|
404
|
+
this.log.warn(`Discarded ${logsByTag.filter((l)=>l.isFromPublic).length} public logs with matching tags`);
|
|
409
405
|
}
|
|
410
406
|
// The logs for the given tag exist so we store them for later processing
|
|
411
|
-
logsForRecipient.push(...
|
|
407
|
+
logsForRecipient.push(...filteredLogsByTag);
|
|
412
408
|
// We retrieve the indexed tagging secret corresponding to the log as I need that to evaluate whether
|
|
413
409
|
// a new largest index have been found.
|
|
414
410
|
const secretCorrespondingToLog = secretsForTheWholeWindow[logIndex];
|
|
415
411
|
const initialIndex = initialIndexesMap[secretCorrespondingToLog.appTaggingSecret.toString()];
|
|
416
|
-
this.log.debug(`Found ${
|
|
412
|
+
this.log.debug(`Found ${filteredLogsByTag.length} logs as recipient ${recipient}`, {
|
|
417
413
|
recipient,
|
|
418
414
|
secret: secretCorrespondingToLog.appTaggingSecret,
|
|
419
415
|
contractName,
|
|
@@ -457,61 +453,24 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
457
453
|
return logsMap;
|
|
458
454
|
}
|
|
459
455
|
/**
|
|
460
|
-
* Decrypts logs tagged for a recipient and returns them.
|
|
461
|
-
* @param scopedLogs - The logs to decrypt.
|
|
462
|
-
* @param recipient - The recipient of the logs.
|
|
463
|
-
* @returns The decrypted notes.
|
|
464
|
-
*/ async #decryptTaggedLogs(scopedLogs, recipient) {
|
|
465
|
-
const recipientCompleteAddress = await this.getCompleteAddress(recipient);
|
|
466
|
-
const ivskM = await this.keyStore.getMasterSecretKey(recipientCompleteAddress.publicKeys.masterIncomingViewingPublicKey);
|
|
467
|
-
const addressSecret = await computeAddressSecret(await recipientCompleteAddress.getPreaddress(), ivskM);
|
|
468
|
-
// Since we could have notes with the same index for different txs, we need
|
|
469
|
-
// to keep track of them scoping by txHash
|
|
470
|
-
const excludedIndices = new Map();
|
|
471
|
-
const decrypted = [];
|
|
472
|
-
for (const scopedLog of scopedLogs){
|
|
473
|
-
const payload = scopedLog.isFromPublic ? await L1NotePayload.decryptAsIncomingFromPublic(PublicLog.fromBuffer(scopedLog.logData), addressSecret) : await L1NotePayload.decryptAsIncoming(PrivateLog.fromBuffer(scopedLog.logData), addressSecret);
|
|
474
|
-
if (!payload) {
|
|
475
|
-
this.log.verbose('Unable to decrypt log');
|
|
476
|
-
continue;
|
|
477
|
-
}
|
|
478
|
-
if (!excludedIndices.has(scopedLog.txHash.toString())) {
|
|
479
|
-
excludedIndices.set(scopedLog.txHash.toString(), new Set());
|
|
480
|
-
}
|
|
481
|
-
const note = await getOrderedNoteItems(this.contractDataProvider, payload);
|
|
482
|
-
const plaintext = [
|
|
483
|
-
payload.storageSlot,
|
|
484
|
-
payload.noteTypeId.toField(),
|
|
485
|
-
...note.items
|
|
486
|
-
];
|
|
487
|
-
decrypted.push({
|
|
488
|
-
plaintext,
|
|
489
|
-
txHash: scopedLog.txHash,
|
|
490
|
-
contractAddress: payload.contractAddress
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
return decrypted;
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
456
|
* Processes the tagged logs returned by syncTaggedLogs by decrypting them and storing them in the database.
|
|
457
|
+
* @param contractAddress - The address of the contract that the logs are tagged for.
|
|
497
458
|
* @param logs - The logs to process.
|
|
498
459
|
* @param recipient - The recipient of the logs.
|
|
499
|
-
*/ async processTaggedLogs(logs, recipient, simulator) {
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
// contract for further processing.
|
|
505
|
-
for (const decryptedLog of decryptedLogs){
|
|
460
|
+
*/ async processTaggedLogs(contractAddress, logs, recipient, simulator) {
|
|
461
|
+
for (const scopedLog of logs){
|
|
462
|
+
if (scopedLog.isFromPublic) {
|
|
463
|
+
throw new Error('Attempted to decrypt public log');
|
|
464
|
+
}
|
|
506
465
|
// Log processing requires the note hashes in the tx in which the note was created. We are now assuming that the
|
|
507
466
|
// note was included in the same block in which the log was delivered - note that partial notes will not work this
|
|
508
467
|
// way.
|
|
509
|
-
const txEffect = await this.aztecNode.getTxEffect(
|
|
468
|
+
const txEffect = await this.aztecNode.getTxEffect(scopedLog.txHash);
|
|
510
469
|
if (!txEffect) {
|
|
511
|
-
throw new Error(`Could not find tx effect for tx hash ${
|
|
470
|
+
throw new Error(`Could not find tx effect for tx hash ${scopedLog.txHash}`);
|
|
512
471
|
}
|
|
513
472
|
// This will trigger calls to the deliverNote oracle
|
|
514
|
-
await this.callProcessLog(
|
|
473
|
+
await this.callProcessLog(contractAddress, scopedLog.log.toFields(), scopedLog.txHash, txEffect.data.noteHashes, txEffect.data.nullifiers[0], recipient, simulator);
|
|
515
474
|
}
|
|
516
475
|
return;
|
|
517
476
|
}
|
|
@@ -556,9 +515,7 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
556
515
|
if (txReceipt === undefined) {
|
|
557
516
|
throw new Error(`Failed to fetch tx receipt for tx hash ${txHash} when searching for note hashes`);
|
|
558
517
|
}
|
|
559
|
-
|
|
560
|
-
const recipientAddressPoint = await recipient.toAddressPoint();
|
|
561
|
-
const noteDao = new NoteDao(new Note(content), contractAddress, storageSlot, nonce, noteHash, siloedNullifier, new TxHash(txHash), txReceipt.blockNumber, txReceipt.blockHash.toString(), uniqueNoteHashTreeIndex, recipientAddressPoint, NoteSelector.empty());
|
|
518
|
+
const noteDao = new NoteDao(new Note(content), contractAddress, storageSlot, nonce, noteHash, siloedNullifier, new TxHash(txHash), txReceipt.blockNumber, txReceipt.blockHash.toString(), uniqueNoteHashTreeIndex, recipient);
|
|
562
519
|
await this.noteDataProvider.addNotes([
|
|
563
520
|
noteDao
|
|
564
521
|
], recipient);
|
|
@@ -578,7 +535,7 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
578
535
|
data: siloedNullifier,
|
|
579
536
|
...blockHashAndNum
|
|
580
537
|
}
|
|
581
|
-
],
|
|
538
|
+
], recipient);
|
|
582
539
|
this.log.verbose(`Removed just-added note`, {
|
|
583
540
|
contract: contractAddress,
|
|
584
541
|
slot: storageSlot,
|
|
@@ -599,23 +556,24 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
599
556
|
// TODO(#11627): handle this case
|
|
600
557
|
throw new Error(`Got ${logsForTag.length} logs for tag ${tag}. getLogByTag currently only supports a single log per tag`);
|
|
601
558
|
}
|
|
602
|
-
const
|
|
559
|
+
const scopedLog = logsForTag[0];
|
|
603
560
|
// getLogsByTag doesn't have all of the information that we need (notably note hashes and the first nullifier), so
|
|
604
561
|
// we need to make a second call to the node for `getTxEffect`.
|
|
605
562
|
// TODO(#9789): bundle this information in the `getLogsByTag` call.
|
|
606
|
-
const txEffect = await this.aztecNode.getTxEffect(
|
|
563
|
+
const txEffect = await this.aztecNode.getTxEffect(scopedLog.txHash);
|
|
607
564
|
if (txEffect == undefined) {
|
|
608
|
-
throw new Error(`Unexpected: failed to retrieve tx effects for tx ${
|
|
565
|
+
throw new Error(`Unexpected: failed to retrieve tx effects for tx ${scopedLog.txHash} which is known to exist`);
|
|
609
566
|
}
|
|
610
|
-
const reader = BufferReader.asReader(log.logData);
|
|
611
|
-
const logArray = reader.readArray(PUBLIC_LOG_DATA_SIZE_IN_FIELDS, Fr);
|
|
612
567
|
// Public logs always take up all available fields by padding with zeroes, and the length of the originally emitted
|
|
613
568
|
// log is lost. Until this is improved, we simply remove all of the zero elements (which are expected to be at the
|
|
614
569
|
// end).
|
|
615
570
|
// TODO(#11636): use the actual log length.
|
|
616
|
-
const trimmedLog =
|
|
617
|
-
return new LogWithTxData(trimmedLog,
|
|
571
|
+
const trimmedLog = scopedLog.log.toFields().filter((x)=>!x.isZero());
|
|
572
|
+
return new LogWithTxData(trimmedLog, scopedLog.txHash.hash, txEffect.data.noteHashes, txEffect.data.nullifiers[0]);
|
|
618
573
|
}
|
|
574
|
+
// TODO(#12553): nuke this as part of tackling that issue. This function is no longer unit tested as I had to remove
|
|
575
|
+
// it from pxe_oracle_interface.test.ts when moving decryption to Noir (at that point we could not get a hold of
|
|
576
|
+
// the decrypted note in the test as TS decryption no longer existed).
|
|
619
577
|
async removeNullifiedNotes(contractAddress) {
|
|
620
578
|
this.log.verbose('Searching for nullifiers of known notes', {
|
|
621
579
|
contract: contractAddress
|
|
@@ -623,7 +581,7 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
623
581
|
for (const recipient of (await this.keyStore.getAccounts())){
|
|
624
582
|
const currentNotesForRecipient = await this.noteDataProvider.getNotes({
|
|
625
583
|
contractAddress,
|
|
626
|
-
|
|
584
|
+
recipient
|
|
627
585
|
});
|
|
628
586
|
const nullifiersToCheck = currentNotesForRecipient.map((note)=>note.siloedNullifier);
|
|
629
587
|
const nullifierIndexes = await this.aztecNode.findNullifiersIndexesWithBlock('latest', nullifiersToCheck);
|
|
@@ -637,7 +595,7 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
637
595
|
};
|
|
638
596
|
}
|
|
639
597
|
}).filter((nullifier)=>nullifier !== undefined);
|
|
640
|
-
const nullifiedNotes = await this.noteDataProvider.removeNullifiedNotes(foundNullifiers,
|
|
598
|
+
const nullifiedNotes = await this.noteDataProvider.removeNullifiedNotes(foundNullifiers, recipient);
|
|
641
599
|
nullifiedNotes.forEach((noteDao)=>{
|
|
642
600
|
this.log.verbose(`Removed note for contract ${noteDao.contractAddress} at slot ${noteDao.storageSlot}`, {
|
|
643
601
|
contract: noteDao.contractAddress,
|
|
@@ -647,7 +605,7 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
647
605
|
});
|
|
648
606
|
}
|
|
649
607
|
}
|
|
650
|
-
async callProcessLog(contractAddress,
|
|
608
|
+
async callProcessLog(contractAddress, logCiphertext, txHash, noteHashes, firstNullifier, recipient, simulator) {
|
|
651
609
|
const artifact = await this.contractDataProvider.getFunctionArtifactByName(contractAddress, 'process_log');
|
|
652
610
|
if (!artifact) {
|
|
653
611
|
throw new Error(`Mandatory implementation of "process_log" missing in noir contract ${contractAddress.toString()}.`);
|
|
@@ -660,7 +618,7 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
660
618
|
type: FunctionType.UNCONSTRAINED,
|
|
661
619
|
isStatic: artifact.isStatic,
|
|
662
620
|
args: encodeArguments(artifact, [
|
|
663
|
-
toBoundedVec(
|
|
621
|
+
toBoundedVec(logCiphertext, PRIVATE_LOG_SIZE_IN_FIELDS),
|
|
664
622
|
txHash.toString(),
|
|
665
623
|
toBoundedVec(noteHashes, MAX_NOTE_HASHES_PER_TX),
|
|
666
624
|
firstNullifier,
|
|
@@ -682,6 +640,13 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
682
640
|
copyCapsule(contractAddress, srcSlot, dstSlot, numEntries) {
|
|
683
641
|
return this.capsuleDataProvider.copyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
|
|
684
642
|
}
|
|
643
|
+
async getSharedSecret(address, ephPk) {
|
|
644
|
+
// TODO(#12656): return an app-siloed secret
|
|
645
|
+
const recipientCompleteAddress = await this.getCompleteAddress(address);
|
|
646
|
+
const ivskM = await this.keyStore.getMasterSecretKey(recipientCompleteAddress.publicKeys.masterIncomingViewingPublicKey);
|
|
647
|
+
const addressSecret = await computeAddressSecret(await recipientCompleteAddress.getPreaddress(), ivskM);
|
|
648
|
+
return deriveEcdhSharedSecret(addressSecret, ephPk);
|
|
649
|
+
}
|
|
685
650
|
}
|
|
686
651
|
function toBoundedVec(array, maxLength) {
|
|
687
652
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pxe_service.d.ts","sourceRoot":"","sources":["../../src/pxe_service/pxe_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,KAAK,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAEL,KAAK,yBAAyB,EAE/B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAiB,KAAK,kBAAkB,EAAsB,MAAM,yBAAyB,CAAC;AACrG,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EAOtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,QAAQ,EACb,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"pxe_service.d.ts","sourceRoot":"","sources":["../../src/pxe_service/pxe_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,KAAK,KAAK,EAAE,MAAM,0BAA0B,CAAC;A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AAqB,CAAC;IAIvE;;;;OAIG;IACI,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,4BAA4B,CAAC;IA4BxE,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC;IAuBtC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IA6JxB,gBAAgB,CAAC,CAAC,EAC7B,gBAAgB,EAAE,uBAAuB,EACzC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EAEb,IAAI,EAAE,KAAK,EAAE,GACZ,OAAO,CAAC,CAAC,EAAE,CAAC;IAiET,eAAe,CAAC,CAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IA8BxG,iBAAiB;IAIvB,OAAO,CAAC,kBAAkB;CAa3B"}
|
|
@@ -286,17 +286,17 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
286
286
|
async getNotes(filter) {
|
|
287
287
|
const noteDaos = await this.noteDataProvider.getNotes(filter);
|
|
288
288
|
const extendedNotes = noteDaos.map(async (dao)=>{
|
|
289
|
-
let
|
|
290
|
-
if (
|
|
289
|
+
let recipient = filter.recipient;
|
|
290
|
+
if (recipient === undefined) {
|
|
291
291
|
const completeAddresses = await this.addressDataProvider.getCompleteAddresses();
|
|
292
|
-
const completeAddressIndex =
|
|
292
|
+
const completeAddressIndex = completeAddresses.findIndex((completeAddress)=>completeAddress.address.equals(dao.recipient));
|
|
293
293
|
const completeAddress = completeAddresses[completeAddressIndex];
|
|
294
294
|
if (completeAddress === undefined) {
|
|
295
|
-
throw new Error(`Cannot find complete address for
|
|
295
|
+
throw new Error(`Cannot find complete address for recipient ${dao.recipient.toString()}`);
|
|
296
296
|
}
|
|
297
|
-
|
|
297
|
+
recipient = completeAddress.address;
|
|
298
298
|
}
|
|
299
|
-
return new UniqueNote(dao.note,
|
|
299
|
+
return new UniqueNote(dao.note, recipient, dao.contractAddress, dao.storageSlot, dao.txHash, dao.nonce);
|
|
300
300
|
});
|
|
301
301
|
return Promise.all(extendedNotes);
|
|
302
302
|
}
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
5
5
|
import type { NoteData } from '@aztec/simulator/client';
|
|
6
|
-
import { NoteSelector } from '@aztec/stdlib/abi';
|
|
7
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
-
import type { PublicKey } from '@aztec/stdlib/keys';
|
|
9
7
|
import { Note } from '@aztec/stdlib/note';
|
|
10
8
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
11
9
|
/**
|
|
@@ -46,12 +44,11 @@ export declare class NoteDao implements NoteData {
|
|
|
46
44
|
l2BlockHash: string;
|
|
47
45
|
/** The index of the leaf in the global note hash tree the note is stored at */
|
|
48
46
|
index: bigint;
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* TODO(#12013): remove
|
|
47
|
+
/**
|
|
48
|
+
* The address whose public key was used to encrypt the note log during delivery.
|
|
49
|
+
* (This is the x-coordinate of the public key.)
|
|
53
50
|
*/
|
|
54
|
-
|
|
51
|
+
recipient: AztecAddress;
|
|
55
52
|
constructor(
|
|
56
53
|
/** The packed content of the note, as will be returned in the getNotes oracle. */
|
|
57
54
|
note: Note,
|
|
@@ -86,12 +83,11 @@ export declare class NoteDao implements NoteData {
|
|
|
86
83
|
l2BlockHash: string,
|
|
87
84
|
/** The index of the leaf in the global note hash tree the note is stored at */
|
|
88
85
|
index: bigint,
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
* TODO(#12013): remove
|
|
86
|
+
/**
|
|
87
|
+
* The address whose public key was used to encrypt the note log during delivery.
|
|
88
|
+
* (This is the x-coordinate of the public key.)
|
|
93
89
|
*/
|
|
94
|
-
|
|
90
|
+
recipient: AztecAddress);
|
|
95
91
|
toBuffer(): Buffer;
|
|
96
92
|
static fromBuffer(buffer: Buffer | BufferReader): NoteDao;
|
|
97
93
|
toString(): string;
|
|
@@ -101,6 +97,6 @@ export declare class NoteDao implements NoteData {
|
|
|
101
97
|
* @returns - Its size in bytes.
|
|
102
98
|
*/
|
|
103
99
|
getSize(): number;
|
|
104
|
-
static random({ note, contractAddress, storageSlot, nonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index,
|
|
100
|
+
static random({ note, contractAddress, storageSlot, nonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, recipient, }?: Partial<NoteDao>): Promise<NoteDao>;
|
|
105
101
|
}
|
|
106
102
|
//# sourceMappingURL=note_dao.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"note_dao.d.ts","sourceRoot":"","sources":["../../../src/storage/note_data_provider/note_dao.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,EAAE,EAAS,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"note_dao.d.ts","sourceRoot":"","sources":["../../../src/storage/note_data_provider/note_dao.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,EAAE,EAAS,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C;;;GAGG;AACH,qBAAa,OA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O,CAAM;CAezB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
2
2
|
import { Fr, Point } from '@aztec/foundation/fields';
|
|
3
3
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
-
import { NoteSelector } from '@aztec/stdlib/abi';
|
|
5
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
5
|
import { Note } from '@aztec/stdlib/note';
|
|
7
6
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
@@ -19,8 +18,7 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
19
18
|
l2BlockNumber;
|
|
20
19
|
l2BlockHash;
|
|
21
20
|
index;
|
|
22
|
-
|
|
23
|
-
noteTypeId;
|
|
21
|
+
recipient;
|
|
24
22
|
constructor(// Note information
|
|
25
23
|
/** The packed content of the note, as will be returned in the getNotes oracle. */ note, /** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */ contractAddress, /**
|
|
26
24
|
* The storage location of the note. This value is not used for anything in PXE, but we do index by storage slot
|
|
@@ -37,9 +35,10 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
37
35
|
* when searching for txEffects.
|
|
38
36
|
*/ txHash, /** The L2 block number in which the tx with this note was included. Used for note management while processing
|
|
39
37
|
* reorgs.*/ l2BlockNumber, /** The L2 block hash in which the tx with this note was included. Used for note management while processing
|
|
40
|
-
* reorgs.*/ l2BlockHash, /** The index of the leaf in the global note hash tree the note is stored at */ index, /**
|
|
41
|
-
*
|
|
42
|
-
|
|
38
|
+
* reorgs.*/ l2BlockHash, /** The index of the leaf in the global note hash tree the note is stored at */ index, /**
|
|
39
|
+
* The address whose public key was used to encrypt the note log during delivery.
|
|
40
|
+
* (This is the x-coordinate of the public key.)
|
|
41
|
+
*/ recipient){
|
|
43
42
|
this.note = note;
|
|
44
43
|
this.contractAddress = contractAddress;
|
|
45
44
|
this.storageSlot = storageSlot;
|
|
@@ -50,8 +49,7 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
50
49
|
this.l2BlockNumber = l2BlockNumber;
|
|
51
50
|
this.l2BlockHash = l2BlockHash;
|
|
52
51
|
this.index = index;
|
|
53
|
-
this.
|
|
54
|
-
this.noteTypeId = noteTypeId;
|
|
52
|
+
this.recipient = recipient;
|
|
55
53
|
}
|
|
56
54
|
toBuffer() {
|
|
57
55
|
return serializeToBuffer([
|
|
@@ -65,8 +63,7 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
65
63
|
this.l2BlockNumber,
|
|
66
64
|
Fr.fromHexString(this.l2BlockHash),
|
|
67
65
|
this.index,
|
|
68
|
-
this.
|
|
69
|
-
this.noteTypeId
|
|
66
|
+
this.recipient
|
|
70
67
|
]);
|
|
71
68
|
}
|
|
72
69
|
static fromBuffer(buffer) {
|
|
@@ -81,9 +78,8 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
81
78
|
const l2BlockNumber = reader.readNumber();
|
|
82
79
|
const l2BlockHash = Fr.fromBuffer(reader).toString();
|
|
83
80
|
const index = toBigIntBE(reader.readBytes(32));
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
return new NoteDao(note, contractAddress, storageSlot, nonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, publicKey, noteTypeId);
|
|
81
|
+
const recipient = AztecAddress.fromBuffer(reader);
|
|
82
|
+
return new NoteDao(note, contractAddress, storageSlot, nonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, recipient);
|
|
87
83
|
}
|
|
88
84
|
toString() {
|
|
89
85
|
return '0x' + this.toBuffer().toString('hex');
|
|
@@ -100,7 +96,7 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
100
96
|
const noteSize = 4 + this.note.items.length * Fr.SIZE_IN_BYTES;
|
|
101
97
|
return noteSize + AztecAddress.SIZE_IN_BYTES + Fr.SIZE_IN_BYTES * 4 + TxHash.SIZE + Point.SIZE_IN_BYTES + indexSize;
|
|
102
98
|
}
|
|
103
|
-
static async random({ note = Note.random(), contractAddress = undefined, storageSlot = Fr.random(), nonce = Fr.random(), noteHash = Fr.random(), siloedNullifier = Fr.random(), txHash = TxHash.random(), l2BlockNumber = Math.floor(Math.random() * 1000), l2BlockHash = Fr.random().toString(), index = Fr.random().toBigInt(),
|
|
104
|
-
return new NoteDao(note, contractAddress ?? await AztecAddress.random(), storageSlot, nonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index,
|
|
99
|
+
static async random({ note = Note.random(), contractAddress = undefined, storageSlot = Fr.random(), nonce = Fr.random(), noteHash = Fr.random(), siloedNullifier = Fr.random(), txHash = TxHash.random(), l2BlockNumber = Math.floor(Math.random() * 1000), l2BlockHash = Fr.random().toString(), index = Fr.random().toBigInt(), recipient = undefined } = {}) {
|
|
100
|
+
return new NoteDao(note, contractAddress ?? await AztecAddress.random(), storageSlot, nonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, recipient ?? await AztecAddress.random());
|
|
105
101
|
}
|
|
106
102
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Fr
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { InBlock } from '@aztec/stdlib/block';
|
|
@@ -14,7 +14,7 @@ export declare class NoteDataProvider implements DataProvider {
|
|
|
14
14
|
removeNotesAfter(blockNumber: number): Promise<void>;
|
|
15
15
|
unnullifyNotesAfter(blockNumber: number, synchedBlockNumber?: number): Promise<void>;
|
|
16
16
|
getNotes(filter: NotesFilter): Promise<NoteDao[]>;
|
|
17
|
-
removeNullifiedNotes(nullifiers: InBlock<Fr>[],
|
|
17
|
+
removeNullifiedNotes(nullifiers: InBlock<Fr>[], recipient: AztecAddress): Promise<NoteDao[]>;
|
|
18
18
|
getSize(): Promise<number>;
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=note_data_provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"note_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/note_data_provider/note_data_provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"note_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/note_data_provider/note_data_provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAqC,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,qBAAa,gBAAiB,YAAW,YAAY;;IAsBnD,OAAO;WAsBa,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAWlE,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBtD,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,GAAE,YAAgC,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBjF,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB9C,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkD3F,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAgGvD,oBAAoB,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IA6DtF,OAAO;CAGd"}
|