@aztec/stdlib 0.83.1 → 0.84.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/abi/abi.d.ts +2 -2
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +1 -1
- package/dest/abi/contract_artifact.d.ts.map +1 -1
- package/dest/abi/contract_artifact.js +21 -9
- package/dest/avm/avm.d.ts +1203 -694
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +58 -6
- package/dest/avm/avm_circuit_public_inputs.d.ts +80 -80
- package/dest/avm/avm_proving_request.d.ts +672 -447
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/config/config.d.ts +2 -1
- package/dest/config/config.d.ts.map +1 -1
- package/dest/contract/artifact_hash.d.ts +5 -5
- package/dest/contract/artifact_hash.d.ts.map +1 -1
- package/dest/contract/artifact_hash.js +8 -8
- package/dest/contract/index.d.ts +1 -1
- package/dest/contract/index.d.ts.map +1 -1
- package/dest/contract/index.js +1 -1
- package/dest/contract/interfaces/contract_class.d.ts +23 -19
- package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_class.js +4 -4
- package/dest/contract/interfaces/contract_instance.d.ts +2 -2
- package/dest/contract/private_function_membership_proof.d.ts +1 -1
- package/dest/contract/private_function_membership_proof.js +6 -6
- package/dest/contract/utility_function_membership_proof.d.ts +27 -0
- package/dest/contract/utility_function_membership_proof.d.ts.map +1 -0
- package/dest/contract/{unconstrained_function_membership_proof.js → utility_function_membership_proof.js} +13 -13
- package/dest/interfaces/allowed_element.d.ts +53 -0
- package/dest/interfaces/allowed_element.d.ts.map +1 -0
- package/dest/interfaces/allowed_element.js +18 -0
- package/dest/interfaces/configs.d.ts +17 -34
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +2 -17
- package/dest/interfaces/proving-job.d.ts +672 -447
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/public_state_source.d.ts +8 -0
- package/dest/interfaces/public_state_source.d.ts.map +1 -0
- package/dest/interfaces/public_state_source.js +1 -0
- package/dest/interfaces/pxe.d.ts +7 -8
- package/dest/interfaces/pxe.d.ts.map +1 -1
- package/dest/interfaces/pxe.js +1 -1
- package/dest/interfaces/server.d.ts +1 -0
- package/dest/interfaces/server.d.ts.map +1 -1
- package/dest/interfaces/server.js +1 -0
- package/dest/logs/tx_scoped_l2_log.d.ts +1 -1
- package/dest/noir/index.d.ts +3 -1
- package/dest/noir/index.d.ts.map +1 -1
- package/dest/noir/index.js +1 -0
- package/dest/note/extended_note.d.ts +3 -3
- package/dest/proofs/proof.d.ts +0 -1
- package/dest/proofs/proof.d.ts.map +1 -1
- package/dest/proofs/proof.js +6 -11
- package/dest/tests/factories.d.ts +4 -3
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +15 -6
- package/dest/trees/database_public_state_source.d.ts +11 -0
- package/dest/trees/database_public_state_source.d.ts.map +1 -0
- package/dest/trees/database_public_state_source.js +18 -0
- package/dest/trees/index.d.ts +1 -0
- package/dest/trees/index.d.ts.map +1 -1
- package/dest/trees/index.js +1 -0
- package/dest/tx/call_context.d.ts +1 -1
- package/dest/tx/tree_snapshots.d.ts +6 -6
- package/package.json +6 -6
- package/src/abi/abi.ts +2 -2
- package/src/abi/contract_artifact.ts +22 -8
- package/src/avm/avm.ts +89 -5
- package/src/config/config.ts +2 -1
- package/src/contract/artifact_hash.ts +9 -9
- package/src/contract/index.ts +1 -1
- package/src/contract/interfaces/contract_class.ts +21 -17
- package/src/contract/private_function_membership_proof.ts +6 -6
- package/src/contract/{unconstrained_function_membership_proof.ts → utility_function_membership_proof.ts} +18 -18
- package/src/interfaces/allowed_element.ts +21 -0
- package/src/interfaces/configs.ts +3 -18
- package/src/interfaces/public_state_source.ts +9 -0
- package/src/interfaces/pxe.ts +8 -9
- package/src/interfaces/server.ts +1 -0
- package/src/noir/index.ts +2 -1
- package/src/proofs/proof.ts +6 -16
- package/src/tests/factories.ts +23 -6
- package/src/trees/database_public_state_source.ts +30 -0
- package/src/trees/index.ts +1 -0
- package/dest/contract/unconstrained_function_membership_proof.d.ts +0 -27
- package/dest/contract/unconstrained_function_membership_proof.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avm_proving_request.d.ts","sourceRoot":"","sources":["../../src/avm/avm_proving_request.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"avm_proving_request.d.ts","sourceRoot":"","sources":["../../src/avm/avm_proving_request.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGlC,CAAC"}
|
package/dest/config/config.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
2
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
-
export { type
|
|
3
|
+
export { type SequencerConfig, SequencerConfigSchema } from '../interfaces/configs.js';
|
|
4
|
+
export { type AllowedElement } from '../interfaces/allowed_element.js';
|
|
4
5
|
export declare const emptyChainConfig: ChainConfig;
|
|
5
6
|
export declare const chainConfigMappings: ConfigMappingsType<ChainConfig>;
|
|
6
7
|
/** Chain configuration. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,KAAK,eAAe,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAEvE,eAAO,MAAM,gBAAgB,EAAE,WAI9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,kBAAkB,CAAC,WAAW,CAgB/D,CAAC;AAEF,2BAA2B;AAC3B,MAAM,MAAM,WAAW,GAAG;IACxB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,WAAW,EAAE;QACX,4BAA4B;QAC5B,aAAa,EAAE,UAAU,CAAC;KAC3B,CAAC;CACH,CAAC"}
|
|
@@ -11,15 +11,15 @@ import { type ContractArtifact, type FunctionArtifact, FunctionSelector, Functio
|
|
|
11
11
|
* sha256(fn.selector, fn.metadata_hash, sha256(fn.bytecode))
|
|
12
12
|
* private_functions_artifact_tree_root = merkleize(private_functions_artifact_leaves)
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* utility_functions_artifact_leaves = artifact.utility_functions.map fn =>
|
|
15
15
|
* sha256(fn.selector, fn.metadata_hash, sha256(fn.bytecode))
|
|
16
|
-
*
|
|
16
|
+
* utility_functions_artifact_tree_root = merkleize(utility_functions_artifact_leaves)
|
|
17
17
|
*
|
|
18
18
|
* version = 1
|
|
19
19
|
* artifact_hash = sha256(
|
|
20
20
|
* version,
|
|
21
21
|
* private_functions_artifact_tree_root,
|
|
22
|
-
*
|
|
22
|
+
* utility_functions_artifact_tree_root,
|
|
23
23
|
* artifact_metadata,
|
|
24
24
|
* )
|
|
25
25
|
* ```
|
|
@@ -27,12 +27,12 @@ import { type ContractArtifact, type FunctionArtifact, FunctionSelector, Functio
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function computeArtifactHash(artifact: ContractArtifact | {
|
|
29
29
|
privateFunctionRoot: Fr;
|
|
30
|
-
|
|
30
|
+
utilityFunctionRoot: Fr;
|
|
31
31
|
metadataHash: Fr;
|
|
32
32
|
}): Promise<Fr>;
|
|
33
33
|
export declare function computeArtifactHashPreimage(artifact: ContractArtifact): Promise<{
|
|
34
34
|
privateFunctionRoot: Fr;
|
|
35
|
-
|
|
35
|
+
utilityFunctionRoot: Fr;
|
|
36
36
|
metadataHash: Fr;
|
|
37
37
|
}>;
|
|
38
38
|
export declare function computeArtifactMetadataHash(artifact: ContractArtifact): Fr;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact_hash.d.ts","sourceRoot":"","sources":["../../src/contract/artifact_hash.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,EAAE,EAAY,MAAM,0BAA0B,CAAC;AAGxD,OAAO,EAAE,UAAU,EAAwB,MAAM,yBAAyB,CAAC;AAE3E,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAS/G;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,gBAAgB,GAAG;IAAE,mBAAmB,EAAE,EAAE,CAAC;IAAC,
|
|
1
|
+
{"version":3,"file":"artifact_hash.d.ts","sourceRoot":"","sources":["../../src/contract/artifact_hash.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,EAAE,EAAY,MAAM,0BAA0B,CAAC;AAGxD,OAAO,EAAE,UAAU,EAAwB,MAAM,yBAAyB,CAAC;AAE3E,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAS/G;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,gBAAgB,GAAG;IAAE,mBAAmB,EAAE,EAAE,CAAC;IAAC,mBAAmB,EAAE,EAAE,CAAC;IAAC,YAAY,EAAE,EAAE,CAAA;CAAE,GAClG,OAAO,CAAC,EAAE,CAAC,CAWb;AAED,wBAAsB,2BAA2B,CAAC,QAAQ,EAAE,gBAAgB;;;;GAK3E;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,gBAAgB,MAErE;AAED,wBAAsB,+BAA+B,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,eAGrG;AAED,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CASjC;AAYD,wBAAsB,2BAA2B,CAC/C,EAAE,EACE,gBAAgB,GAChB,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG;IAAE,oBAAoB,EAAE,EAAE,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAA;CAAE,CAAC,eAOpG;AAED,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,gBAAgB,MAE/D;AAMD,wBAAgB,2BAA2B,QAC9B,MAAM,KAAK,MAAM,qBAC7B"}
|
|
@@ -17,25 +17,25 @@ const sha256Fr = reduceFn(sha256, Fr);
|
|
|
17
17
|
* sha256(fn.selector, fn.metadata_hash, sha256(fn.bytecode))
|
|
18
18
|
* private_functions_artifact_tree_root = merkleize(private_functions_artifact_leaves)
|
|
19
19
|
*
|
|
20
|
-
*
|
|
20
|
+
* utility_functions_artifact_leaves = artifact.utility_functions.map fn =>
|
|
21
21
|
* sha256(fn.selector, fn.metadata_hash, sha256(fn.bytecode))
|
|
22
|
-
*
|
|
22
|
+
* utility_functions_artifact_tree_root = merkleize(utility_functions_artifact_leaves)
|
|
23
23
|
*
|
|
24
24
|
* version = 1
|
|
25
25
|
* artifact_hash = sha256(
|
|
26
26
|
* version,
|
|
27
27
|
* private_functions_artifact_tree_root,
|
|
28
|
-
*
|
|
28
|
+
* utility_functions_artifact_tree_root,
|
|
29
29
|
* artifact_metadata,
|
|
30
30
|
* )
|
|
31
31
|
* ```
|
|
32
32
|
* @param artifact - Artifact to calculate the hash for.
|
|
33
33
|
*/ export async function computeArtifactHash(artifact) {
|
|
34
|
-
if ('privateFunctionRoot' in artifact && '
|
|
35
|
-
const { privateFunctionRoot,
|
|
34
|
+
if ('privateFunctionRoot' in artifact && 'utilityFunctionRoot' in artifact && 'metadataHash' in artifact) {
|
|
35
|
+
const { privateFunctionRoot, utilityFunctionRoot, metadataHash } = artifact;
|
|
36
36
|
const preimage = [
|
|
37
37
|
privateFunctionRoot,
|
|
38
|
-
|
|
38
|
+
utilityFunctionRoot,
|
|
39
39
|
metadataHash
|
|
40
40
|
].map((x)=>x.toBuffer());
|
|
41
41
|
return sha256Fr(Buffer.concat([
|
|
@@ -53,11 +53,11 @@ const sha256Fr = reduceFn(sha256, Fr);
|
|
|
53
53
|
}
|
|
54
54
|
export async function computeArtifactHashPreimage(artifact) {
|
|
55
55
|
const privateFunctionRoot = await computeArtifactFunctionTreeRoot(artifact, FunctionType.PRIVATE);
|
|
56
|
-
const
|
|
56
|
+
const utilityFunctionRoot = await computeArtifactFunctionTreeRoot(artifact, FunctionType.UTILITY);
|
|
57
57
|
const metadataHash = computeArtifactMetadataHash(artifact);
|
|
58
58
|
return {
|
|
59
59
|
privateFunctionRoot,
|
|
60
|
-
|
|
60
|
+
utilityFunctionRoot,
|
|
61
61
|
metadataHash
|
|
62
62
|
};
|
|
63
63
|
}
|
package/dest/contract/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export * from './contract_instance.js';
|
|
|
6
6
|
export * from './contract_instance_update.js';
|
|
7
7
|
export * from './private_function.js';
|
|
8
8
|
export * from './private_function_membership_proof.js';
|
|
9
|
-
export * from './
|
|
9
|
+
export * from './utility_function_membership_proof.js';
|
|
10
10
|
export * from './interfaces/index.js';
|
|
11
11
|
export * from './contract_function_dao.js';
|
|
12
12
|
export * from './partial_address.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wCAAwC,CAAC;AACvD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;AACvD,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
|
package/dest/contract/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export * from './contract_instance.js';
|
|
|
6
6
|
export * from './contract_instance_update.js';
|
|
7
7
|
export * from './private_function.js';
|
|
8
8
|
export * from './private_function_membership_proof.js';
|
|
9
|
-
export * from './
|
|
9
|
+
export * from './utility_function_membership_proof.js';
|
|
10
10
|
export * from './interfaces/index.js';
|
|
11
11
|
export * from './contract_function_dao.js';
|
|
12
12
|
export * from './partial_address.js';
|
|
@@ -13,7 +13,11 @@ declare const VERSION: 1;
|
|
|
13
13
|
export interface ContractClass {
|
|
14
14
|
/** Version of the contract class. */
|
|
15
15
|
version: typeof VERSION;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Hash of the contract artifact. The specification of this hash is not enforced by the protocol. Should include
|
|
18
|
+
* commitments to code of utility functions and compilation metadata. Intended to be used by clients to verify that
|
|
19
|
+
* an off-chain fetched artifact matches a registered class.
|
|
20
|
+
*/
|
|
17
21
|
artifactHash: Fr;
|
|
18
22
|
/** List of individual private functions, constructors included. */
|
|
19
23
|
privateFunctions: PrivateFunction[];
|
|
@@ -32,8 +36,8 @@ export interface ExecutablePrivateFunction extends PrivateFunction {
|
|
|
32
36
|
/** ACIR and Brillig bytecode */
|
|
33
37
|
bytecode: Buffer;
|
|
34
38
|
}
|
|
35
|
-
/**
|
|
36
|
-
export interface
|
|
39
|
+
/** Utility function definition. */
|
|
40
|
+
export interface UtilityFunction {
|
|
37
41
|
/** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
|
|
38
42
|
selector: FunctionSelector;
|
|
39
43
|
/** Brillig. */
|
|
@@ -43,24 +47,24 @@ export interface UnconstrainedFunction {
|
|
|
43
47
|
export type PrivateFunctionMembershipProof = {
|
|
44
48
|
artifactMetadataHash: Fr;
|
|
45
49
|
functionMetadataHash: Fr;
|
|
46
|
-
|
|
50
|
+
utilityFunctionsTreeRoot: Fr;
|
|
47
51
|
privateFunctionTreeSiblingPath: Fr[];
|
|
48
52
|
privateFunctionTreeLeafIndex: number;
|
|
49
53
|
artifactTreeSiblingPath: Fr[];
|
|
50
54
|
artifactTreeLeafIndex: number;
|
|
51
55
|
};
|
|
52
|
-
/** A private function with a
|
|
56
|
+
/** A private function with a membership proof. */
|
|
53
57
|
export type ExecutablePrivateFunctionWithMembershipProof = ExecutablePrivateFunction & PrivateFunctionMembershipProof;
|
|
54
|
-
/** Sibling paths and commitments for proving membership of
|
|
55
|
-
export type
|
|
58
|
+
/** Sibling paths and commitments for proving membership of a utility function within a contract class. */
|
|
59
|
+
export type UtilityFunctionMembershipProof = {
|
|
56
60
|
artifactMetadataHash: Fr;
|
|
57
61
|
functionMetadataHash: Fr;
|
|
58
62
|
privateFunctionsArtifactTreeRoot: Fr;
|
|
59
63
|
artifactTreeSiblingPath: Fr[];
|
|
60
64
|
artifactTreeLeafIndex: number;
|
|
61
65
|
};
|
|
62
|
-
/**
|
|
63
|
-
export type
|
|
66
|
+
/** A utility function with a membership proof. */
|
|
67
|
+
export type UtilityFunctionWithMembershipProof = UtilityFunction & UtilityFunctionMembershipProof;
|
|
64
68
|
export declare const ContractClassSchema: z.ZodObject<{
|
|
65
69
|
version: z.ZodLiteral<1>;
|
|
66
70
|
artifactHash: z.ZodType<Fr, any, string>;
|
|
@@ -168,10 +172,10 @@ export declare const ContractClassWithIdSchema: z.ZodObject<z.objectUtil.extendS
|
|
|
168
172
|
selector?: any;
|
|
169
173
|
}[];
|
|
170
174
|
}>;
|
|
171
|
-
/** A contract class with public bytecode information, and optional private and
|
|
175
|
+
/** A contract class with public bytecode information, and optional private and utility functions. */
|
|
172
176
|
export type ContractClassPublic = {
|
|
173
177
|
privateFunctions: ExecutablePrivateFunctionWithMembershipProof[];
|
|
174
|
-
|
|
178
|
+
utilityFunctions: UtilityFunctionWithMembershipProof[];
|
|
175
179
|
} & Pick<ContractClassCommitments, 'id' | 'privateFunctionsRoot'> & Omit<ContractClass, 'privateFunctions'>;
|
|
176
180
|
export type ContractClassPublicWithCommitment = ContractClassPublic & Pick<ContractClassCommitments, 'publicBytecodeCommitment'>;
|
|
177
181
|
export declare const ContractClassPublicSchema: z.ZodIntersection<z.ZodObject<{
|
|
@@ -210,7 +214,7 @@ export declare const ContractClassPublicSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
210
214
|
}>>, z.ZodObject<{
|
|
211
215
|
artifactMetadataHash: z.ZodType<Fr, any, string>;
|
|
212
216
|
functionMetadataHash: z.ZodType<Fr, any, string>;
|
|
213
|
-
|
|
217
|
+
utilityFunctionsTreeRoot: z.ZodType<Fr, any, string>;
|
|
214
218
|
privateFunctionTreeSiblingPath: z.ZodArray<z.ZodType<Fr, any, string>, "many">;
|
|
215
219
|
privateFunctionTreeLeafIndex: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
216
220
|
artifactTreeSiblingPath: z.ZodArray<z.ZodType<Fr, any, string>, "many">;
|
|
@@ -218,7 +222,7 @@ export declare const ContractClassPublicSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
218
222
|
}, "strip", z.ZodTypeAny, {
|
|
219
223
|
functionMetadataHash: Fr;
|
|
220
224
|
artifactMetadataHash: Fr;
|
|
221
|
-
|
|
225
|
+
utilityFunctionsTreeRoot: Fr;
|
|
222
226
|
privateFunctionTreeSiblingPath: Fr[];
|
|
223
227
|
privateFunctionTreeLeafIndex: number;
|
|
224
228
|
artifactTreeSiblingPath: Fr[];
|
|
@@ -226,13 +230,13 @@ export declare const ContractClassPublicSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
226
230
|
}, {
|
|
227
231
|
functionMetadataHash: string;
|
|
228
232
|
artifactMetadataHash: string;
|
|
229
|
-
|
|
233
|
+
utilityFunctionsTreeRoot: string;
|
|
230
234
|
privateFunctionTreeSiblingPath: string[];
|
|
231
235
|
privateFunctionTreeLeafIndex: string | number | bigint;
|
|
232
236
|
artifactTreeSiblingPath: string[];
|
|
233
237
|
artifactTreeLeafIndex: string | number | bigint;
|
|
234
238
|
}>>, "many">;
|
|
235
|
-
|
|
239
|
+
utilityFunctions: z.ZodArray<z.ZodIntersection<z.ZodObject<{
|
|
236
240
|
/** lala */
|
|
237
241
|
selector: ZodFor<FunctionSelector>;
|
|
238
242
|
bytecode: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Buffer, string>, z.ZodEffects<z.ZodObject<{
|
|
@@ -287,13 +291,13 @@ export declare const ContractClassPublicSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
287
291
|
} & {
|
|
288
292
|
functionMetadataHash: Fr;
|
|
289
293
|
artifactMetadataHash: Fr;
|
|
290
|
-
|
|
294
|
+
utilityFunctionsTreeRoot: Fr;
|
|
291
295
|
privateFunctionTreeSiblingPath: Fr[];
|
|
292
296
|
privateFunctionTreeLeafIndex: number;
|
|
293
297
|
artifactTreeSiblingPath: Fr[];
|
|
294
298
|
artifactTreeLeafIndex: number;
|
|
295
299
|
})[];
|
|
296
|
-
|
|
300
|
+
utilityFunctions: ({
|
|
297
301
|
bytecode: Buffer;
|
|
298
302
|
selector: FunctionSelector;
|
|
299
303
|
} & {
|
|
@@ -317,13 +321,13 @@ export declare const ContractClassPublicSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
317
321
|
} & {
|
|
318
322
|
functionMetadataHash: string;
|
|
319
323
|
artifactMetadataHash: string;
|
|
320
|
-
|
|
324
|
+
utilityFunctionsTreeRoot: string;
|
|
321
325
|
privateFunctionTreeSiblingPath: string[];
|
|
322
326
|
privateFunctionTreeLeafIndex: string | number | bigint;
|
|
323
327
|
artifactTreeSiblingPath: string[];
|
|
324
328
|
artifactTreeLeafIndex: string | number | bigint;
|
|
325
329
|
})[];
|
|
326
|
-
|
|
330
|
+
utilityFunctions: ({
|
|
327
331
|
bytecode: string | {
|
|
328
332
|
type: "Buffer";
|
|
329
333
|
data: number[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_class.d.ts","sourceRoot":"","sources":["../../../src/contract/interfaces/contract_class.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM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,MAAM,MAAM,mBAAmB,GAAG;IAChC,gBAAgB,EAAE,4CAA4C,EAAE,CAAC;IACjE,gBAAgB,EAAE,kCAAkC,EAAE,CAAC;CACxD,GAAG,IAAI,CAAC,wBAAwB,EAAE,IAAI,GAAG,sBAAsB,CAAC,GAC/D,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAE1C,MAAM,MAAM,iCAAiC,GAAG,mBAAmB,GACjE,IAAI,CAAC,wBAAwB,EAAE,0BAA0B,CAAC,CAAC;AAE7D,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAnFpC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FqF,CAAC;AAEnG,qEAAqE;AACrE,MAAM,MAAM,kCAAkC,GAAG;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,GAAG,mBAAmB,CAAC"}
|
|
@@ -9,20 +9,20 @@ const PrivateFunctionSchema = z.object({
|
|
|
9
9
|
const ExecutablePrivateFunctionSchema = PrivateFunctionSchema.and(z.object({
|
|
10
10
|
bytecode: schemas.Buffer
|
|
11
11
|
}));
|
|
12
|
-
const
|
|
12
|
+
const UtilityFunctionSchema = z.object({
|
|
13
13
|
/** lala */ selector: FunctionSelector.schema,
|
|
14
14
|
bytecode: schemas.Buffer
|
|
15
15
|
});
|
|
16
16
|
const PrivateFunctionMembershipProofSchema = z.object({
|
|
17
17
|
artifactMetadataHash: schemas.Fr,
|
|
18
18
|
functionMetadataHash: schemas.Fr,
|
|
19
|
-
|
|
19
|
+
utilityFunctionsTreeRoot: schemas.Fr,
|
|
20
20
|
privateFunctionTreeSiblingPath: z.array(schemas.Fr),
|
|
21
21
|
privateFunctionTreeLeafIndex: schemas.Integer,
|
|
22
22
|
artifactTreeSiblingPath: z.array(schemas.Fr),
|
|
23
23
|
artifactTreeLeafIndex: schemas.Integer
|
|
24
24
|
});
|
|
25
|
-
const
|
|
25
|
+
const UtilityFunctionMembershipProofSchema = z.object({
|
|
26
26
|
artifactMetadataHash: schemas.Fr,
|
|
27
27
|
functionMetadataHash: schemas.Fr,
|
|
28
28
|
privateFunctionsArtifactTreeRoot: schemas.Fr,
|
|
@@ -42,7 +42,7 @@ export const ContractClassPublicSchema = z.object({
|
|
|
42
42
|
id: schemas.Fr,
|
|
43
43
|
privateFunctionsRoot: schemas.Fr,
|
|
44
44
|
privateFunctions: z.array(ExecutablePrivateFunctionSchema.and(PrivateFunctionMembershipProofSchema)),
|
|
45
|
-
|
|
45
|
+
utilityFunctions: z.array(UtilityFunctionSchema.and(UtilityFunctionMembershipProofSchema))
|
|
46
46
|
}).and(ContractClassSchema.omit({
|
|
47
47
|
privateFunctions: true
|
|
48
48
|
}));
|
|
@@ -58,12 +58,12 @@ export declare const ContractInstanceSchema: z.ZodObject<{
|
|
|
58
58
|
}>;
|
|
59
59
|
}, "strip", z.ZodTypeAny, {
|
|
60
60
|
version: 1;
|
|
61
|
+
publicKeys: PublicKeys;
|
|
61
62
|
salt: Fr;
|
|
62
63
|
deployer: AztecAddress;
|
|
63
64
|
currentContractClassId: Fr;
|
|
64
65
|
originalContractClassId: Fr;
|
|
65
66
|
initializationHash: Fr;
|
|
66
|
-
publicKeys: PublicKeys;
|
|
67
67
|
}, {
|
|
68
68
|
version: 1;
|
|
69
69
|
publicKeys: {
|
|
@@ -108,12 +108,12 @@ export declare const ContractInstanceWithAddressSchema: z.ZodIntersection<z.ZodO
|
|
|
108
108
|
}>;
|
|
109
109
|
}, "strip", z.ZodTypeAny, {
|
|
110
110
|
version: 1;
|
|
111
|
+
publicKeys: PublicKeys;
|
|
111
112
|
salt: Fr;
|
|
112
113
|
deployer: AztecAddress;
|
|
113
114
|
currentContractClassId: Fr;
|
|
114
115
|
originalContractClassId: Fr;
|
|
115
116
|
initializationHash: Fr;
|
|
116
|
-
publicKeys: PublicKeys;
|
|
117
117
|
}, {
|
|
118
118
|
version: 1;
|
|
119
119
|
publicKeys: {
|
|
@@ -22,7 +22,7 @@ export declare function createPrivateFunctionMembershipProof(selector: FunctionS
|
|
|
22
22
|
* // Compute artifact leaf and assert it belongs to the artifact
|
|
23
23
|
* artifact_function_leaf = sha256(selector, metadata_hash, sha256(bytecode))
|
|
24
24
|
* computed_artifact_private_function_tree_root = compute_root(artifact_function_leaf, artifact_function_tree_sibling_path)
|
|
25
|
-
* computed_artifact_hash = sha256(computed_artifact_private_function_tree_root,
|
|
25
|
+
* computed_artifact_hash = sha256(computed_artifact_private_function_tree_root, utility_functions_artifact_tree_root, artifact_metadata_hash)
|
|
26
26
|
* assert computed_artifact_hash == contract_class.artifact_hash
|
|
27
27
|
* ```
|
|
28
28
|
* @param fn - Function to check membership proof for.
|
|
@@ -25,7 +25,7 @@ import { computePrivateFunctionLeaf, computePrivateFunctionsTree } from './priva
|
|
|
25
25
|
throw new Error(`Private function with selector ${selector.toString()} not found`);
|
|
26
26
|
}
|
|
27
27
|
// Compute preimage for the artifact hash
|
|
28
|
-
const {
|
|
28
|
+
const { utilityFunctionRoot: utilityFunctionsTreeRoot, metadataHash: artifactMetadataHash } = await computeArtifactHashPreimage(artifact);
|
|
29
29
|
// We need two sibling paths because private function information is split across two trees:
|
|
30
30
|
// The "private function tree" captures the selectors and verification keys, and is used in the kernel circuit for verifying the proof generated by the app circuit.
|
|
31
31
|
const functionLeaf = await computePrivateFunctionLeaf(privateFunction);
|
|
@@ -47,7 +47,7 @@ import { computePrivateFunctionLeaf, computePrivateFunctionsTree } from './priva
|
|
|
47
47
|
functionLeaf: '0x' + functionLeaf.toString('hex'),
|
|
48
48
|
artifactMetadataHash,
|
|
49
49
|
privateFunctionsTreeRoot: '0x' + functionsTree.root.toString('hex'),
|
|
50
|
-
|
|
50
|
+
utilityFunctionsTreeRoot,
|
|
51
51
|
artifactFunctionTreeSiblingPath: artifactTreeSiblingPath.map((fr)=>fr.toString()).join(','),
|
|
52
52
|
privateFunctionTreeSiblingPath: functionsTreeSiblingPath.map((fr)=>fr.toString()).join(',')
|
|
53
53
|
});
|
|
@@ -56,7 +56,7 @@ import { computePrivateFunctionLeaf, computePrivateFunctionsTree } from './priva
|
|
|
56
56
|
artifactTreeLeafIndex,
|
|
57
57
|
artifactMetadataHash,
|
|
58
58
|
functionMetadataHash,
|
|
59
|
-
|
|
59
|
+
utilityFunctionsTreeRoot,
|
|
60
60
|
privateFunctionTreeSiblingPath: functionsTreeSiblingPath,
|
|
61
61
|
privateFunctionTreeLeafIndex: functionsTreeLeafIndex
|
|
62
62
|
};
|
|
@@ -77,7 +77,7 @@ import { computePrivateFunctionLeaf, computePrivateFunctionsTree } from './priva
|
|
|
77
77
|
* // Compute artifact leaf and assert it belongs to the artifact
|
|
78
78
|
* artifact_function_leaf = sha256(selector, metadata_hash, sha256(bytecode))
|
|
79
79
|
* computed_artifact_private_function_tree_root = compute_root(artifact_function_leaf, artifact_function_tree_sibling_path)
|
|
80
|
-
* computed_artifact_hash = sha256(computed_artifact_private_function_tree_root,
|
|
80
|
+
* computed_artifact_hash = sha256(computed_artifact_private_function_tree_root, utility_functions_artifact_tree_root, artifact_metadata_hash)
|
|
81
81
|
* assert computed_artifact_hash == contract_class.artifact_hash
|
|
82
82
|
* ```
|
|
83
83
|
* @param fn - Function to check membership proof for.
|
|
@@ -105,7 +105,7 @@ import { computePrivateFunctionLeaf, computePrivateFunctionsTree } from './priva
|
|
|
105
105
|
const computedArtifactPrivateFunctionTreeRoot = Fr.fromBuffer(computedArtifactPrivateFunctionTreeRootBuffer);
|
|
106
106
|
const computedArtifactHash = await computeArtifactHash({
|
|
107
107
|
privateFunctionRoot: computedArtifactPrivateFunctionTreeRoot,
|
|
108
|
-
|
|
108
|
+
utilityFunctionRoot: fn.utilityFunctionsTreeRoot,
|
|
109
109
|
metadataHash: fn.artifactMetadataHash
|
|
110
110
|
});
|
|
111
111
|
if (!contractClass.artifactHash.equals(computedArtifactHash)) {
|
|
@@ -114,7 +114,7 @@ import { computePrivateFunctionLeaf, computePrivateFunctionsTree } from './priva
|
|
|
114
114
|
computedArtifactHash,
|
|
115
115
|
computedFunctionArtifactHash: functionArtifactHash,
|
|
116
116
|
computedArtifactPrivateFunctionTreeRoot,
|
|
117
|
-
|
|
117
|
+
utilityFunctionRoot: fn.utilityFunctionsTreeRoot,
|
|
118
118
|
metadataHash: fn.artifactMetadataHash,
|
|
119
119
|
artifactFunctionTreeSiblingPath: fn.artifactTreeSiblingPath.map((fr)=>fr.toString()).join(',')
|
|
120
120
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ContractArtifact, FunctionSelector } from '../abi/index.js';
|
|
2
|
+
import type { ContractClassPublic, UtilityFunctionMembershipProof, UtilityFunctionWithMembershipProof } from './interfaces/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a membership proof for a utility function in a contract class, to be verified via `isValidUtilityFunctionMembershipProof`.
|
|
5
|
+
* @param selector - Selector of the function to create the proof for.
|
|
6
|
+
* @param artifact - Artifact of the contract class where the function is defined.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createUtilityFunctionMembershipProof(selector: FunctionSelector, artifact: ContractArtifact): Promise<UtilityFunctionMembershipProof>;
|
|
9
|
+
/**
|
|
10
|
+
* Verifies that a utility function with a membership proof as emitted by the ClassRegisterer contract is valid,
|
|
11
|
+
* as defined in the protocol specs at contract-deployment/classes:
|
|
12
|
+
*
|
|
13
|
+
* ```
|
|
14
|
+
* // Load contract class from local db
|
|
15
|
+
* contract_class = db.get_contract_class(contract_class_id)
|
|
16
|
+
*
|
|
17
|
+
* // Compute artifact leaf and assert it belongs to the artifact
|
|
18
|
+
* artifact_function_leaf = sha256(selector, metadata_hash, sha256(bytecode))
|
|
19
|
+
* computed_artifact_utility_function_tree_root = compute_root(artifact_function_leaf, artifact_function_tree_sibling_path, artifact_function_tree_leaf_index)
|
|
20
|
+
* computed_artifact_hash = sha256(private_functions_artifact_tree_root, computed_artifact_utility_function_tree_root, artifact_metadata_hash)
|
|
21
|
+
* assert computed_artifact_hash == contract_class.artifact_hash
|
|
22
|
+
* ```
|
|
23
|
+
* @param fn - Function to check membership proof for.
|
|
24
|
+
* @param contractClass - In which contract class the function is expected to be.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isValidUtilityFunctionMembershipProof(fn: UtilityFunctionWithMembershipProof, contractClass: Pick<ContractClassPublic, 'artifactHash'>): Promise<boolean>;
|
|
27
|
+
//# sourceMappingURL=utility_function_membership_proof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility_function_membership_proof.d.ts","sourceRoot":"","sources":["../../src/contract/utility_function_membership_proof.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgB,MAAM,iBAAiB,CAAC;AASxF,OAAO,KAAK,EACV,mBAAmB,EACnB,8BAA8B,EAC9B,kCAAkC,EACnC,MAAM,uBAAuB,CAAC;AAE/B;;;;GAIG;AACH,wBAAsB,oCAAoC,CACxD,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,8BAA8B,CAAC,CAsCzC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,qCAAqC,CACzD,EAAE,EAAE,kCAAkC,EACtC,aAAa,EAAE,IAAI,CAAC,mBAAmB,EAAE,cAAc,CAAC,oBA+BzD"}
|
|
@@ -4,20 +4,20 @@ import { computeRootFromSiblingPath } from '@aztec/foundation/trees';
|
|
|
4
4
|
import { FunctionSelector, FunctionType } from '../abi/index.js';
|
|
5
5
|
import { computeArtifactFunctionTree, computeArtifactHash, computeArtifactHashPreimage, computeFunctionArtifactHash, computeFunctionMetadataHash, getArtifactMerkleTreeHasher } from './artifact_hash.js';
|
|
6
6
|
/**
|
|
7
|
-
* Creates a membership proof for
|
|
7
|
+
* Creates a membership proof for a utility function in a contract class, to be verified via `isValidUtilityFunctionMembershipProof`.
|
|
8
8
|
* @param selector - Selector of the function to create the proof for.
|
|
9
9
|
* @param artifact - Artifact of the contract class where the function is defined.
|
|
10
|
-
*/ export async function
|
|
10
|
+
*/ export async function createUtilityFunctionMembershipProof(selector, artifact) {
|
|
11
11
|
const log = createLogger('circuits:function_membership_proof');
|
|
12
12
|
// Locate function artifact
|
|
13
|
-
const
|
|
14
|
-
const
|
|
13
|
+
const utilityFunctions = artifact.functions.filter((fn)=>fn.functionType === FunctionType.UTILITY);
|
|
14
|
+
const utilityFunctionsAndSelectors = await Promise.all(utilityFunctions.map(async (fn)=>({
|
|
15
15
|
fn,
|
|
16
16
|
selector: await FunctionSelector.fromNameAndParameters(fn)
|
|
17
17
|
})));
|
|
18
|
-
const fn =
|
|
18
|
+
const fn = utilityFunctionsAndSelectors.find((fnAndSelector)=>selector.equals(fnAndSelector.selector))?.fn;
|
|
19
19
|
if (!fn) {
|
|
20
|
-
throw new Error(`
|
|
20
|
+
throw new Error(`Utility function with selector ${selector.toString()} not found`);
|
|
21
21
|
}
|
|
22
22
|
// Compute preimage for the artifact hash
|
|
23
23
|
const { privateFunctionRoot: privateFunctionsArtifactTreeRoot, metadataHash: artifactMetadataHash } = await computeArtifactHashPreimage(artifact);
|
|
@@ -27,10 +27,10 @@ import { computeArtifactFunctionTree, computeArtifactHash, computeArtifactHashPr
|
|
|
27
27
|
...fn,
|
|
28
28
|
functionMetadataHash
|
|
29
29
|
});
|
|
30
|
-
const artifactTree = await computeArtifactFunctionTree(artifact, FunctionType.
|
|
30
|
+
const artifactTree = await computeArtifactFunctionTree(artifact, FunctionType.UTILITY);
|
|
31
31
|
const artifactTreeLeafIndex = artifactTree.getIndex(functionArtifactHash.toBuffer());
|
|
32
32
|
const artifactTreeSiblingPath = artifactTree.getSiblingPath(artifactTreeLeafIndex).map(Fr.fromBuffer);
|
|
33
|
-
log.debug(`Computed proof for
|
|
33
|
+
log.debug(`Computed proof for utility function with selector ${selector.toString()}`, {
|
|
34
34
|
functionArtifactHash,
|
|
35
35
|
functionMetadataHash,
|
|
36
36
|
artifactMetadataHash,
|
|
@@ -46,7 +46,7 @@ import { computeArtifactFunctionTree, computeArtifactHash, computeArtifactHashPr
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* Verifies that
|
|
49
|
+
* Verifies that a utility function with a membership proof as emitted by the ClassRegisterer contract is valid,
|
|
50
50
|
* as defined in the protocol specs at contract-deployment/classes:
|
|
51
51
|
*
|
|
52
52
|
* ```
|
|
@@ -55,20 +55,20 @@ import { computeArtifactFunctionTree, computeArtifactHash, computeArtifactHashPr
|
|
|
55
55
|
*
|
|
56
56
|
* // Compute artifact leaf and assert it belongs to the artifact
|
|
57
57
|
* artifact_function_leaf = sha256(selector, metadata_hash, sha256(bytecode))
|
|
58
|
-
*
|
|
59
|
-
* computed_artifact_hash = sha256(private_functions_artifact_tree_root,
|
|
58
|
+
* computed_artifact_utility_function_tree_root = compute_root(artifact_function_leaf, artifact_function_tree_sibling_path, artifact_function_tree_leaf_index)
|
|
59
|
+
* computed_artifact_hash = sha256(private_functions_artifact_tree_root, computed_artifact_utility_function_tree_root, artifact_metadata_hash)
|
|
60
60
|
* assert computed_artifact_hash == contract_class.artifact_hash
|
|
61
61
|
* ```
|
|
62
62
|
* @param fn - Function to check membership proof for.
|
|
63
63
|
* @param contractClass - In which contract class the function is expected to be.
|
|
64
|
-
*/ export async function
|
|
64
|
+
*/ export async function isValidUtilityFunctionMembershipProof(fn, contractClass) {
|
|
65
65
|
const log = createLogger('circuits:function_membership_proof');
|
|
66
66
|
const functionArtifactHash = await computeFunctionArtifactHash(fn);
|
|
67
67
|
const computedArtifactFunctionTreeRootBuffer = await computeRootFromSiblingPath(functionArtifactHash.toBuffer(), fn.artifactTreeSiblingPath.map((fr)=>fr.toBuffer()), fn.artifactTreeLeafIndex, getArtifactMerkleTreeHasher());
|
|
68
68
|
const computedArtifactFunctionTreeRoot = Fr.fromBuffer(computedArtifactFunctionTreeRootBuffer);
|
|
69
69
|
const computedArtifactHash = await computeArtifactHash({
|
|
70
70
|
privateFunctionRoot: fn.privateFunctionsArtifactTreeRoot,
|
|
71
|
-
|
|
71
|
+
utilityFunctionRoot: computedArtifactFunctionTreeRoot,
|
|
72
72
|
metadataHash: fn.artifactMetadataHash
|
|
73
73
|
});
|
|
74
74
|
if (!contractClass.artifactHash.equals(computedArtifactHash)) {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { FunctionSelector } from '../abi/function_selector.js';
|
|
4
|
+
import type { AztecAddress } from '../aztec-address/index.js';
|
|
5
|
+
import { type ZodFor } from '../schemas/index.js';
|
|
6
|
+
type AllowedInstance = {
|
|
7
|
+
address: AztecAddress;
|
|
8
|
+
};
|
|
9
|
+
type AllowedInstanceFunction = {
|
|
10
|
+
address: AztecAddress;
|
|
11
|
+
selector: FunctionSelector;
|
|
12
|
+
};
|
|
13
|
+
type AllowedClass = {
|
|
14
|
+
classId: Fr;
|
|
15
|
+
};
|
|
16
|
+
type AllowedClassFunction = {
|
|
17
|
+
classId: Fr;
|
|
18
|
+
selector: FunctionSelector;
|
|
19
|
+
};
|
|
20
|
+
export type AllowedElement = AllowedInstance | AllowedInstanceFunction | AllowedClass | AllowedClassFunction;
|
|
21
|
+
export declare const AllowedElementSchema: z.ZodUnion<[z.ZodObject<{
|
|
22
|
+
address: ZodFor<AztecAddress>;
|
|
23
|
+
selector: ZodFor<FunctionSelector>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
selector: FunctionSelector;
|
|
26
|
+
address: AztecAddress;
|
|
27
|
+
}, {
|
|
28
|
+
selector?: any;
|
|
29
|
+
address?: any;
|
|
30
|
+
}>, z.ZodObject<{
|
|
31
|
+
address: ZodFor<AztecAddress>;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
address: AztecAddress;
|
|
34
|
+
}, {
|
|
35
|
+
address?: any;
|
|
36
|
+
}>, z.ZodObject<{
|
|
37
|
+
classId: ZodFor<Fr>;
|
|
38
|
+
selector: ZodFor<FunctionSelector>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
selector: FunctionSelector;
|
|
41
|
+
classId: Fr;
|
|
42
|
+
}, {
|
|
43
|
+
selector?: any;
|
|
44
|
+
classId?: any;
|
|
45
|
+
}>, z.ZodObject<{
|
|
46
|
+
classId: ZodFor<Fr>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
classId: Fr;
|
|
49
|
+
}, {
|
|
50
|
+
classId?: any;
|
|
51
|
+
}>]>;
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=allowed_element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowed_element.d.ts","sourceRoot":"","sources":["../../src/interfaces/allowed_element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,qBAAqB,CAAC;AAE3D,KAAK,eAAe,GAAG;IAAE,OAAO,EAAE,YAAY,CAAA;CAAE,CAAC;AACjD,KAAK,uBAAuB,GAAG;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAA;CAAE,CAAC;AACrF,KAAK,YAAY,GAAG;IAAE,OAAO,EAAE,EAAE,CAAA;CAAE,CAAC;AACpC,KAAK,oBAAoB,GAAG;IAAE,OAAO,EAAE,EAAE,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,uBAAuB,GAAG,YAAY,GAAG,oBAAoB,CAAC;AAE7G,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { schemas } from '../schemas/index.js';
|
|
3
|
+
export const AllowedElementSchema = z.union([
|
|
4
|
+
z.object({
|
|
5
|
+
address: schemas.AztecAddress,
|
|
6
|
+
selector: schemas.FunctionSelector
|
|
7
|
+
}),
|
|
8
|
+
z.object({
|
|
9
|
+
address: schemas.AztecAddress
|
|
10
|
+
}),
|
|
11
|
+
z.object({
|
|
12
|
+
classId: schemas.Fr,
|
|
13
|
+
selector: schemas.FunctionSelector
|
|
14
|
+
}),
|
|
15
|
+
z.object({
|
|
16
|
+
classId: schemas.Fr
|
|
17
|
+
})
|
|
18
|
+
]);
|