@aztec/pxe 0.81.0 → 0.82.1-alpha-testnet.1
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.js +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/entrypoints/server/utils.d.ts +15 -7
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +17 -9
- package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.d.ts +2 -2
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
- package/dest/private_kernel/hints/index.d.ts.map +1 -0
- package/dest/private_kernel/index.d.ts +3 -0
- package/dest/private_kernel/index.d.ts.map +1 -0
- package/dest/private_kernel/index.js +2 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +36 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
- package/dest/{kernel_prover/kernel_prover.js → private_kernel/private_kernel_execution_prover.js} +67 -76
- package/dest/{kernel_prover/proving_data_oracle.d.ts → private_kernel/private_kernel_oracle.d.ts} +17 -28
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_oracle.js +4 -0
- package/dest/{kernel_oracle/index.d.ts → private_kernel/private_kernel_oracle_impl.d.ts} +6 -6
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
- package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +13 -3
- package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts +7 -16
- package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/pxe_oracle_interface/pxe_oracle_interface.js +17 -32
- package/dest/pxe_service/error_enriching.d.ts.map +1 -1
- package/dest/pxe_service/error_enriching.js +5 -8
- package/dest/pxe_service/pxe_service.d.ts +13 -27
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +215 -239
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +10 -44
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +93 -68
- package/dest/storage/contract_data_provider/index.d.ts +0 -1
- package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts +2 -41
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/private_functions_tree.js +9 -61
- package/dest/storage/index.d.ts +1 -2
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +1 -2
- package/dest/storage/metadata.d.ts +2 -0
- package/dest/storage/metadata.d.ts.map +1 -0
- package/dest/storage/metadata.js +1 -0
- package/dest/test/pxe_test_suite.d.ts.map +1 -1
- package/dest/test/pxe_test_suite.js +1 -1
- package/package.json +15 -15
- package/src/config/index.ts +1 -1
- package/src/config/package_info.ts +1 -1
- package/src/entrypoints/server/utils.ts +25 -11
- package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +4 -4
- package/src/private_kernel/index.ts +2 -0
- package/src/{kernel_prover/kernel_prover.ts → private_kernel/private_kernel_execution_prover.ts} +80 -91
- package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +17 -29
- package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +19 -6
- package/src/pxe_oracle_interface/pxe_oracle_interface.ts +31 -40
- package/src/pxe_service/error_enriching.ts +8 -14
- package/src/pxe_service/pxe_service.ts +289 -297
- package/src/storage/contract_data_provider/contract_data_provider.ts +114 -75
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/private_functions_tree.ts +11 -75
- package/src/storage/index.ts +1 -3
- package/src/storage/metadata.ts +1 -0
- package/src/test/pxe_test_suite.ts +3 -1
- package/dest/kernel_oracle/index.d.ts.map +0 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/kernel_prover/hints/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.d.ts +0 -3
- package/dest/kernel_prover/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.js +0 -2
- package/dest/kernel_prover/kernel_prover.d.ts +0 -38
- package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
- package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
- package/dest/kernel_prover/proving_data_oracle.js +0 -4
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
- package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
- package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/index.js +0 -1
- package/src/kernel_prover/index.ts +0 -2
- package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
- package/src/storage/auth_witness_data_provider/index.ts +0 -1
- /package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.js +0 -0
- /package/dest/{kernel_prover → private_kernel}/hints/index.d.ts +0 -0
- /package/dest/{kernel_prover → private_kernel}/hints/index.js +0 -0
- /package/src/{kernel_prover → private_kernel}/hints/index.ts +0 -0
package/dest/config/index.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type SimulationProvider } from '@aztec/simulator/client';
|
|
2
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
2
3
|
import type { PXEServiceConfig } from '../../config/index.js';
|
|
3
4
|
import { PXEService } from '../../pxe_service/pxe_service.js';
|
|
4
5
|
/**
|
|
5
|
-
* Create and start an PXEService instance with the given AztecNode.
|
|
6
|
-
* If no keyStore or database is provided, it will use KeyStore and MemoryDB as default values.
|
|
7
|
-
* Returns a Promise that resolves to the started PXEService instance.
|
|
6
|
+
* Create and start an PXEService instance with the given AztecNode and config.
|
|
8
7
|
*
|
|
9
8
|
* @param aztecNode - The AztecNode instance to be used by the server.
|
|
10
9
|
* @param config - The PXE Service Config to use
|
|
11
|
-
* @param useLogSuffix -
|
|
12
|
-
* @param proofCreator - An optional proof creator to use in place of any other configuration
|
|
10
|
+
* @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
|
|
13
11
|
* @returns A Promise that resolves to the started PXEService instance.
|
|
14
12
|
*/
|
|
15
|
-
export declare function createPXEService(aztecNode: AztecNode, config: PXEServiceConfig, useLogSuffix?: string | boolean | undefined
|
|
13
|
+
export declare function createPXEService(aztecNode: AztecNode, config: PXEServiceConfig, useLogSuffix?: string | boolean | undefined): Promise<PXEService>;
|
|
14
|
+
/**
|
|
15
|
+
* Create and start an PXEService instance with the given AztecNode, SimulationProvider and config.
|
|
16
|
+
*
|
|
17
|
+
* @param aztecNode - The AztecNode instance to be used by the server.
|
|
18
|
+
* @param simulationProvider - The SimulationProvider to use
|
|
19
|
+
* @param config - The PXE Service Config to use
|
|
20
|
+
* @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
|
|
21
|
+
* @returns A Promise that resolves to the started PXEService instance.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createPXEServiceWithSimulationProvider(aztecNode: AztecNode, simulationProvider: SimulationProvider, config: PXEServiceConfig, useLogSuffix?: string | boolean | undefined): Promise<PXEService>;
|
|
16
24
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/server/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/server/utils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,kBAAkB,EAAiB,MAAM,yBAAyB,CAAC;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAG9D;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,gBAAgB,EACxB,YAAY,GAAE,MAAM,GAAG,OAAO,GAAG,SAAqB,uBAIvD;AAED;;;;;;;;GAQG;AACH,wBAAsB,sCAAsC,CAC1D,SAAS,EAAE,SAAS,EACpB,kBAAkB,EAAE,kBAAkB,EACtC,MAAM,EAAE,gBAAgB,EACxB,YAAY,GAAE,MAAM,GAAG,OAAO,GAAG,SAAqB,uBA8BvD"}
|
|
@@ -6,18 +6,27 @@ import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
|
6
6
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
7
7
|
import { WASMSimulator } from '@aztec/simulator/client';
|
|
8
8
|
import { PXEService } from '../../pxe_service/pxe_service.js';
|
|
9
|
-
import { PXE_DATA_SCHEMA_VERSION } from '
|
|
9
|
+
import { PXE_DATA_SCHEMA_VERSION } from '../../storage/index.js';
|
|
10
10
|
/**
|
|
11
|
-
* Create and start an PXEService instance with the given AztecNode.
|
|
12
|
-
* If no keyStore or database is provided, it will use KeyStore and MemoryDB as default values.
|
|
13
|
-
* Returns a Promise that resolves to the started PXEService instance.
|
|
11
|
+
* Create and start an PXEService instance with the given AztecNode and config.
|
|
14
12
|
*
|
|
15
13
|
* @param aztecNode - The AztecNode instance to be used by the server.
|
|
16
14
|
* @param config - The PXE Service Config to use
|
|
17
|
-
* @param useLogSuffix -
|
|
18
|
-
* @param proofCreator - An optional proof creator to use in place of any other configuration
|
|
15
|
+
* @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
|
|
19
16
|
* @returns A Promise that resolves to the started PXEService instance.
|
|
20
|
-
*/ export
|
|
17
|
+
*/ export function createPXEService(aztecNode, config, useLogSuffix = undefined) {
|
|
18
|
+
const simulationProvider = new WASMSimulator();
|
|
19
|
+
return createPXEServiceWithSimulationProvider(aztecNode, simulationProvider, config, useLogSuffix);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create and start an PXEService instance with the given AztecNode, SimulationProvider and config.
|
|
23
|
+
*
|
|
24
|
+
* @param aztecNode - The AztecNode instance to be used by the server.
|
|
25
|
+
* @param simulationProvider - The SimulationProvider to use
|
|
26
|
+
* @param config - The PXE Service Config to use
|
|
27
|
+
* @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
|
|
28
|
+
* @returns A Promise that resolves to the started PXEService instance.
|
|
29
|
+
*/ export async function createPXEServiceWithSimulationProvider(aztecNode, simulationProvider, config, useLogSuffix = undefined) {
|
|
21
30
|
const logSuffix = typeof useLogSuffix === 'boolean' ? useLogSuffix ? randomBytes(3).toString('hex') : undefined : useLogSuffix;
|
|
22
31
|
const l1Contracts = await aztecNode.getL1ContractAddresses();
|
|
23
32
|
const configWithContracts = {
|
|
@@ -25,8 +34,7 @@ import { PXE_DATA_SCHEMA_VERSION } from './index.js';
|
|
|
25
34
|
l1Contracts
|
|
26
35
|
};
|
|
27
36
|
const store = await createStore('pxe_data', PXE_DATA_SCHEMA_VERSION, configWithContracts, createLogger('pxe:data:lmdb'));
|
|
28
|
-
const
|
|
29
|
-
const prover = proofCreator ?? await createProver(config, simulationProvider, logSuffix);
|
|
37
|
+
const prover = await createProver(config, simulationProvider, logSuffix);
|
|
30
38
|
const protocolContractsProvider = new BundledProtocolContractsProvider();
|
|
31
39
|
const pxe = await PXEService.create(aztecNode, store, prover, simulationProvider, protocolContractsProvider, config, logSuffix);
|
|
32
40
|
return pxe;
|
package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.d.ts
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PrivateKernelCircuitPublicInputs, PrivateKernelResetCircuitPrivateInputs, type PrivateKernelSimulateOutput } from '@aztec/stdlib/kernel';
|
|
2
2
|
import { type PrivateCallExecutionResult } from '@aztec/stdlib/tx';
|
|
3
|
-
import type {
|
|
3
|
+
import type { PrivateKernelOracle } from '../private_kernel_oracle.js';
|
|
4
4
|
export declare class PrivateKernelResetPrivateInputsBuilder {
|
|
5
5
|
private previousKernelOutput;
|
|
6
6
|
private executionStack;
|
|
@@ -15,7 +15,7 @@ export declare class PrivateKernelResetPrivateInputsBuilder {
|
|
|
15
15
|
private requestedDimensions;
|
|
16
16
|
constructor(previousKernelOutput: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>, executionStack: PrivateCallExecutionResult[], noteHashNullifierCounterMap: Map<number, number>, validationRequestsSplitCounter: number);
|
|
17
17
|
needsReset(): boolean;
|
|
18
|
-
build(oracle:
|
|
18
|
+
build(oracle: PrivateKernelOracle, noteHashLeafIndexMap: Map<bigint, bigint>): Promise<PrivateKernelResetCircuitPrivateInputs>;
|
|
19
19
|
private reduceReadRequestStates;
|
|
20
20
|
private needsResetNoteHashReadRequests;
|
|
21
21
|
private needsResetNullifierReadRequests;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_private_kernel_reset_private_inputs.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts"],"names":[],"mappings":"AAgBA,OAAO,EAGL,KAAK,gCAAgC,EAErC,sCAAsC,EAGtC,KAAK,2BAA2B,EAkBjC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,0BAA0B,EAAiB,MAAM,kBAAkB,CAAC;AAElF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAiDvE,qBAAa,sCAAsC;IAY/C,OAAO,CAAC,oBAAoB;IAC5B,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,2BAA2B;IACnC,OAAO,CAAC,8BAA8B;IAdxC,OAAO,CAAC,cAAc,CAAmC;IAEzD,OAAO,CAAC,aAAa,CAAC,CAA6B;IAEnD,OAAO,CAAC,mBAAmB,CAAoE;IAC/F,OAAO,CAAC,oBAAoB,CAAoE;IAChG,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,uBAAuB,CAA8D;IAC7F,OAAO,CAAC,mBAAmB,CAA+B;gBAGhD,oBAAoB,EAAE,2BAA2B,CAAC,gCAAgC,CAAC,EACnF,cAAc,EAAE,0BAA0B,EAAE,EAC5C,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAChD,8BAA8B,EAAE,MAAM;IAahD,UAAU,IAAI,OAAO;IAwBf,KAAK,CAAC,MAAM,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAgElF,OAAO,CAAC,uBAAuB;IA2B/B,OAAO,CAAC,8BAA8B;IAoDtC,OAAO,CAAC,+BAA+B;IAoDvC,OAAO,CAAC,uBAAuB;IAiB/B,OAAO,CAAC,uBAAuB;IA6E/B,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,oBAAoB;CAmB7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/index.ts"],"names":[],"mappings":"AAAA,cAAc,gDAAgD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/private_kernel/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
2
|
+
import { type PrivateKernelExecutionProofOutput, type PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
3
|
+
import { type PrivateExecutionResult, TxRequest } from '@aztec/stdlib/tx';
|
|
4
|
+
import type { PrivateKernelOracle } from './private_kernel_oracle.js';
|
|
5
|
+
export interface PrivateKernelExecutionProverConfig {
|
|
6
|
+
simulate: boolean;
|
|
7
|
+
skipFeeEnforcement: boolean;
|
|
8
|
+
profileMode: 'gates' | 'execution-steps' | 'full' | 'none';
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The PrivateKernelSequencer class is responsible for taking a transaction request and sequencing the
|
|
12
|
+
* the execution of the private functions within, sequenced with private kernel "glue" to check protocol rules.
|
|
13
|
+
* The result can be a client IVC proof of the private transaction portion, or just a simulation that can e.g.
|
|
14
|
+
* inform state tree updates.
|
|
15
|
+
*/
|
|
16
|
+
export declare class PrivateKernelExecutionProver {
|
|
17
|
+
private oracle;
|
|
18
|
+
private proofCreator;
|
|
19
|
+
private fakeProofs;
|
|
20
|
+
private log;
|
|
21
|
+
constructor(oracle: PrivateKernelOracle, proofCreator: PrivateKernelProver, fakeProofs?: boolean);
|
|
22
|
+
/**
|
|
23
|
+
* Generate a proof for a given transaction request and execution result.
|
|
24
|
+
* The function iterates through the nested executions in the execution result, creates private call data,
|
|
25
|
+
* and generates a proof using the provided ProofCreator instance. It also maintains an index of new notes
|
|
26
|
+
* created during the execution and returns them as a part of the KernelProverOutput.
|
|
27
|
+
*
|
|
28
|
+
* @param txRequest - The authenticated transaction request object.
|
|
29
|
+
* @param executionResult - The execution result object containing nested executions and preimages.
|
|
30
|
+
* @param profile - Set true to profile the gate count for each circuit
|
|
31
|
+
* @returns A Promise that resolves to a KernelProverOutput object containing proof, public inputs, and output notes.
|
|
32
|
+
*/
|
|
33
|
+
proveWithKernels(txRequest: TxRequest, executionResult: PrivateExecutionResult, { simulate, skipFeeEnforcement, profileMode }?: PrivateKernelExecutionProverConfig): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
34
|
+
private createPrivateCallData;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=private_kernel_execution_prover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private_kernel_execution_prover.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_execution_prover.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAKL,KAAK,iCAAiC,EAKtC,KAAK,oCAAoC,EAE1C,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,KAAK,sBAAsB,EAC3B,SAAS,EAIV,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAStE,MAAM,WAAW,kCAAkC;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,GAAG,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;CAC5D;AAED;;;;;GAKG;AACH,qBAAa,4BAA4B;IAIrC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,UAAU;IALpB,OAAO,CAAC,GAAG,CAAuD;gBAGxD,MAAM,EAAE,mBAAmB,EAC3B,YAAY,EAAE,mBAAmB,EACjC,UAAU,UAAQ;IAG5B;;;;;;;;;;OAUG;IACG,gBAAgB,CACpB,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,sBAAsB,EACvC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAE,kCAI9C,GACA,OAAO,CAAC,iCAAiC,CAAC,oCAAoC,CAAC,CAAC;YAgNrE,qBAAqB;CA2CpC"}
|
package/dest/{kernel_prover/kernel_prover.js → private_kernel/private_kernel_execution_prover.js}
RENAMED
|
@@ -12,21 +12,21 @@ import { computeContractAddressFromInstance } from '@aztec/stdlib/contract';
|
|
|
12
12
|
import { hashVK } from '@aztec/stdlib/hash';
|
|
13
13
|
import { PrivateCallData, PrivateKernelCircuitPublicInputs, PrivateKernelData, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelTailCircuitPrivateInputs, PrivateVerificationKeyHints } from '@aztec/stdlib/kernel';
|
|
14
14
|
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
15
|
-
import {
|
|
15
|
+
import { collectNoteHashLeafIndexMap, collectNoteHashNullifierCounterMap, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
|
|
16
16
|
import { VerificationKeyAsFields } from '@aztec/stdlib/vks';
|
|
17
17
|
import { PrivateKernelResetPrivateInputsBuilder } from './hints/build_private_kernel_reset_private_inputs.js';
|
|
18
|
-
const
|
|
18
|
+
const NULL_SIMULATE_OUTPUT = {
|
|
19
19
|
publicInputs: PrivateKernelCircuitPublicInputs.empty(),
|
|
20
20
|
verificationKey: VerificationKeyAsFields.makeEmpty(CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS),
|
|
21
21
|
outputWitness: new Map(),
|
|
22
22
|
bytecode: Buffer.from([])
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
|
-
* The
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*/ export class
|
|
25
|
+
* The PrivateKernelSequencer class is responsible for taking a transaction request and sequencing the
|
|
26
|
+
* the execution of the private functions within, sequenced with private kernel "glue" to check protocol rules.
|
|
27
|
+
* The result can be a client IVC proof of the private transaction portion, or just a simulation that can e.g.
|
|
28
|
+
* inform state tree updates.
|
|
29
|
+
*/ export class PrivateKernelExecutionProver {
|
|
30
30
|
oracle;
|
|
31
31
|
proofCreator;
|
|
32
32
|
fakeProofs;
|
|
@@ -35,7 +35,7 @@ const NULL_PROVE_OUTPUT = {
|
|
|
35
35
|
this.oracle = oracle;
|
|
36
36
|
this.proofCreator = proofCreator;
|
|
37
37
|
this.fakeProofs = fakeProofs;
|
|
38
|
-
this.log = createLogger('pxe:kernel-prover');
|
|
38
|
+
this.log = createLogger('pxe:private-kernel-execution-prover');
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Generate a proof for a given transaction request and execution result.
|
|
@@ -47,50 +47,35 @@ const NULL_PROVE_OUTPUT = {
|
|
|
47
47
|
* @param executionResult - The execution result object containing nested executions and preimages.
|
|
48
48
|
* @param profile - Set true to profile the gate count for each circuit
|
|
49
49
|
* @returns A Promise that resolves to a KernelProverOutput object containing proof, public inputs, and output notes.
|
|
50
|
-
|
|
51
|
-
*/ async prove(txRequest, executionResult, { simulate, skipFeeEnforcement, profile } = {
|
|
50
|
+
*/ async proveWithKernels(txRequest, executionResult, { simulate, skipFeeEnforcement, profileMode } = {
|
|
52
51
|
simulate: false,
|
|
53
52
|
skipFeeEnforcement: false,
|
|
54
|
-
|
|
53
|
+
profileMode: 'none'
|
|
55
54
|
}) {
|
|
56
55
|
const skipProofGeneration = this.fakeProofs || simulate;
|
|
57
|
-
const generateWitnesses = !skipProofGeneration ||
|
|
56
|
+
const generateWitnesses = !skipProofGeneration || profileMode !== 'none';
|
|
58
57
|
const timer = new Timer();
|
|
59
|
-
const isPrivateOnlyTx =
|
|
58
|
+
const isPrivateOnlyTx = executionResult.publicFunctionCalldata.length === 0;
|
|
60
59
|
const executionStack = [
|
|
61
60
|
executionResult.entrypoint
|
|
62
61
|
];
|
|
63
62
|
let firstIteration = true;
|
|
64
|
-
let output =
|
|
65
|
-
const
|
|
66
|
-
const addGateCount = async (circuitName, bytecode)=>{
|
|
67
|
-
const gateCount = await this.proofCreator.computeGateCountForCircuit(bytecode, circuitName);
|
|
68
|
-
gateCounts.push({
|
|
69
|
-
circuitName,
|
|
70
|
-
gateCount
|
|
71
|
-
});
|
|
72
|
-
this.log.debug(`Gate count for ${circuitName} - ${gateCount}`);
|
|
73
|
-
};
|
|
63
|
+
let output = NULL_SIMULATE_OUTPUT;
|
|
64
|
+
const executionSteps = [];
|
|
74
65
|
const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
|
|
75
66
|
const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
|
|
76
|
-
const
|
|
77
|
-
const hasPublicCalls = enqueuedPublicFunctions.length > 0 || !collectPublicTeardownFunctionCall(executionResult).isEmpty();
|
|
78
|
-
const validationRequestsSplitCounter = hasPublicCalls ? getFinalMinRevertibleSideEffectCounter(executionResult) : 0;
|
|
79
|
-
// vector of gzipped bincode acirs
|
|
80
|
-
const acirs = [];
|
|
81
|
-
const witnessStack = [];
|
|
67
|
+
const validationRequestsSplitCounter = isPrivateOnlyTx ? 0 : getFinalMinRevertibleSideEffectCounter(executionResult);
|
|
82
68
|
while(executionStack.length){
|
|
83
69
|
if (!firstIteration) {
|
|
84
70
|
let resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, executionStack, noteHashNullifierCounterMap, validationRequestsSplitCounter);
|
|
85
71
|
while(resetBuilder.needsReset()){
|
|
86
72
|
const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
|
|
87
|
-
output =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
73
|
+
output = simulate ? await this.proofCreator.simulateReset(privateInputs) : await this.proofCreator.generateResetOutput(privateInputs);
|
|
74
|
+
executionSteps.push({
|
|
75
|
+
functionName: 'private_kernel_reset',
|
|
76
|
+
bytecode: output.bytecode,
|
|
77
|
+
witness: output.outputWitness
|
|
78
|
+
});
|
|
94
79
|
resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, executionStack, noteHashNullifierCounterMap, validationRequestsSplitCounter);
|
|
95
80
|
}
|
|
96
81
|
}
|
|
@@ -99,35 +84,33 @@ const NULL_PROVE_OUTPUT = {
|
|
|
99
84
|
...currentExecution.nestedExecutions
|
|
100
85
|
].reverse());
|
|
101
86
|
const functionName = await this.oracle.getDebugFunctionName(currentExecution.publicInputs.callContext.contractAddress, currentExecution.publicInputs.callContext.functionSelector);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
await addGateCount(functionName, currentExecution.acir);
|
|
108
|
-
}
|
|
87
|
+
executionSteps.push({
|
|
88
|
+
functionName: functionName,
|
|
89
|
+
bytecode: currentExecution.acir,
|
|
90
|
+
witness: currentExecution.partialWitness
|
|
91
|
+
});
|
|
109
92
|
const privateCallData = await this.createPrivateCallData(currentExecution);
|
|
110
93
|
if (firstIteration) {
|
|
111
94
|
const proofInput = new PrivateKernelInitCircuitPrivateInputs(txRequest, getVKTreeRoot(), protocolContractTreeRoot, privateCallData, isPrivateOnlyTx, executionResult.firstNullifier);
|
|
112
95
|
this.log.debug(`Calling private kernel init with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`);
|
|
113
96
|
pushTestData('private-kernel-inputs-init', proofInput);
|
|
114
97
|
output = generateWitnesses ? await this.proofCreator.generateInitOutput(proofInput) : await this.proofCreator.simulateInit(proofInput);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
98
|
+
executionSteps.push({
|
|
99
|
+
functionName: 'private_kernel_init',
|
|
100
|
+
bytecode: output.bytecode,
|
|
101
|
+
witness: output.outputWitness
|
|
102
|
+
});
|
|
120
103
|
} else {
|
|
121
104
|
const previousVkMembershipWitness = await this.oracle.getVkMembershipWitness(output.verificationKey);
|
|
122
105
|
const previousKernelData = new PrivateKernelData(output.publicInputs, output.verificationKey, Number(previousVkMembershipWitness.leafIndex), assertLength(previousVkMembershipWitness.siblingPath, VK_TREE_HEIGHT));
|
|
123
106
|
const proofInput = new PrivateKernelInnerCircuitPrivateInputs(previousKernelData, privateCallData);
|
|
124
107
|
pushTestData('private-kernel-inputs-inner', proofInput);
|
|
125
108
|
output = generateWitnesses ? await this.proofCreator.generateInnerOutput(proofInput) : await this.proofCreator.simulateInner(proofInput);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
109
|
+
executionSteps.push({
|
|
110
|
+
functionName: 'private_kernel_inner',
|
|
111
|
+
bytecode: output.bytecode,
|
|
112
|
+
witness: output.outputWitness
|
|
113
|
+
});
|
|
131
114
|
}
|
|
132
115
|
firstIteration = false;
|
|
133
116
|
}
|
|
@@ -136,11 +119,11 @@ const NULL_PROVE_OUTPUT = {
|
|
|
136
119
|
while(resetBuilder.needsReset()){
|
|
137
120
|
const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
|
|
138
121
|
output = generateWitnesses ? await this.proofCreator.generateResetOutput(privateInputs) : await this.proofCreator.simulateReset(privateInputs);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
122
|
+
executionSteps.push({
|
|
123
|
+
functionName: 'private_kernel_reset',
|
|
124
|
+
bytecode: output.bytecode,
|
|
125
|
+
witness: output.outputWitness
|
|
126
|
+
});
|
|
144
127
|
resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, validationRequestsSplitCounter);
|
|
145
128
|
}
|
|
146
129
|
if (output.publicInputs.feePayer.isZero() && skipFeeEnforcement) {
|
|
@@ -156,25 +139,40 @@ const NULL_PROVE_OUTPUT = {
|
|
|
156
139
|
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(previousKernelData);
|
|
157
140
|
pushTestData('private-kernel-inputs-ordering', privateInputs);
|
|
158
141
|
const tailOutput = generateWitnesses ? await this.proofCreator.generateTailOutput(privateInputs) : await this.proofCreator.simulateTail(privateInputs);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
142
|
+
executionSteps.push({
|
|
143
|
+
functionName: 'private_kernel_tail',
|
|
144
|
+
bytecode: tailOutput.bytecode,
|
|
145
|
+
witness: tailOutput.outputWitness
|
|
146
|
+
});
|
|
147
|
+
if (profileMode == 'gates' || profileMode == 'full') {
|
|
148
|
+
for (const entry of executionSteps){
|
|
149
|
+
const gateCount = await this.proofCreator.computeGateCountForCircuit(entry.bytecode, entry.functionName);
|
|
150
|
+
entry.gateCount = gateCount;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (profileMode === 'gates') {
|
|
154
|
+
for (const entry of executionSteps){
|
|
155
|
+
// These buffers are often a few megabytes in size - prevent accidentally serializing them if not requested.
|
|
156
|
+
entry.bytecode = Buffer.from([]);
|
|
157
|
+
entry.witness = new Map();
|
|
158
|
+
}
|
|
166
159
|
}
|
|
167
160
|
if (generateWitnesses) {
|
|
168
161
|
this.log.info(`Private kernel witness generation took ${timer.ms()}ms`);
|
|
169
162
|
}
|
|
163
|
+
let clientIvcProof;
|
|
170
164
|
// TODO(#7368) how do we 'bincode' encode these inputs?
|
|
171
165
|
if (!skipProofGeneration) {
|
|
172
|
-
|
|
173
|
-
tailOutput.clientIvcProof = ivcProof;
|
|
166
|
+
clientIvcProof = await this.proofCreator.createClientIvcProof(executionSteps);
|
|
174
167
|
} else {
|
|
175
|
-
|
|
168
|
+
clientIvcProof = ClientIvcProof.random();
|
|
176
169
|
}
|
|
177
|
-
return
|
|
170
|
+
return {
|
|
171
|
+
publicInputs: tailOutput.publicInputs,
|
|
172
|
+
executionSteps,
|
|
173
|
+
clientIvcProof,
|
|
174
|
+
verificationKey: tailOutput.verificationKey
|
|
175
|
+
};
|
|
178
176
|
}
|
|
179
177
|
async createPrivateCallData({ publicInputs, vk: vkAsBuffer }) {
|
|
180
178
|
const { contractAddress, functionSelector } = publicInputs.callContext;
|
|
@@ -207,11 +205,4 @@ const NULL_PROVE_OUTPUT = {
|
|
|
207
205
|
})
|
|
208
206
|
});
|
|
209
207
|
}
|
|
210
|
-
isPrivateOnly(executionResult) {
|
|
211
|
-
const isPrivateOnlyRecursive = (callResult)=>{
|
|
212
|
-
const makesPublicCalls = callResult.enqueuedPublicFunctionCalls.some((enqueuedCall)=>!enqueuedCall.isEmpty()) || !callResult.publicTeardownFunctionCall.isEmpty();
|
|
213
|
-
return !makesPublicCalls && callResult.nestedExecutions.every((nestedExecution)=>isPrivateOnlyRecursive(nestedExecution));
|
|
214
|
-
};
|
|
215
|
-
return isPrivateOnlyRecursive(executionResult.entrypoint);
|
|
216
|
-
}
|
|
217
208
|
}
|
package/dest/{kernel_prover/proving_data_oracle.d.ts → private_kernel/private_kernel_oracle.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import type { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields';
|
|
3
|
-
import
|
|
3
|
+
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
4
4
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
6
|
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
@@ -8,10 +8,10 @@ import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
|
8
8
|
import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
|
|
9
9
|
import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
|
|
10
10
|
/**
|
|
11
|
-
* Provides functionality
|
|
12
|
-
*
|
|
11
|
+
* Provides functionality needed by the private kernel for interacting with our state trees.
|
|
12
|
+
* This is either PrivateKernelOracleImpl, or a mocked test implementation.
|
|
13
13
|
*/
|
|
14
|
-
export interface
|
|
14
|
+
export interface PrivateKernelOracle {
|
|
15
15
|
/** Retrieves the preimage of a contract address from the registered contract instances db. */
|
|
16
16
|
getContractAddressPreimage(address: AztecAddress): Promise<{
|
|
17
17
|
saltedInitializationHash: Fr;
|
|
@@ -26,37 +26,23 @@ export interface ProvingDataOracle {
|
|
|
26
26
|
privateFunctionsRoot: Fr;
|
|
27
27
|
}>;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* The function membership witness represents a proof that the function belongs to the specified contract.
|
|
31
|
-
* Throws an error if the contract address or function selector is unknown.
|
|
32
|
-
*
|
|
33
|
-
* @param contractClassId - The id of the class.
|
|
34
|
-
* @param selector - The function selector.
|
|
35
|
-
* @returns A promise that resolves with the MembershipWitness instance for the specified contract's function.
|
|
29
|
+
* Returns a membership witness with the sibling path and leaf index in our private functions tree.
|
|
36
30
|
*/
|
|
37
31
|
getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>>;
|
|
38
32
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* which is a placeholder implementation until a concrete membership witness calculation
|
|
42
|
-
* is implemented.
|
|
43
|
-
*
|
|
44
|
-
* @param vk - The VerificationKey for which the membership witness is needed.
|
|
45
|
-
* @returns A Promise that resolves to the MembershipWitness instance.
|
|
33
|
+
* Returns a membership witness with the sibling path and leaf index in our protocol VK indexed merkle tree.
|
|
34
|
+
* Used to validate the previous kernel's verification key.
|
|
46
35
|
*/
|
|
47
36
|
getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<typeof VK_TREE_HEIGHT>>;
|
|
48
37
|
/**
|
|
49
|
-
*
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
38
|
+
* Returns a membership witness with the sibling path and leaf index in our private function indexed merkle tree.
|
|
39
|
+
*/ getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
|
|
40
|
+
/**
|
|
41
|
+
* Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree.
|
|
53
42
|
*/
|
|
54
|
-
getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
|
|
55
43
|
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
|
|
56
44
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* @returns the root of the note hash tree.
|
|
45
|
+
* Returns the root of our note hash merkle tree.
|
|
60
46
|
*/
|
|
61
47
|
getNoteHashTreeRoot(): Promise<Fr>;
|
|
62
48
|
/**
|
|
@@ -67,7 +53,10 @@ export interface ProvingDataOracle {
|
|
|
67
53
|
* @dev Used when feeding the sk_m to the kernel circuit for keys verification.
|
|
68
54
|
*/
|
|
69
55
|
getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar>;
|
|
56
|
+
/** Use debug data to get the function name corresponding to a selector. */
|
|
70
57
|
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
58
|
+
/** Returns a membership witness and leaf index to our public data indexed merkle tree,
|
|
59
|
+
* along with an associated SharedMutable containing the class ID to update. */
|
|
71
60
|
getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
|
|
72
61
|
}
|
|
73
|
-
//# sourceMappingURL=
|
|
62
|
+
//# sourceMappingURL=private_kernel_oracle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private_kernel_oracle.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_oracle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,KAAK,EAAE,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEjE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,8FAA8F;IAC9F,0BAA0B,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC;QACzD,wBAAwB,EAAE,EAAE,CAAC;QAC7B,UAAU,EAAE,UAAU,CAAC;QACvB,sBAAsB,EAAE,EAAE,CAAC;QAC3B,uBAAuB,EAAE,EAAE,CAAC;KAC7B,CAAC,CAAC;IAEH,kFAAkF;IAClF,0BAA0B,CACxB,eAAe,EAAE,EAAE,GAClB,OAAO,CAAC;QAAE,YAAY,EAAE,EAAE,CAAC;QAAC,wBAAwB,EAAE,EAAE,CAAC;QAAC,oBAAoB,EAAE,EAAE,CAAA;KAAE,CAAC,CAAC;IAEzF;;OAEG;IACH,4BAA4B,CAC1B,eAAe,EAAE,EAAE,EACnB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC;IAE3D;;;OAGG;IACH,sBAAsB,CAAC,EAAE,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC;IAEvG;;OAEG,CAAC,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC;IAE9G;;OAEG;IACH,6BAA6B,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CAAC;IAC9F;;OAEG;IACH,mBAAmB,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC;IAEnC;;;;;;OAMG;IACH,kBAAkB,CAAC,eAAe,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAEpE,2EAA2E;IAC3E,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAE7G;mFAC+E;IAC/E,sBAAsB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACrF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import type { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields';
|
|
3
3
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
4
4
|
import type { KeyStore } from '@aztec/key-store';
|
|
@@ -9,12 +9,12 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
9
9
|
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
10
10
|
import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
|
|
11
11
|
import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
|
|
12
|
-
import type { ContractDataProvider } from '../storage/
|
|
13
|
-
import type {
|
|
12
|
+
import type { ContractDataProvider } from '../storage/index.js';
|
|
13
|
+
import type { PrivateKernelOracle } from './private_kernel_oracle.js';
|
|
14
14
|
/**
|
|
15
15
|
* A data oracle that provides information needed for simulating a transaction.
|
|
16
16
|
*/
|
|
17
|
-
export declare class
|
|
17
|
+
export declare class PrivateKernelOracleImpl implements PrivateKernelOracle {
|
|
18
18
|
private contractDataProvider;
|
|
19
19
|
private keyStore;
|
|
20
20
|
private node;
|
|
@@ -28,7 +28,7 @@ export declare class KernelOracle implements ProvingDataOracle {
|
|
|
28
28
|
currentContractClassId: Fr;
|
|
29
29
|
originalContractClassId: Fr;
|
|
30
30
|
initializationHash: Fr;
|
|
31
|
-
publicKeys: import("@aztec/
|
|
31
|
+
publicKeys: import("@aztec/stdlib/keys").PublicKeys;
|
|
32
32
|
address: AztecAddress;
|
|
33
33
|
saltedInitializationHash: Fr;
|
|
34
34
|
}>;
|
|
@@ -42,4 +42,4 @@ export declare class KernelOracle implements ProvingDataOracle {
|
|
|
42
42
|
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string>;
|
|
43
43
|
getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
|
|
44
44
|
}
|
|
45
|
-
//# sourceMappingURL=
|
|
45
|
+
//# sourceMappingURL=private_kernel_oracle_impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,cAAc,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAG1E,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,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAItE;;GAEG;AAEH,qBAAa,uBAAwB,YAAW,mBAAmB;IAE/D,OAAO,CAAC,oBAAoB;IAC5B,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,GAAG;gBAJH,oBAAoB,EAAE,oBAAoB,EAC1C,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,SAAS,EACf,WAAW,GAAE,aAAwB,EACrC,GAAG,yCAAoC;IAGpC,0BAA0B,CAAC,OAAO,EAAE,YAAY;;;;;;;;;;;IAWhD,0BAA0B,CAAC,eAAe,EAAE,EAAE;IAQ9C,4BAA4B,CAAC,eAAe,EAAE,EAAE,EAAE,QAAQ,EAAE,gBAAgB;IAUlF,sBAAsB,CAAC,EAAE,EAAE,uBAAuB;IAKnD,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,qBAAqB,CAAC,CAAC;IAS/G,6BAA6B,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC;IAIvF,mBAAmB,IAAI,OAAO,CAAC,EAAE,CAAC;IAQjC,kBAAkB,CAAC,eAAe,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC;IAInE,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1F,sBAAsB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC;CA6BjG"}
|
|
@@ -11,7 +11,7 @@ import { SharedMutableValues, SharedMutableValuesWithHash } from '@aztec/stdlib/
|
|
|
11
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
12
|
/**
|
|
13
13
|
* A data oracle that provides information needed for simulating a transaction.
|
|
14
|
-
*/ export class
|
|
14
|
+
*/ export class PrivateKernelOracleImpl {
|
|
15
15
|
contractDataProvider;
|
|
16
16
|
keyStore;
|
|
17
17
|
node;
|
|
@@ -26,6 +26,9 @@ import { SharedMutableValues, SharedMutableValuesWithHash } from '@aztec/stdlib/
|
|
|
26
26
|
}
|
|
27
27
|
async getContractAddressPreimage(address) {
|
|
28
28
|
const instance = await this.contractDataProvider.getContractInstance(address);
|
|
29
|
+
if (!instance) {
|
|
30
|
+
throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
|
|
31
|
+
}
|
|
29
32
|
return {
|
|
30
33
|
saltedInitializationHash: await computeSaltedInitializationHash(instance),
|
|
31
34
|
...instance
|
|
@@ -33,10 +36,17 @@ import { SharedMutableValues, SharedMutableValuesWithHash } from '@aztec/stdlib/
|
|
|
33
36
|
}
|
|
34
37
|
async getContractClassIdPreimage(contractClassId) {
|
|
35
38
|
const contractClass = await this.contractDataProvider.getContractClass(contractClassId);
|
|
39
|
+
if (!contractClass) {
|
|
40
|
+
throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
|
|
41
|
+
}
|
|
36
42
|
return computeContractClassIdPreimage(contractClass);
|
|
37
43
|
}
|
|
38
44
|
async getFunctionMembershipWitness(contractClassId, selector) {
|
|
39
|
-
|
|
45
|
+
const membershipWitness = await this.contractDataProvider.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;
|
|
40
50
|
}
|
|
41
51
|
getVkMembershipWitness(vk) {
|
|
42
52
|
const leafIndex = getVKIndex(vk);
|
|
@@ -65,7 +75,7 @@ import { SharedMutableValues, SharedMutableValuesWithHash } from '@aztec/stdlib/
|
|
|
65
75
|
async getUpdatedClassIdHints(contractAddress) {
|
|
66
76
|
const { sharedMutableSlot, sharedMutableHashSlot } = await SharedMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
67
77
|
const hashLeafSlot = await computePublicDataTreeLeafSlot(ProtocolContractAddress.ContractInstanceDeployer, sharedMutableHashSlot);
|
|
68
|
-
const updatedClassIdWitness = await this.node.
|
|
78
|
+
const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockNumber, hashLeafSlot);
|
|
69
79
|
if (!updatedClassIdWitness) {
|
|
70
80
|
throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
|
|
71
81
|
}
|