@aztec/pxe 0.46.2 → 0.46.3
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/kernel_prover/kernel_prover.d.ts +5 -4
- package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
- package/dest/kernel_prover/kernel_prover.js +50 -22
- package/dest/kernel_prover/test/test_circuit_prover.d.ts +11 -9
- package/dest/kernel_prover/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/kernel_prover/test/test_circuit_prover.js +17 -15
- package/dest/pxe_service/create_pxe_service.d.ts +2 -2
- package/dest/pxe_service/create_pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/create_pxe_service.js +5 -5
- package/dest/pxe_service/pxe_service.d.ts +2 -2
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +5 -5
- package/package.json +16 -14
- package/src/kernel_prover/kernel_prover.ts +85 -43
- package/src/kernel_prover/test/test_circuit_prover.ts +39 -23
- package/src/pxe_service/create_pxe_service.ts +7 -7
- package/src/pxe_service/pxe_service.ts +10 -7
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type AppCircuitSimulateOutput,
|
|
3
|
+
type PrivateKernelProver,
|
|
4
|
+
type PrivateKernelSimulateOutput,
|
|
5
|
+
} from '@aztec/circuit-types';
|
|
2
6
|
import type { CircuitName, CircuitSimulationStats } from '@aztec/circuit-types/stats';
|
|
3
7
|
import {
|
|
4
|
-
|
|
8
|
+
ClientIvcProof,
|
|
5
9
|
type PrivateCircuitPublicInputs,
|
|
6
10
|
type PrivateKernelCircuitPublicInputs,
|
|
7
11
|
type PrivateKernelInitCircuitPrivateInputs,
|
|
@@ -9,9 +13,7 @@ import {
|
|
|
9
13
|
type PrivateKernelResetCircuitPrivateInputsVariants,
|
|
10
14
|
type PrivateKernelTailCircuitPrivateInputs,
|
|
11
15
|
type PrivateKernelTailCircuitPublicInputs,
|
|
12
|
-
RECURSIVE_PROOF_LENGTH,
|
|
13
16
|
VerificationKeyAsFields,
|
|
14
|
-
makeRecursiveProof,
|
|
15
17
|
} from '@aztec/circuits.js';
|
|
16
18
|
import { siloNoteHash } from '@aztec/circuits.js/hash';
|
|
17
19
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
@@ -26,21 +28,27 @@ import {
|
|
|
26
28
|
executeTailForPublic,
|
|
27
29
|
} from '@aztec/noir-protocol-circuits-types';
|
|
28
30
|
|
|
31
|
+
import { type WitnessMap } from '@noir-lang/types';
|
|
32
|
+
|
|
29
33
|
/**
|
|
30
34
|
* Test Proof Creator executes circuit simulations and provides fake proofs.
|
|
31
35
|
*/
|
|
32
|
-
export class
|
|
36
|
+
export class TestPrivateKernelProver implements PrivateKernelProver {
|
|
33
37
|
constructor(private log = createDebugLogger('aztec:test_proof_creator')) {}
|
|
34
38
|
|
|
39
|
+
createClientIvcProof(_acirs: Buffer[], _witnessStack: WitnessMap[]): Promise<ClientIvcProof> {
|
|
40
|
+
return Promise.resolve(ClientIvcProof.empty());
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
public getSiloedCommitments(publicInputs: PrivateCircuitPublicInputs) {
|
|
36
44
|
const contractAddress = publicInputs.callContext.storageContractAddress;
|
|
37
45
|
|
|
38
46
|
return Promise.resolve(publicInputs.noteHashes.map(commitment => siloNoteHash(contractAddress, commitment.value)));
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
public async
|
|
49
|
+
public async simulateProofInit(
|
|
42
50
|
privateInputs: PrivateKernelInitCircuitPrivateInputs,
|
|
43
|
-
): Promise<
|
|
51
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
44
52
|
const [duration, result] = await elapsed(() => executeInit(privateInputs));
|
|
45
53
|
this.log.debug(`Simulated private kernel init`, {
|
|
46
54
|
eventName: 'circuit-simulation',
|
|
@@ -49,12 +57,12 @@ export class TestProofCreator implements ProofCreator {
|
|
|
49
57
|
inputSize: privateInputs.toBuffer().length,
|
|
50
58
|
outputSize: result.toBuffer().length,
|
|
51
59
|
} satisfies CircuitSimulationStats);
|
|
52
|
-
return this.
|
|
60
|
+
return this.makeEmptyKernelSimulateOutput<PrivateKernelCircuitPublicInputs>(result, 'PrivateKernelInitArtifact');
|
|
53
61
|
}
|
|
54
62
|
|
|
55
|
-
public async
|
|
63
|
+
public async simulateProofInner(
|
|
56
64
|
privateInputs: PrivateKernelInnerCircuitPrivateInputs,
|
|
57
|
-
): Promise<
|
|
65
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
58
66
|
const [duration, result] = await elapsed(() => executeInner(privateInputs));
|
|
59
67
|
this.log.debug(`Simulated private kernel inner`, {
|
|
60
68
|
eventName: 'circuit-simulation',
|
|
@@ -63,12 +71,12 @@ export class TestProofCreator implements ProofCreator {
|
|
|
63
71
|
inputSize: privateInputs.toBuffer().length,
|
|
64
72
|
outputSize: result.toBuffer().length,
|
|
65
73
|
} satisfies CircuitSimulationStats);
|
|
66
|
-
return this.
|
|
74
|
+
return this.makeEmptyKernelSimulateOutput<PrivateKernelCircuitPublicInputs>(result, 'PrivateKernelInnerArtifact');
|
|
67
75
|
}
|
|
68
76
|
|
|
69
|
-
public async
|
|
77
|
+
public async simulateProofReset(
|
|
70
78
|
privateInputs: PrivateKernelResetCircuitPrivateInputsVariants,
|
|
71
|
-
): Promise<
|
|
79
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
72
80
|
const [duration, result] = await elapsed(() => executeReset(privateInputs));
|
|
73
81
|
this.log.debug(`Simulated private kernel reset`, {
|
|
74
82
|
eventName: 'circuit-simulation',
|
|
@@ -77,12 +85,15 @@ export class TestProofCreator implements ProofCreator {
|
|
|
77
85
|
inputSize: privateInputs.toBuffer().length,
|
|
78
86
|
outputSize: result.toBuffer().length,
|
|
79
87
|
} satisfies CircuitSimulationStats);
|
|
80
|
-
return this.
|
|
88
|
+
return this.makeEmptyKernelSimulateOutput<PrivateKernelCircuitPublicInputs>(
|
|
89
|
+
result,
|
|
90
|
+
'PrivateKernelResetFullArtifact',
|
|
91
|
+
);
|
|
81
92
|
}
|
|
82
93
|
|
|
83
|
-
public async
|
|
94
|
+
public async simulateProofTail(
|
|
84
95
|
privateInputs: PrivateKernelTailCircuitPrivateInputs,
|
|
85
|
-
): Promise<
|
|
96
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
86
97
|
const isForPublic = privateInputs.isForPublic();
|
|
87
98
|
const [duration, result] = await elapsed(() =>
|
|
88
99
|
isForPublic ? executeTailForPublic(privateInputs) : executeTail(privateInputs),
|
|
@@ -94,25 +105,30 @@ export class TestProofCreator implements ProofCreator {
|
|
|
94
105
|
inputSize: privateInputs.toBuffer().length,
|
|
95
106
|
outputSize: result.toBuffer().length,
|
|
96
107
|
} satisfies CircuitSimulationStats);
|
|
97
|
-
return this.
|
|
108
|
+
return this.makeEmptyKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>(
|
|
98
109
|
result,
|
|
99
110
|
isForPublic ? 'PrivateKernelTailToPublicArtifact' : 'PrivateKernelTailArtifact',
|
|
100
111
|
);
|
|
101
112
|
}
|
|
102
113
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
computeAppCircuitVerificationKey(
|
|
115
|
+
_bytecode: Buffer,
|
|
116
|
+
_appCircuitName?: string | undefined,
|
|
117
|
+
): Promise<AppCircuitSimulateOutput> {
|
|
118
|
+
const appCircuitProofOutput: AppCircuitSimulateOutput = {
|
|
106
119
|
verificationKey: VerificationKeyAsFields.makeEmpty(),
|
|
107
120
|
};
|
|
108
121
|
return Promise.resolve(appCircuitProofOutput);
|
|
109
122
|
}
|
|
110
123
|
|
|
111
|
-
private
|
|
112
|
-
|
|
124
|
+
private makeEmptyKernelSimulateOutput<PublicInputsType>(
|
|
125
|
+
publicInputs: PublicInputsType,
|
|
126
|
+
circuitType: ProtocolArtifact,
|
|
127
|
+
) {
|
|
128
|
+
const kernelProofOutput: PrivateKernelSimulateOutput<PublicInputsType> = {
|
|
113
129
|
publicInputs,
|
|
114
|
-
proof: makeRecursiveProof<typeof NESTED_RECURSIVE_PROOF_LENGTH>(NESTED_RECURSIVE_PROOF_LENGTH),
|
|
115
130
|
verificationKey: ProtocolCircuitVks[circuitType].keyAsFields,
|
|
131
|
+
outputWitness: new Map(),
|
|
116
132
|
};
|
|
117
133
|
return kernelProofOutput;
|
|
118
134
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type AztecNode, type
|
|
1
|
+
import { BBNativePrivateKernelProver } from '@aztec/bb-prover';
|
|
2
|
+
import { type AztecNode, type PrivateKernelProver } from '@aztec/circuit-types';
|
|
3
3
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
4
4
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { KeyStore } from '@aztec/key-store';
|
|
@@ -16,7 +16,7 @@ import { join } from 'path';
|
|
|
16
16
|
|
|
17
17
|
import { type PXEServiceConfig } from '../config/index.js';
|
|
18
18
|
import { KVPxeDatabase } from '../database/kv_pxe_database.js';
|
|
19
|
-
import {
|
|
19
|
+
import { TestPrivateKernelProver } from '../kernel_prover/test/test_circuit_prover.js';
|
|
20
20
|
import { PXEService } from './pxe_service.js';
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -34,7 +34,7 @@ export async function createPXEService(
|
|
|
34
34
|
aztecNode: AztecNode,
|
|
35
35
|
config: PXEServiceConfig,
|
|
36
36
|
useLogSuffix: string | boolean | undefined = undefined,
|
|
37
|
-
proofCreator?:
|
|
37
|
+
proofCreator?: PrivateKernelProver,
|
|
38
38
|
) {
|
|
39
39
|
const logSuffix =
|
|
40
40
|
typeof useLogSuffix === 'boolean' ? (useLogSuffix ? randomBytes(3).toString('hex') : undefined) : useLogSuffix;
|
|
@@ -47,14 +47,14 @@ export async function createPXEService(
|
|
|
47
47
|
const db = new KVPxeDatabase(await initStoreForRollup(AztecLmdbStore.open(pxeDbPath), l1Contracts.rollupAddress));
|
|
48
48
|
|
|
49
49
|
// (@PhilWindle) Temporary validation until WASM is implemented
|
|
50
|
-
let prover:
|
|
50
|
+
let prover: PrivateKernelProver | undefined = proofCreator;
|
|
51
51
|
if (!prover) {
|
|
52
52
|
if (config.proverEnabled && (!config.bbBinaryPath || !config.bbWorkingDirectory)) {
|
|
53
53
|
throw new Error(`Prover must be configured with binary path and working directory`);
|
|
54
54
|
}
|
|
55
55
|
prover = !config.proverEnabled
|
|
56
|
-
? new
|
|
57
|
-
: new
|
|
56
|
+
? new TestPrivateKernelProver()
|
|
57
|
+
: new BBNativePrivateKernelProver(
|
|
58
58
|
config.bbBinaryPath!,
|
|
59
59
|
config.bbWorkingDirectory!,
|
|
60
60
|
createDebugLogger('aztec:pxe:bb-native-prover' + (logSuffix ? `:${logSuffix}` : '')),
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
type OutgoingNotesFilter,
|
|
17
17
|
type PXE,
|
|
18
18
|
type PXEInfo,
|
|
19
|
-
type
|
|
19
|
+
type PrivateKernelProver,
|
|
20
20
|
SimulatedTx,
|
|
21
21
|
SimulationError,
|
|
22
22
|
TaggedLog,
|
|
@@ -72,7 +72,7 @@ import { IncomingNoteDao } from '../database/incoming_note_dao.js';
|
|
|
72
72
|
import { type PxeDatabase } from '../database/index.js';
|
|
73
73
|
import { KernelOracle } from '../kernel_oracle/index.js';
|
|
74
74
|
import { KernelProver } from '../kernel_prover/kernel_prover.js';
|
|
75
|
-
import {
|
|
75
|
+
import { TestPrivateKernelProver } from '../kernel_prover/test/test_circuit_prover.js';
|
|
76
76
|
import { getAcirSimulator } from '../simulator/index.js';
|
|
77
77
|
import { Synchronizer } from '../synchronizer/index.js';
|
|
78
78
|
|
|
@@ -89,13 +89,13 @@ export class PXEService implements PXE {
|
|
|
89
89
|
// ensures that state is not changed while simulating
|
|
90
90
|
private jobQueue = new SerialQueue();
|
|
91
91
|
|
|
92
|
-
private fakeProofCreator = new
|
|
92
|
+
private fakeProofCreator = new TestPrivateKernelProver();
|
|
93
93
|
|
|
94
94
|
constructor(
|
|
95
95
|
private keyStore: KeyStore,
|
|
96
96
|
private node: AztecNode,
|
|
97
97
|
private db: PxeDatabase,
|
|
98
|
-
private proofCreator:
|
|
98
|
+
private proofCreator: PrivateKernelProver,
|
|
99
99
|
private config: PXEServiceConfig,
|
|
100
100
|
logSuffix?: string,
|
|
101
101
|
) {
|
|
@@ -750,7 +750,7 @@ export class PXEService implements PXE {
|
|
|
750
750
|
*/
|
|
751
751
|
async #simulateAndProve(
|
|
752
752
|
txExecutionRequest: TxExecutionRequest,
|
|
753
|
-
proofCreator:
|
|
753
|
+
proofCreator: PrivateKernelProver,
|
|
754
754
|
msgSender?: AztecAddress,
|
|
755
755
|
): Promise<SimulatedTx> {
|
|
756
756
|
// Get values that allow us to reconstruct the block hash
|
|
@@ -759,7 +759,10 @@ export class PXEService implements PXE {
|
|
|
759
759
|
const kernelOracle = new KernelOracle(this.contractDataOracle, this.keyStore, this.node);
|
|
760
760
|
const kernelProver = new KernelProver(kernelOracle, proofCreator);
|
|
761
761
|
this.log.debug(`Executing kernel prover...`);
|
|
762
|
-
const {
|
|
762
|
+
const { clientIvcProof, publicInputs } = await kernelProver.prove(
|
|
763
|
+
txExecutionRequest.toTxRequest(),
|
|
764
|
+
executionResult,
|
|
765
|
+
);
|
|
763
766
|
|
|
764
767
|
const noteEncryptedLogs = new EncryptedNoteTxL2Logs([collectSortedNoteEncryptedLogs(executionResult)]);
|
|
765
768
|
const unencryptedLogs = new UnencryptedTxL2Logs([collectSortedUnencryptedLogs(executionResult)]);
|
|
@@ -769,7 +772,7 @@ export class PXEService implements PXE {
|
|
|
769
772
|
|
|
770
773
|
const tx = new Tx(
|
|
771
774
|
publicInputs,
|
|
772
|
-
|
|
775
|
+
clientIvcProof!,
|
|
773
776
|
noteEncryptedLogs,
|
|
774
777
|
encryptedLogs,
|
|
775
778
|
unencryptedLogs,
|