Skip to content

Commit cb77939

Browse files
author
sklppy88
committed
init
1 parent 66f31c7 commit cb77939

25 files changed

Lines changed: 144 additions & 70 deletions

File tree

l1-contracts/src/core/libraries/ConstantsGen.sol

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,22 @@ library Constants {
146146
uint256 internal constant MULTI_CALL_ENTRYPOINT_ADDRESS = 4;
147147
uint256 internal constant FEE_JUICE_ADDRESS = 5;
148148
uint256 internal constant ROUTER_ADDRESS = 6;
149+
uint256 internal constant DEFAULT_NPK_M_X =
150+
582240093077765400562621227108555700500271598878376310175765873770292988861;
151+
uint256 internal constant DEFAULT_NPK_M_Y =
152+
10422444662424639723529825114205836958711284159673861467999592572974769103684;
153+
uint256 internal constant DEFAULT_IVPK_M_X =
154+
339708709767762472786445938838804872781183545349360029270386718856175781484;
155+
uint256 internal constant DEFAULT_IVPK_M_Y =
156+
12719619215050539905199178334954929730355853796706924300730604757520758976849;
157+
uint256 internal constant DEFAULT_OVPK_M_X =
158+
12212787719617305570587928860288475454328008955283046946846066128763901043335;
159+
uint256 internal constant DEFAULT_OVPK_M_Y =
160+
3646747884782549389807830220601404629716007431341772952958971658285958854707;
161+
uint256 internal constant DEFAULT_TPK_M_X =
162+
728059161893070741164607238299536939695876538801885465230641192969135857403;
163+
uint256 internal constant DEFAULT_TPK_M_Y =
164+
14575718736702206050102425029229426215631664471161015518982549597389390371695;
149165
uint256 internal constant AZTEC_ADDRESS_LENGTH = 1;
150166
uint256 internal constant GAS_FEES_LENGTH = 2;
151167
uint256 internal constant GAS_LENGTH = 2;

noir-projects/noir-protocol-circuits/crates/types/src/constants.nr

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,22 @@ global MULTI_CALL_ENTRYPOINT_ADDRESS = AztecAddress::from_field(4);
238238
global FEE_JUICE_ADDRESS = AztecAddress::from_field(5);
239239
global ROUTER_ADDRESS = AztecAddress::from_field(6);
240240

241+
// CANONICAL DEFAULT KEYS
242+
// This below are:
243+
// "az_null_npk"
244+
// "az_null_ivpk"
245+
// "az_null_ovpk"
246+
// "az_null_tpk"
247+
// as bytes, hashed to curve using grumpkin::g1::affine_element::hash_to_curve(<X>, 0);
248+
global DEFAULT_NPK_M_X = 0x01498945581e0eb9f8427ad6021184c700ef091d570892c437d12c7d90364bbd;
249+
global DEFAULT_NPK_M_Y = 0x170ae506787c5c43d6ca9255d571c10fa9ffa9d141666e290c347c5c9ab7e344;
250+
global DEFAULT_IVPK_M_X = 0x00c044b05b6ca83b9c2dbae79cc1135155956a64e136819136e9947fe5e5866c;
251+
global DEFAULT_IVPK_M_Y = 0x1c1f0ca244c7cd46b682552bff8ae77dea40b966a71de076ec3b7678f2bdb151;
252+
global DEFAULT_OVPK_M_X = 0x1b00316144359e9a3ec8e49c1cdb7eeb0cedd190dfd9dc90eea5115aa779e287;
253+
global DEFAULT_OVPK_M_Y = 0x080ffc74d7a8b0bccb88ac11f45874172f3847eb8b92654aaa58a3d2b8dc7833;
254+
global DEFAULT_TPK_M_X = 0x019c111f36ad3fc1d9b7a7a14344314d2864b94f030594cd67f753ef774a1efb;
255+
global DEFAULT_TPK_M_Y = 0x2039907fe37f08d10739255141bb066c506a12f7d1e8dfec21abc58494705b6f;
256+
241257
// LENGTH OF STRUCTS SERIALIZED TO FIELDS
242258
global AZTEC_ADDRESS_LENGTH: u32 = 1;
243259
global GAS_FEES_LENGTH: u32 = 2;

noir-projects/noir-protocol-circuits/crates/types/src/public_keys.nr

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
use crate::{
2-
address::public_keys_hash::PublicKeysHash, constants::GENERATOR_INDEX__PUBLIC_KEYS_HASH,
3-
hash::poseidon2_hash_with_separator, point::POINT_LENGTH,
4-
traits::{Deserialize, Serialize, Empty, is_empty, Hash},
2+
address::public_keys_hash::PublicKeysHash,
3+
constants::{
4+
GENERATOR_INDEX__PUBLIC_KEYS_HASH, DEFAULT_NPK_M_X, DEFAULT_NPK_M_Y, DEFAULT_IVPK_M_X,
5+
DEFAULT_IVPK_M_Y, DEFAULT_OVPK_M_X, DEFAULT_OVPK_M_Y, DEFAULT_TPK_M_X, DEFAULT_TPK_M_Y,
6+
}, hash::poseidon2_hash_with_separator, point::POINT_LENGTH,
7+
traits::{Deserialize, Serialize, Hash},
58
};
69

710
use dep::std::embedded_curve_ops::EmbeddedCurvePoint as Point;
11+
use dep::std::embedded_curve_ops::fixed_base_scalar_mul as derive_public_key;
12+
use std::embedded_curve_ops::EmbeddedCurveScalar;
13+
use std::default::Default;
814

915
pub global PUBLIC_KEYS_LENGTH: u32 = 12;
1016

@@ -96,13 +102,21 @@ impl Serialize<POINT_LENGTH> for TpkM {
96102
}
97103
}
98104

99-
impl Empty for PublicKeys {
100-
fn empty() -> Self {
105+
impl Default for PublicKeys {
106+
fn default() -> Self {
101107
PublicKeys {
102-
npk_m: NpkM { inner: Point::empty() },
103-
ivpk_m: IvpkM { inner: Point::empty() },
104-
ovpk_m: OvpkM { inner: Point::empty() },
105-
tpk_m: TpkM { inner: Point::empty() },
108+
npk_m: NpkM {
109+
inner: Point { x: DEFAULT_NPK_M_X, y: DEFAULT_NPK_M_Y, is_infinite: false },
110+
},
111+
ivpk_m: IvpkM {
112+
inner: Point { x: DEFAULT_IVPK_M_X, y: DEFAULT_IVPK_M_Y, is_infinite: false },
113+
},
114+
ovpk_m: OvpkM {
115+
inner: Point { x: DEFAULT_OVPK_M_X, y: DEFAULT_OVPK_M_Y, is_infinite: false },
116+
},
117+
tpk_m: TpkM {
118+
inner: Point { x: DEFAULT_TPK_M_X, y: DEFAULT_TPK_M_Y, is_infinite: false },
119+
},
106120
}
107121
}
108122
}
@@ -118,16 +132,10 @@ impl Eq for PublicKeys {
118132

119133
impl PublicKeys {
120134
pub fn hash(self) -> PublicKeysHash {
121-
PublicKeysHash::from_field(
122-
if is_empty(self) {
123-
0
124-
} else {
125-
poseidon2_hash_with_separator(
126-
self.serialize(),
127-
GENERATOR_INDEX__PUBLIC_KEYS_HASH as Field,
128-
)
129-
},
130-
)
135+
PublicKeysHash::from_field(poseidon2_hash_with_separator(
136+
self.serialize(),
137+
GENERATOR_INDEX__PUBLIC_KEYS_HASH as Field,
138+
))
131139
}
132140
}
133141

@@ -202,13 +210,13 @@ unconstrained fn compute_public_keys_hash() {
202210
}
203211

204212
#[test]
205-
unconstrained fn compute_empty_hash() {
206-
let keys = PublicKeys::empty();
213+
unconstrained fn compute_default_hash() {
214+
let keys = PublicKeys::default();
207215

208216
let actual = keys.hash();
209-
let test_data_empty_hash = 0x0000000000000000000000000000000000000000000000000000000000000000;
217+
let test_data_default_hash = 0x1d3bf1fb93ae0e9cda83b203dd91c3bfb492a9aecf30ec90e1057eced0f0e62d;
210218

211-
assert(actual.to_field() == test_data_empty_hash);
219+
assert(actual.to_field() == test_data_default_hash);
212220
}
213221

214222
#[test]

noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ impl Empty for FixtureBuilder {
13301330
returns_hash: 0,
13311331
function_leaf_membership_witness: MembershipWitness::empty(),
13321332
salted_initialization_hash: SaltedInitializationHash::from_field(0),
1333-
public_keys: PublicKeys::empty(),
1333+
public_keys: PublicKeys::default(),
13341334
contract_class_artifact_hash: 0,
13351335
contract_class_public_bytecode_commitment: 0,
13361336
acir_hash: 0,

noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ global default_contract = ContractData {
3232
contract_class_id: ContractClassId {
3333
inner: 0x28e91aaf764bc6083e2796ff884079ad895d4b948d6ce8f37f01b29d0bc95a21,
3434
},
35-
public_keys: PublicKeys::empty(),
35+
public_keys: PublicKeys::default(),
3636
salted_initialization_hash: SaltedInitializationHash {
3737
inner: 0x13a939daa511233e5446905ed2cadbee14948fa75df183b53b5c14b612bffe88,
3838
},
@@ -56,7 +56,7 @@ global parent_contract = ContractData {
5656
contract_class_id: ContractClassId {
5757
inner: 0x00236b0dc6c537d5106543053c5b85c4cbe95b0474f8238b094bae63f1cbcfee,
5858
},
59-
public_keys: PublicKeys::empty(),
59+
public_keys: PublicKeys::default(),
6060
salted_initialization_hash: SaltedInitializationHash {
6161
inner: 0x24bd6ac7a182e2cf25e437c72f53544ef81dfd97d9afee23abb07a638e7be749,
6262
},
@@ -70,7 +70,8 @@ pub fn get_protocol_contract(index: u32) -> ContractData {
7070
let artifact_hash = 576576 + seed;
7171
let salted_initialization_hash = SaltedInitializationHash { inner: 281972 + seed };
7272
let public_bytecode_commitment = 38383 + seed;
73-
let public_keys = PublicKeys::empty();
73+
// Empty public keys here will throw an error when doing ec ops
74+
let public_keys = PublicKeys::default();
7475

7576
let function = get_protocol_contract_function(index);
7677
let private_functions_root = private_functions_root_from_siblings(

yarn-project/aztec.js/src/contract/contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class Contract extends ContractBase {
3838
*/
3939
public static deploy(wallet: Wallet, artifact: ContractArtifact, args: any[], constructorName?: string) {
4040
const postDeployCtor = (address: AztecAddress, wallet: Wallet) => Contract.at(address, artifact, wallet);
41-
return new DeployMethod(PublicKeys.empty(), wallet, artifact, postDeployCtor, args, constructorName);
41+
return new DeployMethod(PublicKeys.default(), wallet, artifact, postDeployCtor, args, constructorName);
4242
}
4343

4444
/**

yarn-project/aztec.js/src/deployment/contract_deployer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class ContractDeployer {
2929
public deploy(...args: any[]) {
3030
const postDeployCtor = (address: AztecAddress, wallet: Wallet) => Contract.at(address, this.artifact, wallet);
3131
return new DeployMethod(
32-
this.publicKeys ?? PublicKeys.empty(),
32+
this.publicKeys ?? PublicKeys.default(),
3333
this.wallet,
3434
this.artifact,
3535
postDeployCtor,

yarn-project/aztec/src/cli/cmds/start_pxe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export async function addPXE(
105105
address,
106106
deployer: AztecAddress.ZERO,
107107
contractClassId: getContractClassFromArtifact(artifact!).id,
108-
publicKeys: PublicKeys.empty(),
108+
publicKeys: PublicKeys.default(),
109109
};
110110
userLog(`Registering ${name} at ${address.toString()}`);
111111
await pxe.registerContract({ artifact, instance });

yarn-project/builder/src/contract-interface-gen/typescript.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function generateDeploy(input: ContractArtifact) {
8484
* Creates a tx to deploy a new instance of this contract.
8585
*/
8686
public static deploy(wallet: Wallet, ${args}) {
87-
return new DeployMethod<${contractName}>(PublicKeys.empty(), wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(1));
87+
return new DeployMethod<${contractName}>(PublicKeys.default(), wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(1));
8888
}
8989
9090
/**
@@ -102,7 +102,7 @@ function generateDeploy(input: ContractArtifact) {
102102
...args: Parameters<${contractName}['methods'][M]>
103103
) {
104104
return new DeployMethod<${contractName}>(
105-
opts.publicKeys ?? PublicKeys.empty(),
105+
opts.publicKeys ?? PublicKeys.default(),
106106
opts.wallet,
107107
${artifactName},
108108
${contractName}.at,

yarn-project/circuits.js/src/constants.gen.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ export const REGISTERER_CONTRACT_ADDRESS = 3;
131131
export const MULTI_CALL_ENTRYPOINT_ADDRESS = 4;
132132
export const FEE_JUICE_ADDRESS = 5;
133133
export const ROUTER_ADDRESS = 6;
134+
export const DEFAULT_NPK_M_X = 582240093077765400562621227108555700500271598878376310175765873770292988861n;
135+
export const DEFAULT_NPK_M_Y = 10422444662424639723529825114205836958711284159673861467999592572974769103684n;
136+
export const DEFAULT_IVPK_M_X = 339708709767762472786445938838804872781183545349360029270386718856175781484n;
137+
export const DEFAULT_IVPK_M_Y = 12719619215050539905199178334954929730355853796706924300730604757520758976849n;
138+
export const DEFAULT_OVPK_M_X = 12212787719617305570587928860288475454328008955283046946846066128763901043335n;
139+
export const DEFAULT_OVPK_M_Y = 3646747884782549389807830220601404629716007431341772952958971658285958854707n;
140+
export const DEFAULT_TPK_M_X = 728059161893070741164607238299536939695876538801885465230641192969135857403n;
141+
export const DEFAULT_TPK_M_Y = 14575718736702206050102425029229426215631664471161015518982549597389390371695n;
134142
export const AZTEC_ADDRESS_LENGTH = 1;
135143
export const GAS_FEES_LENGTH = 2;
136144
export const GAS_LENGTH = 2;

0 commit comments

Comments
 (0)