@aztec/stdlib 5.0.0-nightly.20260521 → 5.0.0-nightly.20260523
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/avm/avm.d.ts +33 -26
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +6 -3
- package/dest/avm/avm_proving_request.d.ts +11 -9
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/avm/message_pack.js +12 -3
- package/dest/contract/complete_address.d.ts +2 -1
- package/dest/contract/complete_address.d.ts.map +1 -1
- package/dest/contract/complete_address.js +6 -2
- package/dest/contract/contract_address.d.ts +5 -5
- package/dest/contract/contract_address.d.ts.map +1 -1
- package/dest/contract/contract_address.js +4 -3
- package/dest/contract/contract_instance.d.ts +4 -2
- package/dest/contract/contract_instance.d.ts.map +1 -1
- package/dest/contract/contract_instance.js +10 -3
- package/dest/contract/interfaces/contract_instance.d.ts +24 -20
- package/dest/contract/interfaces/contract_instance.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance.js +4 -2
- package/dest/interfaces/proving-job.d.ts +11 -9
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/kernel/hints/key_validation_request.d.ts +12 -8
- package/dest/kernel/hints/key_validation_request.d.ts.map +1 -1
- package/dest/kernel/hints/key_validation_request.js +20 -18
- package/dest/keys/derivation.d.ts +6 -2
- package/dest/keys/derivation.d.ts.map +1 -1
- package/dest/keys/derivation.js +12 -5
- package/dest/keys/public_key.d.ts +22 -3
- package/dest/keys/public_key.d.ts.map +1 -1
- package/dest/keys/public_key.js +20 -1
- package/dest/keys/public_keys.d.ts +37 -69
- package/dest/keys/public_keys.d.ts.map +1 -1
- package/dest/keys/public_keys.js +77 -74
- package/dest/tests/factories.d.ts +2 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +10 -6
- package/dest/tx/simulated_tx.d.ts +17 -13
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/avm/avm.ts +5 -0
- package/src/avm/message_pack.ts +12 -3
- package/src/contract/complete_address.ts +7 -3
- package/src/contract/contract_address.ts +5 -5
- package/src/contract/contract_instance.ts +11 -2
- package/src/contract/interfaces/contract_instance.ts +6 -2
- package/src/kernel/hints/key_validation_request.ts +18 -16
- package/src/keys/derivation.ts +15 -8
- package/src/keys/public_key.ts +26 -2
- package/src/keys/public_keys.ts +80 -116
- package/src/tests/factories.ts +20 -10
|
@@ -36,46 +36,49 @@ export declare class SimulationOverrides {
|
|
|
36
36
|
}[] | null | undefined>>;
|
|
37
37
|
contracts: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
38
38
|
instance: z.ZodIntersection<z.ZodObject<{
|
|
39
|
-
version: z.ZodLiteral<
|
|
39
|
+
version: z.ZodLiteral<2>;
|
|
40
40
|
salt: ZodFor<import("@aztec/foundation/schemas").Fr>;
|
|
41
41
|
deployer: ZodFor<import("../aztec-address/index.js").AztecAddress>;
|
|
42
42
|
currentContractClassId: ZodFor<import("@aztec/foundation/schemas").Fr>;
|
|
43
43
|
originalContractClassId: ZodFor<import("@aztec/foundation/schemas").Fr>;
|
|
44
44
|
initializationHash: ZodFor<import("@aztec/foundation/schemas").Fr>;
|
|
45
|
+
immutablesHash: ZodFor<import("@aztec/foundation/schemas").Fr>;
|
|
45
46
|
publicKeys: z.ZodPipe<z.ZodObject<{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
npkMHash: z.ZodType<import("@aztec/foundation/schemas").Fr, string, z.core.$ZodTypeInternals<import("@aztec/foundation/schemas").Fr, string>>;
|
|
48
|
+
ivpkM: z.ZodType<import("@aztec/foundation/schemas").Point, string, z.core.$ZodTypeInternals<import("@aztec/foundation/schemas").Point, string>>;
|
|
49
|
+
ovpkMHash: z.ZodType<import("@aztec/foundation/schemas").Fr, string, z.core.$ZodTypeInternals<import("@aztec/foundation/schemas").Fr, string>>;
|
|
50
|
+
tpkMHash: z.ZodType<import("@aztec/foundation/schemas").Fr, string, z.core.$ZodTypeInternals<import("@aztec/foundation/schemas").Fr, string>>;
|
|
50
51
|
}, z.core.$strip>, z.ZodTransform<import("../keys/public_keys.js").PublicKeys, {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
npkMHash: import("@aztec/foundation/schemas").Fr;
|
|
53
|
+
ivpkM: import("@aztec/foundation/schemas").Point;
|
|
54
|
+
ovpkMHash: import("@aztec/foundation/schemas").Fr;
|
|
55
|
+
tpkMHash: import("@aztec/foundation/schemas").Fr;
|
|
55
56
|
}>>;
|
|
56
57
|
}, z.core.$strip>, z.ZodObject<{
|
|
57
58
|
address: ZodFor<import("../aztec-address/index.js").AztecAddress>;
|
|
58
59
|
}, z.core.$strip>>;
|
|
59
60
|
}, z.core.$strip>>>>, z.ZodTransform<Record<string, {
|
|
60
61
|
instance: {
|
|
61
|
-
version:
|
|
62
|
+
version: 2;
|
|
62
63
|
salt: import("@aztec/foundation/schemas").Fr;
|
|
63
64
|
deployer: import("../aztec-address/index.js").AztecAddress;
|
|
64
65
|
currentContractClassId: import("@aztec/foundation/schemas").Fr;
|
|
65
66
|
originalContractClassId: import("@aztec/foundation/schemas").Fr;
|
|
66
67
|
initializationHash: import("@aztec/foundation/schemas").Fr;
|
|
68
|
+
immutablesHash: import("@aztec/foundation/schemas").Fr;
|
|
67
69
|
publicKeys: import("../keys/public_keys.js").PublicKeys;
|
|
68
70
|
} & {
|
|
69
71
|
address: import("../aztec-address/index.js").AztecAddress;
|
|
70
72
|
};
|
|
71
73
|
}> | undefined, Record<string, {
|
|
72
74
|
instance: {
|
|
73
|
-
version:
|
|
75
|
+
version: 2;
|
|
74
76
|
salt: import("@aztec/foundation/schemas").Fr;
|
|
75
77
|
deployer: import("../aztec-address/index.js").AztecAddress;
|
|
76
78
|
currentContractClassId: import("@aztec/foundation/schemas").Fr;
|
|
77
79
|
originalContractClassId: import("@aztec/foundation/schemas").Fr;
|
|
78
80
|
initializationHash: import("@aztec/foundation/schemas").Fr;
|
|
81
|
+
immutablesHash: import("@aztec/foundation/schemas").Fr;
|
|
79
82
|
publicKeys: import("../keys/public_keys.js").PublicKeys;
|
|
80
83
|
} & {
|
|
81
84
|
address: import("../aztec-address/index.js").AztecAddress;
|
|
@@ -89,12 +92,13 @@ export declare class SimulationOverrides {
|
|
|
89
92
|
}[] | undefined;
|
|
90
93
|
contracts: Record<string, {
|
|
91
94
|
instance: {
|
|
92
|
-
version:
|
|
95
|
+
version: 2;
|
|
93
96
|
salt: import("@aztec/foundation/schemas").Fr;
|
|
94
97
|
deployer: import("../aztec-address/index.js").AztecAddress;
|
|
95
98
|
currentContractClassId: import("@aztec/foundation/schemas").Fr;
|
|
96
99
|
originalContractClassId: import("@aztec/foundation/schemas").Fr;
|
|
97
100
|
initializationHash: import("@aztec/foundation/schemas").Fr;
|
|
101
|
+
immutablesHash: import("@aztec/foundation/schemas").Fr;
|
|
98
102
|
publicKeys: import("../keys/public_keys.js").PublicKeys;
|
|
99
103
|
} & {
|
|
100
104
|
address: import("../aztec-address/index.js").AztecAddress;
|
|
@@ -133,4 +137,4 @@ export declare class TxSimulationResult {
|
|
|
133
137
|
* @returns
|
|
134
138
|
*/
|
|
135
139
|
export declare function accumulatePrivateReturnValues(executionResult: PrivateExecutionResult): NestedProcessReturnValues;
|
|
136
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
140
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2ltdWxhdGVkX3R4LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHgvc2ltdWxhdGVkX3R4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBWSxNQUFNLDJCQUEyQixDQUFDO0FBQ2xFLE9BQU8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;IAED,OAAa,MAAM,gCAMlB;IAED,sBAAsB,8BAErB;IAED,aAAa,IAAI,OAAO,CAAC,EAAE,CAAC,CAE3B;IAED,qBAAqB,gCAEpB;CACF;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,eAAe,EAAE,sBAAsB,GAAG,yBAAyB,CAWhH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "5.0.0-nightly.
|
|
3
|
+
"version": "5.0.0-nightly.20260523",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -92,13 +92,13 @@
|
|
|
92
92
|
},
|
|
93
93
|
"dependencies": {
|
|
94
94
|
"@aws-sdk/client-s3": "^3.892.0",
|
|
95
|
-
"@aztec/bb.js": "5.0.0-nightly.
|
|
96
|
-
"@aztec/blob-lib": "5.0.0-nightly.
|
|
97
|
-
"@aztec/constants": "5.0.0-nightly.
|
|
98
|
-
"@aztec/ethereum": "5.0.0-nightly.
|
|
99
|
-
"@aztec/foundation": "5.0.0-nightly.
|
|
100
|
-
"@aztec/l1-artifacts": "5.0.0-nightly.
|
|
101
|
-
"@aztec/noir-noirc_abi": "5.0.0-nightly.
|
|
95
|
+
"@aztec/bb.js": "5.0.0-nightly.20260523",
|
|
96
|
+
"@aztec/blob-lib": "5.0.0-nightly.20260523",
|
|
97
|
+
"@aztec/constants": "5.0.0-nightly.20260523",
|
|
98
|
+
"@aztec/ethereum": "5.0.0-nightly.20260523",
|
|
99
|
+
"@aztec/foundation": "5.0.0-nightly.20260523",
|
|
100
|
+
"@aztec/l1-artifacts": "5.0.0-nightly.20260523",
|
|
101
|
+
"@aztec/noir-noirc_abi": "5.0.0-nightly.20260523",
|
|
102
102
|
"@google-cloud/storage": "^7.15.0",
|
|
103
103
|
"axios": "^1.15.1",
|
|
104
104
|
"json-stringify-deterministic": "1.0.12",
|
package/src/avm/avm.ts
CHANGED
|
@@ -130,6 +130,7 @@ export class AvmContractInstanceHint {
|
|
|
130
130
|
public readonly currentContractClassId: Fr,
|
|
131
131
|
public readonly originalContractClassId: Fr,
|
|
132
132
|
public readonly initializationHash: Fr,
|
|
133
|
+
public readonly immutablesHash: Fr,
|
|
133
134
|
public readonly publicKeys: PublicKeys,
|
|
134
135
|
) {}
|
|
135
136
|
|
|
@@ -143,6 +144,7 @@ export class AvmContractInstanceHint {
|
|
|
143
144
|
currentContractClassId: schemas.Fr,
|
|
144
145
|
originalContractClassId: schemas.Fr,
|
|
145
146
|
initializationHash: schemas.Fr,
|
|
147
|
+
immutablesHash: schemas.Fr,
|
|
146
148
|
publicKeys: PublicKeys.schema,
|
|
147
149
|
})
|
|
148
150
|
.transform(
|
|
@@ -154,6 +156,7 @@ export class AvmContractInstanceHint {
|
|
|
154
156
|
currentContractClassId,
|
|
155
157
|
originalContractClassId,
|
|
156
158
|
initializationHash,
|
|
159
|
+
immutablesHash,
|
|
157
160
|
publicKeys,
|
|
158
161
|
}) =>
|
|
159
162
|
new AvmContractInstanceHint(
|
|
@@ -164,6 +167,7 @@ export class AvmContractInstanceHint {
|
|
|
164
167
|
currentContractClassId,
|
|
165
168
|
originalContractClassId,
|
|
166
169
|
initializationHash,
|
|
170
|
+
immutablesHash,
|
|
167
171
|
publicKeys,
|
|
168
172
|
),
|
|
169
173
|
);
|
|
@@ -188,6 +192,7 @@ export class AvmContractInstanceHint {
|
|
|
188
192
|
Fr.fromPlainObject(obj.currentContractClassId),
|
|
189
193
|
Fr.fromPlainObject(obj.originalContractClassId),
|
|
190
194
|
Fr.fromPlainObject(obj.initializationHash),
|
|
195
|
+
Fr.fromPlainObject(obj.immutablesHash),
|
|
191
196
|
PublicKeys.fromPlainObject(obj.publicKeys),
|
|
192
197
|
);
|
|
193
198
|
}
|
package/src/avm/message_pack.ts
CHANGED
|
@@ -64,13 +64,22 @@ function setUpMessagePackExtensions() {
|
|
|
64
64
|
addExtension({
|
|
65
65
|
Class: Point,
|
|
66
66
|
write: (p: Point) => {
|
|
67
|
-
|
|
68
|
-
//
|
|
67
|
+
// TODO: Now that we use a 2 elt point representation, we should be able to handle infs here.
|
|
68
|
+
// However this opens possible bad paths with public keys and requires sanitised conversion between
|
|
69
|
+
// BB's inf representation (see below), and ours/Noir's (0, 0), and empty points from BB, when inf
|
|
70
|
+
// does not actually pass through.
|
|
71
|
+
assert(!p.isInfinite, 'Cannot serialize infinity');
|
|
69
72
|
return { x: new Fq(p.x.toBigInt()), y: new Fq(p.y.toBigInt()) };
|
|
70
73
|
},
|
|
71
74
|
read: (data: { x: Fq; y: Fq }) => {
|
|
75
|
+
// Note: BB encodes infinity as x == y == Buffer of all ones.
|
|
76
|
+
// Infinity should never pass through here, but for correctness:
|
|
77
|
+
const ALL_ONES = (1n << 256n) - 1n;
|
|
78
|
+
if (data.x.toBigInt() === ALL_ONES && data.y.toBigInt() === ALL_ONES) {
|
|
79
|
+
return Point.INFINITY;
|
|
80
|
+
}
|
|
72
81
|
// Convert Fq back to Fr for Point constructor
|
|
73
|
-
return new Point(new Fr(data.x.toBigInt()), new Fr(data.y.toBigInt())
|
|
82
|
+
return new Point(new Fr(data.x.toBigInt()), new Fr(data.y.toBigInt()));
|
|
74
83
|
},
|
|
75
84
|
});
|
|
76
85
|
// EthAddress is a class that has a buffer in TS, but is itself just a field in C++.
|
|
@@ -38,7 +38,8 @@ export class CompleteAddress {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/** Size in bytes of an instance */
|
|
41
|
-
|
|
41
|
+
// address (1 Fr) + publicKeys (1 Fr hash + 1 Point + 2 Fr hashes = 5 Fr) + partialAddress (1 Fr) = 7 Fr
|
|
42
|
+
static readonly SIZE_IN_BYTES = 32 * 7;
|
|
42
43
|
|
|
43
44
|
static get schema() {
|
|
44
45
|
return hexSchemaFor(CompleteAddress);
|
|
@@ -54,8 +55,11 @@ export class CompleteAddress {
|
|
|
54
55
|
|
|
55
56
|
static async fromSecretKeyAndPartialAddress(secretKey: Fr, partialAddress: Fr): Promise<CompleteAddress> {
|
|
56
57
|
const { publicKeys } = await deriveKeys(secretKey);
|
|
57
|
-
|
|
58
|
+
return await this.fromPublicKeysAndPartialAddress(publicKeys, partialAddress);
|
|
59
|
+
}
|
|
58
60
|
|
|
61
|
+
static async fromPublicKeysAndPartialAddress(publicKeys: PublicKeys, partialAddress: Fr): Promise<CompleteAddress> {
|
|
62
|
+
const address = await computeAddress(publicKeys, partialAddress);
|
|
59
63
|
return new CompleteAddress(address, publicKeys, partialAddress);
|
|
60
64
|
}
|
|
61
65
|
|
|
@@ -87,7 +91,7 @@ export class CompleteAddress {
|
|
|
87
91
|
* @returns A readable string representation of the complete address.
|
|
88
92
|
*/
|
|
89
93
|
public toReadableString(): string {
|
|
90
|
-
return `Address: ${this.address.toString()}\
|
|
94
|
+
return `Address: ${this.address.toString()}\nNpkM hash: ${this.publicKeys.npkMHash.toString()}\nIvpkM: ${this.publicKeys.ivpkM.toString()}\nOvpkM hash: ${this.publicKeys.ovpkMHash.toString()}\nTpkM hash: ${this.publicKeys.tpkMHash.toString()}\nPartial Address: ${this.partialAddress.toString()}\n`;
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
/**
|
|
@@ -13,9 +13,9 @@ import type { ContractInstance } from './interfaces/contract_instance.js';
|
|
|
13
13
|
/**
|
|
14
14
|
* Returns the deployment address for a given contract instance.
|
|
15
15
|
* ```
|
|
16
|
-
* salted_initialization_hash = poseidon2(DOM_SEP__SALTED_INITIALIZATION_HASH, [salt, initialization_hash, deployer])
|
|
16
|
+
* salted_initialization_hash = poseidon2(DOM_SEP__SALTED_INITIALIZATION_HASH, [salt, initialization_hash, deployer, immutables_hash])
|
|
17
17
|
* partial_address = poseidon2(DOM_SEP__PARTIAL_ADDRESS, [contract_class_id, salted_initialization_hash])
|
|
18
|
-
* address = ((poseidon2(
|
|
18
|
+
* address = ((poseidon2(DOM_SEP__CONTRACT_ADDRESS_V2, [public_keys_hash, partial_address]) * G) + ivpk_m).x <- the x-coordinate of the address point
|
|
19
19
|
* ```
|
|
20
20
|
* @param instance - A contract instance for which to calculate the deployment address.
|
|
21
21
|
*/
|
|
@@ -34,7 +34,7 @@ export async function computeContractAddressFromInstance(
|
|
|
34
34
|
*/
|
|
35
35
|
export async function computePartialAddress(
|
|
36
36
|
instance:
|
|
37
|
-
| Pick<ContractInstance, 'originalContractClassId' | 'initializationHash' | 'salt' | 'deployer'>
|
|
37
|
+
| Pick<ContractInstance, 'originalContractClassId' | 'initializationHash' | 'salt' | 'deployer' | 'immutablesHash'>
|
|
38
38
|
| { originalContractClassId: Fr; saltedInitializationHash: Fr },
|
|
39
39
|
): Promise<Fr> {
|
|
40
40
|
const saltedInitializationHash =
|
|
@@ -53,10 +53,10 @@ export async function computePartialAddress(
|
|
|
53
53
|
* @param instance - Contract instance for which to compute the salted initialization hash.
|
|
54
54
|
*/
|
|
55
55
|
export function computeSaltedInitializationHash(
|
|
56
|
-
instance: Pick<ContractInstance, 'initializationHash' | 'salt' | 'deployer'>,
|
|
56
|
+
instance: Pick<ContractInstance, 'initializationHash' | 'salt' | 'deployer' | 'immutablesHash'>,
|
|
57
57
|
): Promise<Fr> {
|
|
58
58
|
return poseidon2HashWithSeparator(
|
|
59
|
-
[instance.salt, instance.initializationHash, instance.deployer],
|
|
59
|
+
[instance.salt, instance.initializationHash, instance.deployer, instance.immutablesHash],
|
|
60
60
|
DomainSeparator.SALTED_INITIALIZATION_HASH,
|
|
61
61
|
);
|
|
62
62
|
}
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from './contract_address.js';
|
|
21
21
|
import type { ContractInstance, ContractInstanceWithAddress } from './interfaces/contract_instance.js';
|
|
22
22
|
|
|
23
|
-
const VERSION =
|
|
23
|
+
const VERSION = 2 as const;
|
|
24
24
|
|
|
25
25
|
export type ContractInstantiationData = {
|
|
26
26
|
constructorArtifact?: FunctionAbi | string;
|
|
@@ -29,6 +29,7 @@ export type ContractInstantiationData = {
|
|
|
29
29
|
salt: Fr;
|
|
30
30
|
publicKeys?: PublicKeys;
|
|
31
31
|
deployer?: AztecAddress;
|
|
32
|
+
immutablesHash?: Fr;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
export class SerializableContractInstance {
|
|
@@ -38,6 +39,7 @@ export class SerializableContractInstance {
|
|
|
38
39
|
public readonly currentContractClassId: Fr;
|
|
39
40
|
public readonly originalContractClassId: Fr;
|
|
40
41
|
public readonly initializationHash: Fr;
|
|
42
|
+
public readonly immutablesHash: Fr;
|
|
41
43
|
public readonly publicKeys: PublicKeys;
|
|
42
44
|
|
|
43
45
|
constructor(instance: ContractInstance) {
|
|
@@ -49,6 +51,7 @@ export class SerializableContractInstance {
|
|
|
49
51
|
this.currentContractClassId = instance.currentContractClassId;
|
|
50
52
|
this.originalContractClassId = instance.originalContractClassId;
|
|
51
53
|
this.initializationHash = instance.initializationHash;
|
|
54
|
+
this.immutablesHash = instance.immutablesHash;
|
|
52
55
|
this.publicKeys = instance.publicKeys;
|
|
53
56
|
}
|
|
54
57
|
|
|
@@ -60,6 +63,7 @@ export class SerializableContractInstance {
|
|
|
60
63
|
this.currentContractClassId,
|
|
61
64
|
this.originalContractClassId,
|
|
62
65
|
this.initializationHash,
|
|
66
|
+
this.immutablesHash,
|
|
63
67
|
this.publicKeys,
|
|
64
68
|
);
|
|
65
69
|
}
|
|
@@ -78,6 +82,7 @@ export class SerializableContractInstance {
|
|
|
78
82
|
currentContractClassId: reader.readObject(Fr),
|
|
79
83
|
originalContractClassId: reader.readObject(Fr),
|
|
80
84
|
initializationHash: reader.readObject(Fr),
|
|
85
|
+
immutablesHash: reader.readObject(Fr),
|
|
81
86
|
publicKeys: reader.readObject(PublicKeys),
|
|
82
87
|
});
|
|
83
88
|
}
|
|
@@ -90,6 +95,7 @@ export class SerializableContractInstance {
|
|
|
90
95
|
currentContractClassId: Fr.random(),
|
|
91
96
|
originalContractClassId: Fr.random(),
|
|
92
97
|
initializationHash: Fr.random(),
|
|
98
|
+
immutablesHash: Fr.random(),
|
|
93
99
|
publicKeys: await PublicKeys.random(),
|
|
94
100
|
...opts,
|
|
95
101
|
});
|
|
@@ -103,6 +109,7 @@ export class SerializableContractInstance {
|
|
|
103
109
|
currentContractClassId: Fr.zero(),
|
|
104
110
|
originalContractClassId: Fr.zero(),
|
|
105
111
|
initializationHash: Fr.zero(),
|
|
112
|
+
immutablesHash: Fr.zero(),
|
|
106
113
|
publicKeys: PublicKeys.default(),
|
|
107
114
|
});
|
|
108
115
|
}
|
|
@@ -130,15 +137,17 @@ export async function getContractInstanceFromInstantiationParams(
|
|
|
130
137
|
)
|
|
131
138
|
: await computeInitializationHash(constructorArtifact, args);
|
|
132
139
|
const publicKeys = opts.publicKeys ?? PublicKeys.default();
|
|
140
|
+
const immutablesHash = opts.immutablesHash ?? Fr.ZERO;
|
|
133
141
|
|
|
134
142
|
const instance: ContractInstance = {
|
|
135
143
|
currentContractClassId: contractClass.id,
|
|
136
144
|
originalContractClassId: contractClass.id,
|
|
137
145
|
initializationHash,
|
|
146
|
+
immutablesHash,
|
|
138
147
|
publicKeys,
|
|
139
148
|
salt: opts.salt,
|
|
140
149
|
deployer,
|
|
141
|
-
version:
|
|
150
|
+
version: 2,
|
|
142
151
|
};
|
|
143
152
|
|
|
144
153
|
return { ...instance, address: await computeContractAddressFromInstance(instance) };
|
|
@@ -6,7 +6,7 @@ import { AztecAddress } from '../../aztec-address/index.js';
|
|
|
6
6
|
import { PublicKeys } from '../../keys/public_keys.js';
|
|
7
7
|
import { schemas, zodFor } from '../../schemas/index.js';
|
|
8
8
|
|
|
9
|
-
const VERSION =
|
|
9
|
+
const VERSION = 2 as const;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* A contract instance is a concrete deployment of a contract class. It always references a contract class,
|
|
@@ -26,6 +26,8 @@ export interface ContractInstance {
|
|
|
26
26
|
originalContractClassId: Fr;
|
|
27
27
|
/** Hash of the selector and arguments to the constructor. */
|
|
28
28
|
initializationHash: Fr;
|
|
29
|
+
/** Hash of Immutables Values the contract is deployed with. */
|
|
30
|
+
immutablesHash: Fr;
|
|
29
31
|
/** Public keys associated with this instance. */
|
|
30
32
|
publicKeys: PublicKeys;
|
|
31
33
|
}
|
|
@@ -40,6 +42,7 @@ export const ContractInstanceSchema = zodFor<ContractInstance>()(
|
|
|
40
42
|
currentContractClassId: schemas.Fr,
|
|
41
43
|
originalContractClassId: schemas.Fr,
|
|
42
44
|
initializationHash: schemas.Fr,
|
|
45
|
+
immutablesHash: schemas.Fr,
|
|
43
46
|
publicKeys: PublicKeys.schema,
|
|
44
47
|
}),
|
|
45
48
|
);
|
|
@@ -54,12 +57,13 @@ export const ContractInstanceWithAddressSchema = zodFor<ContractInstanceWithAddr
|
|
|
54
57
|
*/
|
|
55
58
|
export function contractInstanceFromPlainObject(obj: any): ContractInstance {
|
|
56
59
|
return {
|
|
57
|
-
version:
|
|
60
|
+
version: 2,
|
|
58
61
|
salt: Fr.fromPlainObject(obj.salt),
|
|
59
62
|
deployer: AztecAddress.fromPlainObject(obj.deployer),
|
|
60
63
|
currentContractClassId: Fr.fromPlainObject(obj.currentContractClassId),
|
|
61
64
|
originalContractClassId: Fr.fromPlainObject(obj.originalContractClassId),
|
|
62
65
|
initializationHash: Fr.fromPlainObject(obj.initializationHash),
|
|
66
|
+
immutablesHash: Fr.fromPlainObject(obj.immutablesHash),
|
|
63
67
|
publicKeys: PublicKeys.fromPlainObject(obj.publicKeys),
|
|
64
68
|
};
|
|
65
69
|
}
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
import { KEY_VALIDATION_REQUEST_LENGTH } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { GrumpkinScalar
|
|
3
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
4
4
|
import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Request for validating keys used in the app.
|
|
8
|
+
*
|
|
9
|
+
* The master public key is exposed only as `pkMHash` (its `hashPublicKey` digest).
|
|
10
|
+
* The kernel reset circuit derives the corresponding point from the master secret key hint and
|
|
11
|
+
* asserts that its hash matches `pkMHash`.
|
|
8
12
|
*/
|
|
9
13
|
export class KeyValidationRequest {
|
|
10
|
-
/** App-siloed secret key corresponding to the same underlying secret as
|
|
14
|
+
/** App-siloed secret key corresponding to the same underlying secret as `pkMHash`. */
|
|
11
15
|
public readonly skApp: Fr;
|
|
12
16
|
|
|
13
17
|
constructor(
|
|
14
|
-
/**
|
|
15
|
-
public readonly
|
|
18
|
+
/** Hash of the master public key corresponding to the same underlying secret as `skApp`. */
|
|
19
|
+
public readonly pkMHash: Fr,
|
|
16
20
|
skApp: Fr | GrumpkinScalar,
|
|
17
21
|
) {
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// the skApp as GrumpkinScalar it was converted to that form from Fr. So, it is safe to convert it back
|
|
21
|
-
// to Fr. If this would change in the future the code below will throw an error so it should be easy to debug.
|
|
22
|
+
// skApp may arrive as a GrumpkinScalar (Fq) in some code paths; safe to truncate to Fr because
|
|
23
|
+
// the value originally came from an Fr poseidon hash and was widened to GrumpkinScalar.
|
|
22
24
|
this.skApp = skApp instanceof Fr ? skApp : new Fr(skApp.toBigInt());
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
toBuffer() {
|
|
26
|
-
return serializeToBuffer(this.
|
|
28
|
+
return serializeToBuffer(this.pkMHash, this.skApp);
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
get skAppAsGrumpkinScalar() {
|
|
@@ -32,11 +34,11 @@ export class KeyValidationRequest {
|
|
|
32
34
|
|
|
33
35
|
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
34
36
|
const reader = BufferReader.asReader(buffer);
|
|
35
|
-
return new KeyValidationRequest(
|
|
37
|
+
return new KeyValidationRequest(Fr.fromBuffer(reader), Fr.fromBuffer(reader));
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
toFields(): Fr[] {
|
|
39
|
-
const fields = [this.
|
|
41
|
+
const fields = [this.pkMHash, this.skApp];
|
|
40
42
|
if (fields.length !== KEY_VALIDATION_REQUEST_LENGTH) {
|
|
41
43
|
throw new Error(
|
|
42
44
|
`Invalid number of fields for KeyValidationRequest. Expected ${KEY_VALIDATION_REQUEST_LENGTH}, got ${fields.length}`,
|
|
@@ -47,18 +49,18 @@ export class KeyValidationRequest {
|
|
|
47
49
|
|
|
48
50
|
static fromFields(fields: Fr[] | FieldReader): KeyValidationRequest {
|
|
49
51
|
const reader = FieldReader.asReader(fields);
|
|
50
|
-
return new KeyValidationRequest(
|
|
52
|
+
return new KeyValidationRequest(reader.readField(), reader.readField());
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
isEmpty() {
|
|
54
|
-
return this.
|
|
56
|
+
return this.pkMHash.isZero() && this.skApp.isZero();
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
static empty() {
|
|
58
|
-
return new KeyValidationRequest(
|
|
60
|
+
return new KeyValidationRequest(Fr.ZERO, Fr.ZERO);
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
static
|
|
62
|
-
return new KeyValidationRequest(
|
|
63
|
+
static random() {
|
|
64
|
+
return new KeyValidationRequest(Fr.random(), Fr.random());
|
|
63
65
|
}
|
|
64
66
|
}
|
package/src/keys/derivation.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
|
7
7
|
|
|
8
8
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
9
9
|
import type { KeyPrefix } from './key_types.js';
|
|
10
|
+
import { PublicKey, hashPublicKey } from './public_key.js';
|
|
10
11
|
import { PublicKeys } from './public_keys.js';
|
|
11
12
|
import { getKeyGenerator } from './utils.js';
|
|
12
13
|
|
|
@@ -44,18 +45,18 @@ export function deriveSigningKey(secretKey: Fr): GrumpkinScalar {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
export function computePreaddress(publicKeysHash: Fr, partialAddress: Fr) {
|
|
47
|
-
return poseidon2HashWithSeparator([publicKeysHash, partialAddress], DomainSeparator.
|
|
48
|
+
return poseidon2HashWithSeparator([publicKeysHash, partialAddress], DomainSeparator.CONTRACT_ADDRESS_V2);
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
export async function computeAddress(publicKeys: PublicKeys, partialAddress: Fr): Promise<AztecAddress> {
|
|
51
52
|
// Given public keys and a partial address, we can compute our address in the following steps.
|
|
52
|
-
// 1. preaddress = poseidon2([publicKeysHash, partialAddress], DomainSeparator.
|
|
53
|
+
// 1. preaddress = poseidon2([publicKeysHash, partialAddress], DomainSeparator.CONTRACT_ADDRESS_V2);
|
|
53
54
|
// 2. addressPoint = (preaddress * G) + ivpk_m
|
|
54
55
|
// 3. address = addressPoint.x
|
|
55
56
|
const preaddress = await computePreaddress(await publicKeys.hash(), partialAddress);
|
|
56
57
|
const address = await Grumpkin.add(
|
|
57
58
|
await derivePublicKeyFromSecretKey(new Fq(preaddress.toBigInt())),
|
|
58
|
-
publicKeys.
|
|
59
|
+
publicKeys.ivpkM,
|
|
59
60
|
);
|
|
60
61
|
|
|
61
62
|
return new AztecAddress(address.x);
|
|
@@ -83,7 +84,7 @@ export async function computeAddressSecret(preaddress: Fr, ivsk: Fq) {
|
|
|
83
84
|
return addressSecretCandidate;
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
export function derivePublicKeyFromSecretKey(secretKey: Fq) {
|
|
87
|
+
export function derivePublicKeyFromSecretKey(secretKey: Fq): Promise<PublicKey> {
|
|
87
88
|
return Grumpkin.mul(Grumpkin.generator, secretKey);
|
|
88
89
|
}
|
|
89
90
|
|
|
@@ -106,12 +107,15 @@ export async function deriveKeys(secretKey: Fr) {
|
|
|
106
107
|
const masterOutgoingViewingPublicKey = await derivePublicKeyFromSecretKey(masterOutgoingViewingSecretKey);
|
|
107
108
|
const masterTaggingPublicKey = await derivePublicKeyFromSecretKey(masterTaggingSecretKey);
|
|
108
109
|
|
|
109
|
-
//
|
|
110
|
+
// The non-owner-visible PublicKeys carries hashes for npk/ovpk/tpk and the raw
|
|
111
|
+
// point only for ivpk_m. The npk/ovpk/tpk raw points are also returned alongside so the key
|
|
112
|
+
// store can persist them under `${account}-{n|ov|t}pk_m` (only their hashes live in publicKeys).
|
|
113
|
+
// The ivpk_m point isn't returned separately because it already lives in publicKeys.ivpkM.
|
|
110
114
|
const publicKeys = new PublicKeys(
|
|
111
|
-
masterNullifierPublicKey,
|
|
115
|
+
await hashPublicKey(masterNullifierPublicKey),
|
|
112
116
|
masterIncomingViewingPublicKey,
|
|
113
|
-
masterOutgoingViewingPublicKey,
|
|
114
|
-
masterTaggingPublicKey,
|
|
117
|
+
await hashPublicKey(masterOutgoingViewingPublicKey),
|
|
118
|
+
await hashPublicKey(masterTaggingPublicKey),
|
|
115
119
|
);
|
|
116
120
|
|
|
117
121
|
return {
|
|
@@ -119,6 +123,9 @@ export async function deriveKeys(secretKey: Fr) {
|
|
|
119
123
|
masterIncomingViewingSecretKey,
|
|
120
124
|
masterOutgoingViewingSecretKey,
|
|
121
125
|
masterTaggingSecretKey,
|
|
126
|
+
masterNullifierPublicKey,
|
|
127
|
+
masterOutgoingViewingPublicKey,
|
|
128
|
+
masterTaggingPublicKey,
|
|
122
129
|
publicKeys,
|
|
123
130
|
};
|
|
124
131
|
}
|
package/src/keys/public_key.ts
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DomainSeparator } from '@aztec/constants';
|
|
2
|
+
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
2
5
|
|
|
3
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Hashes a public key.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors Noir's `hash_public_key` in `noir-protocol-circuits/crates/types/src/public_keys.nr`:
|
|
10
|
+
* `Poseidon2(DOM_SEP__SINGLE_PUBLIC_KEY_HASH, [pk.x, pk.y])`.
|
|
11
|
+
*
|
|
12
|
+
* This is distinct from Noir's generic `Hash` impl for `EmbeddedCurvePoint` (`noir_stdlib/src/embedded_curve_ops.nr`),
|
|
13
|
+
* which simply absorbs `x` then `y` into a `Hasher` state with no domain separator. That generic impl is unsuitable
|
|
14
|
+
* for hashing keys at the protocol boundary, where the domain separator is required to prevent collisions with hashes
|
|
15
|
+
* of other Grumpkin points (e.g. note commitments, nullifiers).
|
|
16
|
+
*/
|
|
17
|
+
export function hashPublicKey(pk: PublicKey): Promise<Fr> {
|
|
18
|
+
return poseidon2HashWithSeparator([pk.x, pk.y], DomainSeparator.SINGLE_PUBLIC_KEY_HASH);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Represents a user public key.
|
|
23
|
+
*
|
|
24
|
+
* Structurally identical to a Grumpkin `Point`; exposed as a distinct name so call sites read as "public key" where
|
|
25
|
+
* that's the domain meaning.
|
|
26
|
+
*/
|
|
4
27
|
export type PublicKey = Point;
|
|
28
|
+
export const PublicKey = Point;
|