@aztec/pxe 0.36.0 → 0.38.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/config/index.d.ts +17 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -1
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -1
- package/dest/kernel_oracle/index.d.ts +1 -1
- package/dest/kernel_oracle/index.d.ts.map +1 -1
- package/dest/kernel_oracle/index.js +2 -2
- package/dest/kernel_prover/bb_prover/bb_native_proof_creator.d.ts +95 -0
- package/dest/kernel_prover/bb_prover/bb_native_proof_creator.d.ts.map +1 -0
- package/dest/kernel_prover/bb_prover/bb_native_proof_creator.js +437 -0
- package/dest/kernel_prover/{proof_creator.d.ts → interface/proof_creator.d.ts} +16 -35
- package/dest/kernel_prover/interface/proof_creator.d.ts.map +1 -0
- package/dest/kernel_prover/interface/proof_creator.js +2 -0
- package/dest/kernel_prover/kernel_prover.d.ts +4 -4
- package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
- package/dest/kernel_prover/kernel_prover.js +10 -37
- package/dest/kernel_prover/private_inputs_builders/build_private_kernel_tail_hints.d.ts +1 -1
- package/dest/kernel_prover/private_inputs_builders/build_private_kernel_tail_hints.d.ts.map +1 -1
- package/dest/kernel_prover/private_inputs_builders/build_private_kernel_tail_hints.js +4 -33
- package/dest/kernel_prover/proving_data_oracle.d.ts +1 -1
- package/dest/kernel_prover/proving_data_oracle.d.ts.map +1 -1
- package/dest/kernel_prover/test/test_circuit_prover.d.ts +16 -0
- package/dest/kernel_prover/test/test_circuit_prover.d.ts.map +1 -0
- package/dest/kernel_prover/test/test_circuit_prover.js +67 -0
- package/dest/pxe_service/create_pxe_service.d.ts +3 -1
- package/dest/pxe_service/create_pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/create_pxe_service.js +16 -3
- package/dest/pxe_service/pxe_service.d.ts +5 -4
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +16 -57
- package/dest/simulator_oracle/index.d.ts +5 -4
- package/dest/simulator_oracle/index.d.ts.map +1 -1
- package/dest/simulator_oracle/index.js +12 -3
- package/package.json +14 -12
- package/src/config/index.ts +19 -2
- package/src/index.ts +3 -0
- package/src/kernel_oracle/index.ts +1 -1
- package/src/kernel_prover/bb_prover/bb_native_proof_creator.ts +713 -0
- package/src/kernel_prover/interface/proof_creator.ts +79 -0
- package/src/kernel_prover/kernel_prover.ts +19 -48
- package/src/kernel_prover/private_inputs_builders/build_private_kernel_tail_hints.ts +5 -40
- package/src/kernel_prover/proving_data_oracle.ts +1 -1
- package/src/kernel_prover/test/test_circuit_prover.ts +96 -0
- package/src/pxe_service/create_pxe_service.ts +17 -1
- package/src/pxe_service/pxe_service.ts +31 -68
- package/src/simulator_oracle/index.ts +16 -7
- package/dest/kernel_prover/proof_creator.d.ts.map +0 -1
- package/dest/kernel_prover/proof_creator.js +0 -68
- package/src/kernel_prover/proof_creator.ts +0 -157
|
@@ -15,9 +15,10 @@ import {
|
|
|
15
15
|
type FunctionSelector,
|
|
16
16
|
type Header,
|
|
17
17
|
type L1_TO_L2_MSG_TREE_HEIGHT,
|
|
18
|
+
type Point,
|
|
18
19
|
} from '@aztec/circuits.js';
|
|
19
20
|
import { computeL1ToL2MessageNullifier } from '@aztec/circuits.js/hash';
|
|
20
|
-
import { type
|
|
21
|
+
import { type FunctionArtifact, getFunctionArtifact } from '@aztec/foundation/abi';
|
|
21
22
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
22
23
|
import { type DBOracle, MessageLoadOracleInputs, type NullifierKeys } from '@aztec/simulator';
|
|
23
24
|
import { type ContractInstance } from '@aztec/types/contracts';
|
|
@@ -43,6 +44,7 @@ export class SimulatorOracle implements DBOracle {
|
|
|
43
44
|
return { masterNullifierPublicKey, appNullifierSecretKey };
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
// TODO: #5834
|
|
46
48
|
async getCompleteAddress(address: AztecAddress): Promise<CompleteAddress> {
|
|
47
49
|
const completeAddress = await this.db.getCompleteAddress(address);
|
|
48
50
|
if (!completeAddress) {
|
|
@@ -77,6 +79,16 @@ export class SimulatorOracle implements DBOracle {
|
|
|
77
79
|
return capsule;
|
|
78
80
|
}
|
|
79
81
|
|
|
82
|
+
// TODO: #5834
|
|
83
|
+
async getPublicKeysForAddress(address: AztecAddress): Promise<Point[]> {
|
|
84
|
+
const nullifierPublicKey = await this.keyStore.getMasterNullifierPublicKey(address);
|
|
85
|
+
const incomingViewingPublicKey = await this.keyStore.getMasterIncomingViewingPublicKey(address);
|
|
86
|
+
const outgoingViewingPublicKey = await this.keyStore.getMasterOutgoingViewingPublicKey(address);
|
|
87
|
+
const taggingPublicKey = await this.keyStore.getMasterTaggingPublicKey(address);
|
|
88
|
+
|
|
89
|
+
return [nullifierPublicKey, incomingViewingPublicKey, outgoingViewingPublicKey, taggingPublicKey];
|
|
90
|
+
}
|
|
91
|
+
|
|
80
92
|
async getNotes(contractAddress: AztecAddress, storageSlot: Fr, status: NoteStatus) {
|
|
81
93
|
const noteDaos = await this.db.getNotes({
|
|
82
94
|
contractAddress,
|
|
@@ -95,10 +107,7 @@ export class SimulatorOracle implements DBOracle {
|
|
|
95
107
|
}));
|
|
96
108
|
}
|
|
97
109
|
|
|
98
|
-
async getFunctionArtifact(
|
|
99
|
-
contractAddress: AztecAddress,
|
|
100
|
-
selector: FunctionSelector,
|
|
101
|
-
): Promise<FunctionArtifactWithDebugMetadata> {
|
|
110
|
+
async getFunctionArtifact(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionArtifact> {
|
|
102
111
|
const artifact = await this.contractDataOracle.getFunctionArtifact(contractAddress, selector);
|
|
103
112
|
const debug = await this.contractDataOracle.getFunctionDebugMetadata(contractAddress, selector);
|
|
104
113
|
return {
|
|
@@ -110,10 +119,10 @@ export class SimulatorOracle implements DBOracle {
|
|
|
110
119
|
async getFunctionArtifactByName(
|
|
111
120
|
contractAddress: AztecAddress,
|
|
112
121
|
functionName: string,
|
|
113
|
-
): Promise<
|
|
122
|
+
): Promise<FunctionArtifact | undefined> {
|
|
114
123
|
const instance = await this.contractDataOracle.getContractInstance(contractAddress);
|
|
115
124
|
const artifact = await this.contractDataOracle.getContractArtifact(instance.contractClassId);
|
|
116
|
-
return artifact &&
|
|
125
|
+
return artifact && getFunctionArtifact(artifact, functionName);
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
/**
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proof_creator.d.ts","sourceRoot":"","sources":["../../src/kernel_prover/proof_creator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,gCAAgC,EACrC,KAAK,qCAAqC,EAC1C,KAAK,sCAAsC,EAC3C,KAAK,qCAAqC,EAC1C,KAAK,oCAAoC,EACzC,KAAK,KAAK,EAEX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAKnD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,YAAY,EAAE,gCAAgC,CAAC;IAC/C;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,YAAY,EAAE,oCAAoC,CAAC;IACnD;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,oBAAoB,CAAC,YAAY,EAAE,0BAA0B,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IAE9E;;;;;OAKG;IACH,eAAe,CAAC,uBAAuB,EAAE,qCAAqC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAEtG;;;;;OAKG;IACH,gBAAgB,CAAC,wBAAwB,EAAE,sCAAsC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAEzG;;;;;OAKG;IACH,eAAe,CAAC,uBAAuB,EAAE,qCAAqC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC5G;AAED;;;;;;GAMG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACzC,OAAO,CAAC,GAAG;gBAAH,GAAG,yCAAkD;IAElE,oBAAoB,CAAC,YAAY,EAAE,0BAA0B;IAQvD,eAAe,CAAC,aAAa,EAAE,qCAAqC,GAAG,OAAO,CAAC,WAAW,CAAC;IAiB3F,gBAAgB,CAAC,aAAa,EAAE,sCAAsC,GAAG,OAAO,CAAC,WAAW,CAAC;IAiB7F,eAAe,CAAC,aAAa,EAAE,qCAAqC,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAmB9G"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { makeEmptyProof, } from '@aztec/circuits.js';
|
|
2
|
-
import { siloNoteHash } from '@aztec/circuits.js/hash';
|
|
3
|
-
import { createDebugLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { elapsed } from '@aztec/foundation/timer';
|
|
5
|
-
import { executeInit, executeInner, executeTail, executeTailForPublic } from '@aztec/noir-protocol-circuits-types';
|
|
6
|
-
/**
|
|
7
|
-
* The KernelProofCreator class is responsible for generating siloed commitments and zero-knowledge proofs
|
|
8
|
-
* for private kernel circuit. It leverages Barretenberg to perform cryptographic operations and proof creation.
|
|
9
|
-
* The class provides methods to compute commitments based on the given public inputs and to generate proofs based on
|
|
10
|
-
* signed transaction requests, previous kernel data, private call data, and a flag indicating whether it's the first
|
|
11
|
-
* iteration or not.
|
|
12
|
-
*/
|
|
13
|
-
export class KernelProofCreator {
|
|
14
|
-
constructor(log = createDebugLogger('aztec:kernel_proof_creator')) {
|
|
15
|
-
this.log = log;
|
|
16
|
-
}
|
|
17
|
-
getSiloedCommitments(publicInputs) {
|
|
18
|
-
const contractAddress = publicInputs.callContext.storageContractAddress;
|
|
19
|
-
return Promise.resolve(publicInputs.newNoteHashes.map(commitment => siloNoteHash(contractAddress, commitment.value)));
|
|
20
|
-
}
|
|
21
|
-
async createProofInit(privateInputs) {
|
|
22
|
-
const [duration, result] = await elapsed(() => executeInit(privateInputs));
|
|
23
|
-
this.log.debug(`Simulated private kernel init`, {
|
|
24
|
-
eventName: 'circuit-simulation',
|
|
25
|
-
circuitName: 'private-kernel-init',
|
|
26
|
-
duration,
|
|
27
|
-
inputSize: privateInputs.toBuffer().length,
|
|
28
|
-
outputSize: result.toBuffer().length,
|
|
29
|
-
});
|
|
30
|
-
const proof = makeEmptyProof();
|
|
31
|
-
return {
|
|
32
|
-
publicInputs: result,
|
|
33
|
-
proof: proof,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
async createProofInner(privateInputs) {
|
|
37
|
-
const [duration, result] = await elapsed(() => executeInner(privateInputs));
|
|
38
|
-
this.log.debug(`Simulated private kernel inner`, {
|
|
39
|
-
eventName: 'circuit-simulation',
|
|
40
|
-
circuitName: 'private-kernel-inner',
|
|
41
|
-
duration,
|
|
42
|
-
inputSize: privateInputs.toBuffer().length,
|
|
43
|
-
outputSize: result.toBuffer().length,
|
|
44
|
-
});
|
|
45
|
-
const proof = makeEmptyProof();
|
|
46
|
-
return {
|
|
47
|
-
publicInputs: result,
|
|
48
|
-
proof: proof,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
async createProofTail(privateInputs) {
|
|
52
|
-
const isForPublic = privateInputs.isForPublic();
|
|
53
|
-
const [duration, result] = await elapsed(() => isForPublic ? executeTailForPublic(privateInputs) : executeTail(privateInputs));
|
|
54
|
-
this.log.debug(`Simulated private kernel ordering`, {
|
|
55
|
-
eventName: 'circuit-simulation',
|
|
56
|
-
circuitName: 'private-kernel-ordering',
|
|
57
|
-
duration,
|
|
58
|
-
inputSize: privateInputs.toBuffer().length,
|
|
59
|
-
outputSize: result.toBuffer().length,
|
|
60
|
-
});
|
|
61
|
-
const proof = makeEmptyProof();
|
|
62
|
-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
import {
|
|
3
|
-
type PrivateCircuitPublicInputs,
|
|
4
|
-
type PrivateKernelCircuitPublicInputs,
|
|
5
|
-
type PrivateKernelInitCircuitPrivateInputs,
|
|
6
|
-
type PrivateKernelInnerCircuitPrivateInputs,
|
|
7
|
-
type PrivateKernelTailCircuitPrivateInputs,
|
|
8
|
-
type PrivateKernelTailCircuitPublicInputs,
|
|
9
|
-
type Proof,
|
|
10
|
-
makeEmptyProof,
|
|
11
|
-
} from '@aztec/circuits.js';
|
|
12
|
-
import { siloNoteHash } from '@aztec/circuits.js/hash';
|
|
13
|
-
import { type Fr } from '@aztec/foundation/fields';
|
|
14
|
-
import { createDebugLogger } from '@aztec/foundation/log';
|
|
15
|
-
import { elapsed } from '@aztec/foundation/timer';
|
|
16
|
-
import { executeInit, executeInner, executeTail, executeTailForPublic } from '@aztec/noir-protocol-circuits-types';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Represents the output of the proof creation process for init and inner private kernel circuit.
|
|
20
|
-
* Contains the public inputs required for the init and inner private kernel circuit and the generated proof.
|
|
21
|
-
*/
|
|
22
|
-
export interface ProofOutput {
|
|
23
|
-
/**
|
|
24
|
-
* The public inputs required for the proof generation process.
|
|
25
|
-
*/
|
|
26
|
-
publicInputs: PrivateKernelCircuitPublicInputs;
|
|
27
|
-
/**
|
|
28
|
-
* The zk-SNARK proof for the kernel execution.
|
|
29
|
-
*/
|
|
30
|
-
proof: Proof;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Represents the output of the proof creation process for final ordering private kernel circuit.
|
|
35
|
-
* Contains the public inputs required for the final ordering private kernel circuit and the generated proof.
|
|
36
|
-
*/
|
|
37
|
-
export interface ProofOutputFinal {
|
|
38
|
-
/**
|
|
39
|
-
* The public inputs required for the proof generation process.
|
|
40
|
-
*/
|
|
41
|
-
publicInputs: PrivateKernelTailCircuitPublicInputs;
|
|
42
|
-
/**
|
|
43
|
-
* The zk-SNARK proof for the kernel execution.
|
|
44
|
-
*/
|
|
45
|
-
proof: Proof;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* ProofCreator provides functionality to create and validate proofs, and retrieve
|
|
50
|
-
* siloed commitments necessary for maintaining transaction privacy and security on the network.
|
|
51
|
-
*/
|
|
52
|
-
export interface ProofCreator {
|
|
53
|
-
/**
|
|
54
|
-
* Computes the siloed commitments for a given set of public inputs.
|
|
55
|
-
*
|
|
56
|
-
* @param publicInputs - The public inputs containing the contract address and new note hashes to be used in generating siloed note hashes.
|
|
57
|
-
* @returns An array of Fr (finite field) elements representing the siloed commitments.
|
|
58
|
-
*/
|
|
59
|
-
getSiloedCommitments(publicInputs: PrivateCircuitPublicInputs): Promise<Fr[]>;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Creates a proof output for a given signed transaction request and private call data for the first iteration.
|
|
63
|
-
*
|
|
64
|
-
* @param privateKernelInputsInit - The private data structure for the initial iteration.
|
|
65
|
-
* @returns A Promise resolving to a ProofOutput object containing public inputs and the kernel proof.
|
|
66
|
-
*/
|
|
67
|
-
createProofInit(privateKernelInputsInit: PrivateKernelInitCircuitPrivateInputs): Promise<ProofOutput>;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Creates a proof output for a given previous kernel data and private call data for an inner iteration.
|
|
71
|
-
*
|
|
72
|
-
* @param privateKernelInputsInner - The private input data structure for the inner iteration.
|
|
73
|
-
* @returns A Promise resolving to a ProofOutput object containing public inputs and the kernel proof.
|
|
74
|
-
*/
|
|
75
|
-
createProofInner(privateKernelInputsInner: PrivateKernelInnerCircuitPrivateInputs): Promise<ProofOutput>;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Creates a proof output based on the last inner kernel iteration kernel data for the final ordering iteration.
|
|
79
|
-
*
|
|
80
|
-
* @param privateKernelInputsTail - The private input data structure for the final ordering iteration.
|
|
81
|
-
* @returns A Promise resolving to a ProofOutput object containing public inputs and the kernel proof.
|
|
82
|
-
*/
|
|
83
|
-
createProofTail(privateKernelInputsTail: PrivateKernelTailCircuitPrivateInputs): Promise<ProofOutputFinal>;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The KernelProofCreator class is responsible for generating siloed commitments and zero-knowledge proofs
|
|
88
|
-
* for private kernel circuit. It leverages Barretenberg to perform cryptographic operations and proof creation.
|
|
89
|
-
* The class provides methods to compute commitments based on the given public inputs and to generate proofs based on
|
|
90
|
-
* signed transaction requests, previous kernel data, private call data, and a flag indicating whether it's the first
|
|
91
|
-
* iteration or not.
|
|
92
|
-
*/
|
|
93
|
-
export class KernelProofCreator implements ProofCreator {
|
|
94
|
-
constructor(private log = createDebugLogger('aztec:kernel_proof_creator')) {}
|
|
95
|
-
|
|
96
|
-
public getSiloedCommitments(publicInputs: PrivateCircuitPublicInputs) {
|
|
97
|
-
const contractAddress = publicInputs.callContext.storageContractAddress;
|
|
98
|
-
|
|
99
|
-
return Promise.resolve(
|
|
100
|
-
publicInputs.newNoteHashes.map(commitment => siloNoteHash(contractAddress, commitment.value)),
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public async createProofInit(privateInputs: PrivateKernelInitCircuitPrivateInputs): Promise<ProofOutput> {
|
|
105
|
-
const [duration, result] = await elapsed(() => executeInit(privateInputs));
|
|
106
|
-
this.log.debug(`Simulated private kernel init`, {
|
|
107
|
-
eventName: 'circuit-simulation',
|
|
108
|
-
circuitName: 'private-kernel-init',
|
|
109
|
-
duration,
|
|
110
|
-
inputSize: privateInputs.toBuffer().length,
|
|
111
|
-
outputSize: result.toBuffer().length,
|
|
112
|
-
} satisfies CircuitSimulationStats);
|
|
113
|
-
const proof = makeEmptyProof();
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
publicInputs: result,
|
|
117
|
-
proof: proof,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public async createProofInner(privateInputs: PrivateKernelInnerCircuitPrivateInputs): Promise<ProofOutput> {
|
|
122
|
-
const [duration, result] = await elapsed(() => executeInner(privateInputs));
|
|
123
|
-
this.log.debug(`Simulated private kernel inner`, {
|
|
124
|
-
eventName: 'circuit-simulation',
|
|
125
|
-
circuitName: 'private-kernel-inner',
|
|
126
|
-
duration,
|
|
127
|
-
inputSize: privateInputs.toBuffer().length,
|
|
128
|
-
outputSize: result.toBuffer().length,
|
|
129
|
-
} satisfies CircuitSimulationStats);
|
|
130
|
-
const proof = makeEmptyProof();
|
|
131
|
-
|
|
132
|
-
return {
|
|
133
|
-
publicInputs: result,
|
|
134
|
-
proof: proof,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
public async createProofTail(privateInputs: PrivateKernelTailCircuitPrivateInputs): Promise<ProofOutputFinal> {
|
|
139
|
-
const isForPublic = privateInputs.isForPublic();
|
|
140
|
-
const [duration, result] = await elapsed(() =>
|
|
141
|
-
isForPublic ? executeTailForPublic(privateInputs) : executeTail(privateInputs),
|
|
142
|
-
);
|
|
143
|
-
this.log.debug(`Simulated private kernel ordering`, {
|
|
144
|
-
eventName: 'circuit-simulation',
|
|
145
|
-
circuitName: 'private-kernel-ordering',
|
|
146
|
-
duration,
|
|
147
|
-
inputSize: privateInputs.toBuffer().length,
|
|
148
|
-
outputSize: result.toBuffer().length,
|
|
149
|
-
} satisfies CircuitSimulationStats);
|
|
150
|
-
const proof = makeEmptyProof();
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
publicInputs: result,
|
|
154
|
-
proof: proof,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
}
|