diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index a047ff3bce0e..b2146dd56d0f 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -146,6 +146,22 @@ library Constants { uint256 internal constant MULTI_CALL_ENTRYPOINT_ADDRESS = 4; uint256 internal constant FEE_JUICE_ADDRESS = 5; uint256 internal constant ROUTER_ADDRESS = 6; + uint256 internal constant DEFAULT_NPK_M_X = + 582240093077765400562621227108555700500271598878376310175765873770292988861; + uint256 internal constant DEFAULT_NPK_M_Y = + 10422444662424639723529825114205836958711284159673861467999592572974769103684; + uint256 internal constant DEFAULT_IVPK_M_X = + 339708709767762472786445938838804872781183545349360029270386718856175781484; + uint256 internal constant DEFAULT_IVPK_M_Y = + 12719619215050539905199178334954929730355853796706924300730604757520758976849; + uint256 internal constant DEFAULT_OVPK_M_X = + 12212787719617305570587928860288475454328008955283046946846066128763901043335; + uint256 internal constant DEFAULT_OVPK_M_Y = + 3646747884782549389807830220601404629716007431341772952958971658285958854707; + uint256 internal constant DEFAULT_TPK_M_X = + 728059161893070741164607238299536939695876538801885465230641192969135857403; + uint256 internal constant DEFAULT_TPK_M_Y = + 14575718736702206050102425029229426215631664471161015518982549597389390371695; uint256 internal constant AZTEC_ADDRESS_LENGTH = 1; uint256 internal constant GAS_FEES_LENGTH = 2; uint256 internal constant GAS_LENGTH = 2; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index 7a680ae96010..0049afc61564 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -238,6 +238,22 @@ global MULTI_CALL_ENTRYPOINT_ADDRESS = AztecAddress::from_field(4); global FEE_JUICE_ADDRESS = AztecAddress::from_field(5); global ROUTER_ADDRESS = AztecAddress::from_field(6); +// CANONICAL DEFAULT KEYS +// This below are: +// "az_null_npk" +// "az_null_ivpk" +// "az_null_ovpk" +// "az_null_tpk" +// as bytes, hashed to curve using grumpkin::g1::affine_element::hash_to_curve(, 0); +global DEFAULT_NPK_M_X = 0x01498945581e0eb9f8427ad6021184c700ef091d570892c437d12c7d90364bbd; +global DEFAULT_NPK_M_Y = 0x170ae506787c5c43d6ca9255d571c10fa9ffa9d141666e290c347c5c9ab7e344; +global DEFAULT_IVPK_M_X = 0x00c044b05b6ca83b9c2dbae79cc1135155956a64e136819136e9947fe5e5866c; +global DEFAULT_IVPK_M_Y = 0x1c1f0ca244c7cd46b682552bff8ae77dea40b966a71de076ec3b7678f2bdb151; +global DEFAULT_OVPK_M_X = 0x1b00316144359e9a3ec8e49c1cdb7eeb0cedd190dfd9dc90eea5115aa779e287; +global DEFAULT_OVPK_M_Y = 0x080ffc74d7a8b0bccb88ac11f45874172f3847eb8b92654aaa58a3d2b8dc7833; +global DEFAULT_TPK_M_X = 0x019c111f36ad3fc1d9b7a7a14344314d2864b94f030594cd67f753ef774a1efb; +global DEFAULT_TPK_M_Y = 0x2039907fe37f08d10739255141bb066c506a12f7d1e8dfec21abc58494705b6f; + // LENGTH OF STRUCTS SERIALIZED TO FIELDS global AZTEC_ADDRESS_LENGTH: u32 = 1; global GAS_FEES_LENGTH: u32 = 2; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/public_keys.nr b/noir-projects/noir-protocol-circuits/crates/types/src/public_keys.nr index c3097bc56b60..65bb1defab9b 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/public_keys.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/public_keys.nr @@ -1,10 +1,16 @@ use crate::{ - address::public_keys_hash::PublicKeysHash, constants::GENERATOR_INDEX__PUBLIC_KEYS_HASH, - hash::poseidon2_hash_with_separator, point::POINT_LENGTH, - traits::{Deserialize, Serialize, Empty, is_empty, Hash}, + address::public_keys_hash::PublicKeysHash, + constants::{ + GENERATOR_INDEX__PUBLIC_KEYS_HASH, DEFAULT_NPK_M_X, DEFAULT_NPK_M_Y, DEFAULT_IVPK_M_X, + DEFAULT_IVPK_M_Y, DEFAULT_OVPK_M_X, DEFAULT_OVPK_M_Y, DEFAULT_TPK_M_X, DEFAULT_TPK_M_Y, + }, hash::poseidon2_hash_with_separator, point::POINT_LENGTH, + traits::{Deserialize, Serialize, Hash}, }; use dep::std::embedded_curve_ops::EmbeddedCurvePoint as Point; +use dep::std::embedded_curve_ops::fixed_base_scalar_mul as derive_public_key; +use std::embedded_curve_ops::EmbeddedCurveScalar; +use std::default::Default; pub global PUBLIC_KEYS_LENGTH: u32 = 12; @@ -96,13 +102,21 @@ impl Serialize for TpkM { } } -impl Empty for PublicKeys { - fn empty() -> Self { +impl Default for PublicKeys { + fn default() -> Self { PublicKeys { - npk_m: NpkM { inner: Point::empty() }, - ivpk_m: IvpkM { inner: Point::empty() }, - ovpk_m: OvpkM { inner: Point::empty() }, - tpk_m: TpkM { inner: Point::empty() }, + npk_m: NpkM { + inner: Point { x: DEFAULT_NPK_M_X, y: DEFAULT_NPK_M_Y, is_infinite: false }, + }, + ivpk_m: IvpkM { + inner: Point { x: DEFAULT_IVPK_M_X, y: DEFAULT_IVPK_M_Y, is_infinite: false }, + }, + ovpk_m: OvpkM { + inner: Point { x: DEFAULT_OVPK_M_X, y: DEFAULT_OVPK_M_Y, is_infinite: false }, + }, + tpk_m: TpkM { + inner: Point { x: DEFAULT_TPK_M_X, y: DEFAULT_TPK_M_Y, is_infinite: false }, + }, } } } @@ -118,16 +132,10 @@ impl Eq for PublicKeys { impl PublicKeys { pub fn hash(self) -> PublicKeysHash { - PublicKeysHash::from_field( - if is_empty(self) { - 0 - } else { - poseidon2_hash_with_separator( - self.serialize(), - GENERATOR_INDEX__PUBLIC_KEYS_HASH as Field, - ) - }, - ) + PublicKeysHash::from_field(poseidon2_hash_with_separator( + self.serialize(), + GENERATOR_INDEX__PUBLIC_KEYS_HASH as Field, + )) } } @@ -202,13 +210,13 @@ unconstrained fn compute_public_keys_hash() { } #[test] -unconstrained fn compute_empty_hash() { - let keys = PublicKeys::empty(); +unconstrained fn compute_default_hash() { + let keys = PublicKeys::default(); let actual = keys.hash(); - let test_data_empty_hash = 0x0000000000000000000000000000000000000000000000000000000000000000; + let test_data_default_hash = 0x1d3bf1fb93ae0e9cda83b203dd91c3bfb492a9aecf30ec90e1057eced0f0e62d; - assert(actual.to_field() == test_data_empty_hash); + assert(actual.to_field() == test_data_default_hash); } #[test] diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr index f1cab7bfdca0..ad244b94ba52 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr @@ -1330,7 +1330,7 @@ impl Empty for FixtureBuilder { returns_hash: 0, function_leaf_membership_witness: MembershipWitness::empty(), salted_initialization_hash: SaltedInitializationHash::from_field(0), - public_keys: PublicKeys::empty(), + public_keys: PublicKeys::default(), contract_class_artifact_hash: 0, contract_class_public_bytecode_commitment: 0, acir_hash: 0, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr index 4bf18e15d194..c854adeec7fc 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr @@ -32,7 +32,7 @@ global default_contract = ContractData { contract_class_id: ContractClassId { inner: 0x28e91aaf764bc6083e2796ff884079ad895d4b948d6ce8f37f01b29d0bc95a21, }, - public_keys: PublicKeys::empty(), + public_keys: PublicKeys::default(), salted_initialization_hash: SaltedInitializationHash { inner: 0x13a939daa511233e5446905ed2cadbee14948fa75df183b53b5c14b612bffe88, }, @@ -56,7 +56,7 @@ global parent_contract = ContractData { contract_class_id: ContractClassId { inner: 0x00236b0dc6c537d5106543053c5b85c4cbe95b0474f8238b094bae63f1cbcfee, }, - public_keys: PublicKeys::empty(), + public_keys: PublicKeys::default(), salted_initialization_hash: SaltedInitializationHash { inner: 0x24bd6ac7a182e2cf25e437c72f53544ef81dfd97d9afee23abb07a638e7be749, }, @@ -70,7 +70,8 @@ pub fn get_protocol_contract(index: u32) -> ContractData { let artifact_hash = 576576 + seed; let salted_initialization_hash = SaltedInitializationHash { inner: 281972 + seed }; let public_bytecode_commitment = 38383 + seed; - let public_keys = PublicKeys::empty(); + // Empty public keys here will throw an error when doing ec ops + let public_keys = PublicKeys::default(); let function = get_protocol_contract_function(index); let private_functions_root = private_functions_root_from_siblings( diff --git a/yarn-project/aztec.js/src/contract/contract.ts b/yarn-project/aztec.js/src/contract/contract.ts index efa673794e86..708b220386ea 100644 --- a/yarn-project/aztec.js/src/contract/contract.ts +++ b/yarn-project/aztec.js/src/contract/contract.ts @@ -38,7 +38,7 @@ export class Contract extends ContractBase { */ public static deploy(wallet: Wallet, artifact: ContractArtifact, args: any[], constructorName?: string) { const postDeployCtor = (address: AztecAddress, wallet: Wallet) => Contract.at(address, artifact, wallet); - return new DeployMethod(PublicKeys.empty(), wallet, artifact, postDeployCtor, args, constructorName); + return new DeployMethod(PublicKeys.default(), wallet, artifact, postDeployCtor, args, constructorName); } /** diff --git a/yarn-project/aztec.js/src/deployment/contract_deployer.ts b/yarn-project/aztec.js/src/deployment/contract_deployer.ts index 86545368e8ef..f45dfd186e29 100644 --- a/yarn-project/aztec.js/src/deployment/contract_deployer.ts +++ b/yarn-project/aztec.js/src/deployment/contract_deployer.ts @@ -29,7 +29,7 @@ export class ContractDeployer { public deploy(...args: any[]) { const postDeployCtor = (address: AztecAddress, wallet: Wallet) => Contract.at(address, this.artifact, wallet); return new DeployMethod( - this.publicKeys ?? PublicKeys.empty(), + this.publicKeys ?? PublicKeys.default(), this.wallet, this.artifact, postDeployCtor, diff --git a/yarn-project/aztec/src/cli/cmds/start_pxe.ts b/yarn-project/aztec/src/cli/cmds/start_pxe.ts index fe9126f0319c..bffece2414ca 100644 --- a/yarn-project/aztec/src/cli/cmds/start_pxe.ts +++ b/yarn-project/aztec/src/cli/cmds/start_pxe.ts @@ -105,7 +105,7 @@ export async function addPXE( address, deployer: AztecAddress.ZERO, contractClassId: getContractClassFromArtifact(artifact!).id, - publicKeys: PublicKeys.empty(), + publicKeys: PublicKeys.default(), }; userLog(`Registering ${name} at ${address.toString()}`); await pxe.registerContract({ artifact, instance }); diff --git a/yarn-project/builder/src/contract-interface-gen/typescript.ts b/yarn-project/builder/src/contract-interface-gen/typescript.ts index 34c06fab2702..200337cb22b5 100644 --- a/yarn-project/builder/src/contract-interface-gen/typescript.ts +++ b/yarn-project/builder/src/contract-interface-gen/typescript.ts @@ -84,7 +84,7 @@ function generateDeploy(input: ContractArtifact) { * Creates a tx to deploy a new instance of this contract. */ public static deploy(wallet: Wallet, ${args}) { - return new DeployMethod<${contractName}>(PublicKeys.empty(), wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(1)); + return new DeployMethod<${contractName}>(PublicKeys.default(), wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(1)); } /** @@ -102,7 +102,7 @@ function generateDeploy(input: ContractArtifact) { ...args: Parameters<${contractName}['methods'][M]> ) { return new DeployMethod<${contractName}>( - opts.publicKeys ?? PublicKeys.empty(), + opts.publicKeys ?? PublicKeys.default(), opts.wallet, ${artifactName}, ${contractName}.at, diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index 73680d79e42b..de32b6c7b5c3 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -131,6 +131,14 @@ export const REGISTERER_CONTRACT_ADDRESS = 3; export const MULTI_CALL_ENTRYPOINT_ADDRESS = 4; export const FEE_JUICE_ADDRESS = 5; export const ROUTER_ADDRESS = 6; +export const DEFAULT_NPK_M_X = 582240093077765400562621227108555700500271598878376310175765873770292988861n; +export const DEFAULT_NPK_M_Y = 10422444662424639723529825114205836958711284159673861467999592572974769103684n; +export const DEFAULT_IVPK_M_X = 339708709767762472786445938838804872781183545349360029270386718856175781484n; +export const DEFAULT_IVPK_M_Y = 12719619215050539905199178334954929730355853796706924300730604757520758976849n; +export const DEFAULT_OVPK_M_X = 12212787719617305570587928860288475454328008955283046946846066128763901043335n; +export const DEFAULT_OVPK_M_Y = 3646747884782549389807830220601404629716007431341772952958971658285958854707n; +export const DEFAULT_TPK_M_X = 728059161893070741164607238299536939695876538801885465230641192969135857403n; +export const DEFAULT_TPK_M_Y = 14575718736702206050102425029229426215631664471161015518982549597389390371695n; export const AZTEC_ADDRESS_LENGTH = 1; export const GAS_FEES_LENGTH = 2; export const GAS_LENGTH = 2; diff --git a/yarn-project/circuits.js/src/contract/contract_instance.ts b/yarn-project/circuits.js/src/contract/contract_instance.ts index 49a5f413481a..9d60d1d7e4a6 100644 --- a/yarn-project/circuits.js/src/contract/contract_instance.ts +++ b/yarn-project/circuits.js/src/contract/contract_instance.ts @@ -80,14 +80,14 @@ export class SerializableContractInstance { }); } - static empty() { + static default() { return new SerializableContractInstance({ version: VERSION, salt: Fr.zero(), deployer: AztecAddress.zero(), contractClassId: Fr.zero(), initializationHash: Fr.zero(), - publicKeys: PublicKeys.empty(), + publicKeys: PublicKeys.default(), }); } } @@ -122,7 +122,7 @@ export function getContractInstanceFromDeployParams( args, ) : computeInitializationHash(constructorArtifact, args); - const publicKeys = opts.publicKeys ?? PublicKeys.empty(); + const publicKeys = opts.publicKeys ?? PublicKeys.default(); const instance: ContractInstance = { contractClassId, diff --git a/yarn-project/circuits.js/src/types/public_keys.test.ts b/yarn-project/circuits.js/src/types/public_keys.test.ts index 51902c7cc1ec..10dac1f65f70 100644 --- a/yarn-project/circuits.js/src/types/public_keys.test.ts +++ b/yarn-project/circuits.js/src/types/public_keys.test.ts @@ -16,16 +16,24 @@ describe('PublicKeys', () => { expect(hash).toMatchInlineSnapshot(`"0x0fecd9a32db731fec1fded1b9ff957a1625c069245a3613a2538bd527068b0ad"`); // Run with AZTEC_GENERATE_TEST_DATA=1 to update noir test data - updateInlineTestData('noir-projects/aztec-nr/aztec/src/keys/public_keys.nr', 'expected_public_keys_hash', hash); + updateInlineTestData( + 'noir-projects/noir-protocol-circuits/crates/types/src/public_keys.nr', + 'expected_public_keys_hash', + hash, + ); }); - it('computes empty keys hash', () => { - const keys = PublicKeys.empty(); + it('computes default keys hash', () => { + const keys = PublicKeys.default(); const hash = keys.hash().toString(); - expect(hash).toMatchInlineSnapshot(`"0x0000000000000000000000000000000000000000000000000000000000000000"`); + expect(hash).toMatchInlineSnapshot(`"0x1d3bf1fb93ae0e9cda83b203dd91c3bfb492a9aecf30ec90e1057eced0f0e62d"`); // Run with AZTEC_GENERATE_TEST_DATA=1 to update noir test data - updateInlineTestData('noir-projects/aztec-nr/aztec/src/keys/public_keys.nr', 'test_data_empty_hash', hash); + updateInlineTestData( + 'noir-projects/noir-protocol-circuits/crates/types/src/public_keys.nr', + 'test_data_default_hash', + hash, + ); }); }); diff --git a/yarn-project/circuits.js/src/types/public_keys.ts b/yarn-project/circuits.js/src/types/public_keys.ts index 57bb3400d50e..3dd38c807c07 100644 --- a/yarn-project/circuits.js/src/types/public_keys.ts +++ b/yarn-project/circuits.js/src/types/public_keys.ts @@ -2,7 +2,17 @@ import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr, Point } from '@aztec/foundation/fields'; import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize'; -import { GeneratorIndex } from '../constants.gen.js'; +import { + DEFAULT_IVPK_M_X, + DEFAULT_IVPK_M_Y, + DEFAULT_NPK_M_X, + DEFAULT_NPK_M_Y, + DEFAULT_OVPK_M_X, + DEFAULT_OVPK_M_Y, + DEFAULT_TPK_M_X, + DEFAULT_TPK_M_Y, + GeneratorIndex, +} from '../constants.gen.js'; import { type PublicKey } from './public_key.js'; export class PublicKeys { @@ -41,8 +51,13 @@ export class PublicKeys { ); } - static empty(): PublicKeys { - return new PublicKeys(Point.ZERO, Point.ZERO, Point.ZERO, Point.ZERO); + static default(): PublicKeys { + return new PublicKeys( + new Point(new Fr(DEFAULT_NPK_M_X), new Fr(DEFAULT_NPK_M_Y), false), + new Point(new Fr(DEFAULT_IVPK_M_X), new Fr(DEFAULT_IVPK_M_Y), false), + new Point(new Fr(DEFAULT_OVPK_M_X), new Fr(DEFAULT_OVPK_M_Y), false), + new Point(new Fr(DEFAULT_TPK_M_X), new Fr(DEFAULT_TPK_M_Y), false), + ); } static random(): PublicKeys { diff --git a/yarn-project/cli-wallet/src/cmds/deploy.ts b/yarn-project/cli-wallet/src/cmds/deploy.ts index 71d131d444be..d105e8e50634 100644 --- a/yarn-project/cli-wallet/src/cmds/deploy.ts +++ b/yarn-project/cli-wallet/src/cmds/deploy.ts @@ -37,7 +37,7 @@ export async function deploy( ); } - const deployer = new ContractDeployer(contractArtifact, wallet, publicKeys ?? PublicKeys.empty(), initializer); + const deployer = new ContractDeployer(contractArtifact, wallet, publicKeys ?? PublicKeys.default(), initializer); let args = []; if (rawArgs.length > 0) { diff --git a/yarn-project/cli/src/cmds/pxe/add_contract.ts b/yarn-project/cli/src/cmds/pxe/add_contract.ts index 5298eeeb1822..3904930d04cc 100644 --- a/yarn-project/cli/src/cmds/pxe/add_contract.ts +++ b/yarn-project/cli/src/cmds/pxe/add_contract.ts @@ -23,7 +23,7 @@ export async function addContract( salt, initializationHash, contractClassId: getContractClassFromArtifact(artifact).id, - publicKeys: publicKeys ?? PublicKeys.empty(), + publicKeys: publicKeys ?? PublicKeys.default(), address, deployer: deployer ?? AztecAddress.ZERO, }; diff --git a/yarn-project/noir-protocol-circuits-types/src/__snapshots__/noir_test_gen.test.ts.snap b/yarn-project/noir-protocol-circuits-types/src/__snapshots__/noir_test_gen.test.ts.snap index 4c362396bb23..6ba80a51baaf 100644 --- a/yarn-project/noir-protocol-circuits-types/src/__snapshots__/noir_test_gen.test.ts.snap +++ b/yarn-project/noir-protocol-circuits-types/src/__snapshots__/noir_test_gen.test.ts.snap @@ -6,10 +6,10 @@ exports[`Data generation for noir tests Computes contract info for defaultContra artifact_hash: 0x0000000000000000000000000000000000000000000000000000000000003039, public_bytecode_commitment: 0x0000000000000000000000000000000000000000000000000000000000000005, private_functions_root: 0x25d76df45434ec75a83321daf941cfc667ff3a9027942e17105da4f50d1d13f9, - address: AztecAddress { inner: 0x1119ce64278d82d5178d977b0921630b2834045c8dc4bec257813bcbafdddb57 }, + address: AztecAddress { inner: 0x26a0c3dba9cc7290ebf910fe8a8ea00b99b51817ae686fdd7c35392860133410 }, partial_address: PartialAddress { inner: 0x0cf203c94c91bed28440b00ecd888d88cce1f86ddf2aa8d33acbb9b6fc06d382 }, contract_class_id: ContractClassId { inner: 0x28e91aaf764bc6083e2796ff884079ad895d4b948d6ce8f37f01b29d0bc95a21 }, - public_keys: PublicKeys { inner: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 }, + public_keys: PublicKeys { inner: 01498945581e0eb9f8427ad6021184c700ef091d570892c437d12c7d90364bbd170ae506787c5c43d6ca9255d571c10fa9ffa9d141666e290c347c5c9ab7e34400c044b05b6ca83b9c2dbae79cc1135155956a64e136819136e9947fe5e5866c1c1f0ca244c7cd46b682552bff8ae77dea40b966a71de076ec3b7678f2bdb1511b00316144359e9a3ec8e49c1cdb7eeb0cedd190dfd9dc90eea5115aa779e287080ffc74d7a8b0bccb88ac11f45874172f3847eb8b92654aaa58a3d2b8dc7833019c111f36ad3fc1d9b7a7a14344314d2864b94f030594cd67f753ef774a1efb2039907fe37f08d10739255141bb066c506a12f7d1e8dfec21abc58494705b6f }, salted_initialization_hash: SaltedInitializationHash { inner: 0x13a939daa511233e5446905ed2cadbee14948fa75df183b53b5c14b612bffe88 }, deployer: AztecAddress { inner: 0x0000000000000000000000000000000000000000000000000000000000000000 } }" @@ -21,10 +21,10 @@ exports[`Data generation for noir tests Computes contract info for parentContrac artifact_hash: 0x00000000000000000000000000000000000000000000000000000000000004bc, public_bytecode_commitment: 0x0000000000000000000000000000000000000000000000000000000000000005, private_functions_root: 0x1228b39ba6702af03e595300e8484c6373f00790d0148cc3d4ff0fd1c778a83a, - address: AztecAddress { inner: 0x218802a34637b05632108fedc42176dfce00e4daa8aa9aeadbf09f8c7069267a }, + address: AztecAddress { inner: 0x00d81b0b87d6776f68155d9f2b92469fdcb461c1366b9635ab0030bbf6ec86cf }, partial_address: PartialAddress { inner: 0x245df9f519d616473880260dd64b19a838081bb44dc17cd6ea5d870a63d2bf57 }, contract_class_id: ContractClassId { inner: 0x00236b0dc6c537d5106543053c5b85c4cbe95b0474f8238b094bae63f1cbcfee }, - public_keys: PublicKeys { inner: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 }, + public_keys: PublicKeys { inner: 01498945581e0eb9f8427ad6021184c700ef091d570892c437d12c7d90364bbd170ae506787c5c43d6ca9255d571c10fa9ffa9d141666e290c347c5c9ab7e34400c044b05b6ca83b9c2dbae79cc1135155956a64e136819136e9947fe5e5866c1c1f0ca244c7cd46b682552bff8ae77dea40b966a71de076ec3b7678f2bdb1511b00316144359e9a3ec8e49c1cdb7eeb0cedd190dfd9dc90eea5115aa779e287080ffc74d7a8b0bccb88ac11f45874172f3847eb8b92654aaa58a3d2b8dc7833019c111f36ad3fc1d9b7a7a14344314d2864b94f030594cd67f753ef774a1efb2039907fe37f08d10739255141bb066c506a12f7d1e8dfec21abc58494705b6f }, salted_initialization_hash: SaltedInitializationHash { inner: 0x24bd6ac7a182e2cf25e437c72f53544ef81dfd97d9afee23abb07a638e7be749 }, deployer: AztecAddress { inner: 0x0000000000000000000000000000000000000000000000000000000000000000 } }" diff --git a/yarn-project/noir-protocol-circuits-types/src/noir_test_gen.test.ts b/yarn-project/noir-protocol-circuits-types/src/noir_test_gen.test.ts index e5233391bbc3..dd191ced7448 100644 --- a/yarn-project/noir-protocol-circuits-types/src/noir_test_gen.test.ts +++ b/yarn-project/noir-protocol-circuits-types/src/noir_test_gen.test.ts @@ -25,7 +25,7 @@ describe('Data generation for noir tests', () => { const defaultContract: FixtureContractData = { artifactHash: new Fr(12345), packedBytecode: Buffer.from([3, 4, 5, 6, 7]), - publicKeys: PublicKeys.empty(), + publicKeys: PublicKeys.default(), salt: new Fr(56789), privateFunctions: [ { selector: FunctionSelector.fromField(new Fr(1010101)), vkHash: new Fr(0) }, @@ -37,7 +37,7 @@ describe('Data generation for noir tests', () => { const parentContract: FixtureContractData = { artifactHash: new Fr(1212), packedBytecode: Buffer.from([3, 4, 3, 4]), - publicKeys: PublicKeys.empty(), + publicKeys: PublicKeys.default(), salt: new Fr(5656), privateFunctions: [{ selector: FunctionSelector.fromField(new Fr(334455)), vkHash: new Fr(0) }], toString: () => 'parentContract', diff --git a/yarn-project/protocol-contracts/src/protocol_contract_data.ts b/yarn-project/protocol-contracts/src/protocol_contract_data.ts index 7cc5bfad5409..f05089798eb8 100644 --- a/yarn-project/protocol-contracts/src/protocol_contract_data.ts +++ b/yarn-project/protocol-contracts/src/protocol_contract_data.ts @@ -50,14 +50,14 @@ export const ProtocolContractAddress: Record }; export const ProtocolContractLeaf = { - AuthRegistry: Fr.fromString('0x2ace300b02ca5ab0a25052b1e852913a47292096997ca09f758c0e3624e84560'), - ContractInstanceDeployer: Fr.fromString('0x21e432f60f69ac5eb7582c26c03c6c7e4a3eb577720774bc8e1521561ca752a1'), - ContractClassRegisterer: Fr.fromString('0x1b6d5873cef5a35f681ab9468527f356c96e09b3c64603aef404ec2ad80aa3a9'), - MultiCallEntrypoint: Fr.fromString('0x0966ead8d11933bb3c72547bb997898971715f2275acd4c7d5d86fdf614ba1a2'), - FeeJuice: Fr.fromString('0x24388f7ef1b9c9e661721f3331a989a2f10cba300539471e4401c38629b27816'), - Router: Fr.fromString('0x1d8f25db3e8faa6a96cb1ecf57876a2ee04581deb3c4f181488ccd817abcbdb0'), + AuthRegistry: Fr.fromString('0x0d7c69bbd50f9da911b5ab26e313dafc7f66b0e03a52d6d98270c54ed751c4e2'), + ContractInstanceDeployer: Fr.fromString('0x0f91b27c8187748d9710cc579b3fc08b56e5a391b9f7818b71feadd39816bc6d'), + ContractClassRegisterer: Fr.fromString('0x17f57693577de778fa6f4d83c280597ac659acfbce64175aacc390d289f97953'), + MultiCallEntrypoint: Fr.fromString('0x054b0c9a77a2fcaf1c3a1519205a21d4627cb950245a462d6a9bfc52892d6b7a'), + FeeJuice: Fr.fromString('0x03c51587dc12449bd85f33627111224910a934b3c79fcf720fd1c6ccac0f34e1'), + Router: Fr.fromString('0x250937e9172b417f70fb2d0bdefdf69268e1134f1612418cf58fb80ff4278fe9'), }; export const protocolContractTreeRoot = Fr.fromString( - '0x0ce9f44ae6605f375e5f5267ceb769861703ce8e4235f16f7afc137ec34dcf06', + '0x1010ec5ed35322c9adf0ef6573d9f4bdb43bb971ddfe8dfa7776c5d4254eb2ab', ); diff --git a/yarn-project/pxe/src/kernel_prover/kernel_prover.test.ts b/yarn-project/pxe/src/kernel_prover/kernel_prover.test.ts index c34fa969661d..25978d48da2a 100644 --- a/yarn-project/pxe/src/kernel_prover/kernel_prover.test.ts +++ b/yarn-project/pxe/src/kernel_prover/kernel_prover.test.ts @@ -145,7 +145,7 @@ describe('Kernel Prover', () => { oracle.getContractAddressPreimage.mockResolvedValue({ contractClassId: Fr.random(), - publicKeys: PublicKeys.empty(), + publicKeys: PublicKeys.random(), saltedInitializationHash: Fr.random(), }); oracle.getContractClassIdPreimage.mockResolvedValue({ diff --git a/yarn-project/simulator/src/avm/journal/journal.test.ts b/yarn-project/simulator/src/avm/journal/journal.test.ts index e0306adb81f7..e3feaf9ee536 100644 --- a/yarn-project/simulator/src/avm/journal/journal.test.ts +++ b/yarn-project/simulator/src/avm/journal/journal.test.ts @@ -154,11 +154,11 @@ describe('journal', () => { expect(trace.traceGetContractInstance).toHaveBeenCalledWith({ exists: true, ...contractInstance }); }); it('Can get undefined contract instance', async () => { - const emptyContractInstance = SerializableContractInstance.empty().withAddress(address); + const defaultContractInstance = SerializableContractInstance.default().withAddress(address); await persistableState.getContractInstance(address); expect(trace.traceGetContractInstance).toHaveBeenCalledTimes(1); - expect(trace.traceGetContractInstance).toHaveBeenCalledWith({ exists: false, ...emptyContractInstance }); + expect(trace.traceGetContractInstance).toHaveBeenCalledWith({ exists: false, ...defaultContractInstance }); }); }); diff --git a/yarn-project/simulator/src/avm/journal/journal.ts b/yarn-project/simulator/src/avm/journal/journal.ts index c6d2157f5014..3f6f115f5a0d 100644 --- a/yarn-project/simulator/src/avm/journal/journal.ts +++ b/yarn-project/simulator/src/avm/journal/journal.ts @@ -217,7 +217,7 @@ export class AvmPersistableStateManager { const aztecAddress = AztecAddress.fromField(contractAddress); let instance = await this.worldStateDB.getContractInstance(aztecAddress); if (instance === undefined) { - instance = SerializableContractInstance.empty().withAddress(aztecAddress); + instance = SerializableContractInstance.default().withAddress(aztecAddress); exists = false; } this.log.debug( diff --git a/yarn-project/simulator/src/avm/opcodes/contract.test.ts b/yarn-project/simulator/src/avm/opcodes/contract.test.ts index b5d256960068..1ba6ff2c2c15 100644 --- a/yarn-project/simulator/src/avm/opcodes/contract.test.ts +++ b/yarn-project/simulator/src/avm/opcodes/contract.test.ts @@ -1,5 +1,5 @@ import { randomContractInstanceWithAddress } from '@aztec/circuit-types'; -import { AztecAddress, SerializableContractInstance } from '@aztec/circuits.js'; +import { AztecAddress, PublicKeys, SerializableContractInstance } from '@aztec/circuits.js'; import { mock } from 'jest-mock-extended'; @@ -68,23 +68,25 @@ describe('Contract opcodes', () => { }); it('should return zeroes if not found', async () => { - const emptyContractInstance = SerializableContractInstance.empty().withAddress(address); + const defaultContractInstance = SerializableContractInstance.default().withAddress(address); context.machineState.memory.set(0, new Field(address.toField())); await new GetContractInstance(/*indirect=*/ 0, /*addressOffset=*/ 0, /*dstOffset=*/ 1).execute(context); - const actual = context.machineState.memory.getSlice(1, 6); + const actual = context.machineState.memory.getSlice(1, 17); expect(actual).toEqual([ new Field(0), // found new Field(0), new Field(0), new Field(0), new Field(0), - new Field(0), + ...PublicKeys.default() + .toFields() + .map(f => new Field(f)), ]); expect(trace.traceGetContractInstance).toHaveBeenCalledTimes(1); - expect(trace.traceGetContractInstance).toHaveBeenCalledWith({ exists: false, ...emptyContractInstance }); + expect(trace.traceGetContractInstance).toHaveBeenCalledWith({ exists: false, ...defaultContractInstance }); }); }); }); diff --git a/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.test.ts b/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.test.ts index 877543e77c87..38201e377dca 100644 --- a/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.test.ts +++ b/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.test.ts @@ -52,7 +52,7 @@ describe('Enqueued-call Side Effect Trace', () => { const recipient = Fr.random(); const content = Fr.random(); const log = [Fr.random(), Fr.random(), Fr.random()]; - const contractInstance = SerializableContractInstance.empty().withAddress(new Fr(42)); + const contractInstance = SerializableContractInstance.default().withAddress(new Fr(42)); const startGasLeft = Gas.fromFields([new Fr(randomInt(10000)), new Fr(randomInt(10000))]); const endGasLeft = Gas.fromFields([new Fr(randomInt(10000)), new Fr(randomInt(10000))]); diff --git a/yarn-project/simulator/src/public/side_effect_trace.test.ts b/yarn-project/simulator/src/public/side_effect_trace.test.ts index 87cb70f0c028..096f64d9f225 100644 --- a/yarn-project/simulator/src/public/side_effect_trace.test.ts +++ b/yarn-project/simulator/src/public/side_effect_trace.test.ts @@ -40,7 +40,7 @@ describe('Side Effect Trace', () => { const recipient = Fr.random(); const content = Fr.random(); const log = [Fr.random(), Fr.random(), Fr.random()]; - const contractInstance = SerializableContractInstance.empty().withAddress(new Fr(42)); + const contractInstance = SerializableContractInstance.default().withAddress(new Fr(42)); const startGasLeft = Gas.fromFields([new Fr(randomInt(10000)), new Fr(randomInt(10000))]); const endGasLeft = Gas.fromFields([new Fr(randomInt(10000)), new Fr(randomInt(10000))]); diff --git a/yarn-project/txe/src/txe_service/txe_service.ts b/yarn-project/txe/src/txe_service/txe_service.ts index d0761d707ef1..13cc7637562c 100644 --- a/yarn-project/txe/src/txe_service/txe_service.ts +++ b/yarn-project/txe/src/txe_service/txe_service.ts @@ -118,7 +118,7 @@ export class TXEService { skipArgsDecoding: true, salt: Fr.ONE, // TODO: Modify this to allow for passing public keys. - publicKeys: PublicKeys.empty(), + publicKeys: PublicKeys.default(), constructorArtifact: initializerStr ? initializerStr : undefined, deployer: AztecAddress.ZERO, });