Skip to content

Commit 866ca2e

Browse files
authored
Merge branch 'backport-to-v4-next-staging' into claudebox/notify-fairies-on-compat-fail
2 parents b9c2250 + b0496cf commit 866ca2e

138 files changed

Lines changed: 2460 additions & 2280 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

noir-projects/noir-contracts/contracts/account/ecdsa_k_account_contract/src/main.nr

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ pub contract EcdsaKAccount {
77
use aztec::{
88
authwit::{account::AccountActions, entrypoint::app::AppPayload},
99
context::PrivateContext,
10-
macros::{
11-
functions::{allow_phase_change, external, initializer, noinitcheck, view},
12-
storage::storage,
13-
},
10+
macros::{functions::{allow_phase_change, external, initializer, noinitcheck, view}, storage::storage},
1411
messages::message_delivery::MessageDelivery,
1512
oracle::{auth_witness::get_auth_witness_as_bytes, notes::set_sender_for_tags},
1613
state_vars::SinglePrivateImmutable,
@@ -37,12 +34,11 @@ pub contract EcdsaKAccount {
3734
unsafe { set_sender_for_tags(self.address) };
3835
// The note message gets delivered to the note owner which is set by the SinglePrivateImmutable to be this
3936
// contract.
40-
self.storage.signing_public_key.initialize(pub_key_note).deliver(
41-
MessageDelivery.ONCHAIN_CONSTRAINED,
42-
);
37+
self.storage.signing_public_key.initialize(pub_key_note).deliver(MessageDelivery.ONCHAIN_CONSTRAINED);
4338
}
4439

45-
// @dev: If you globally change the entrypoint signature don't forget to update account_entrypoint.ts file (specifically `getEntrypointAbi()`)
40+
// @dev: If you globally change the entrypoint signature don't forget to update account_entrypoint.ts file
41+
// (specifically `getEntrypointAbi()`)
4642
// using noinitcheck is an optimization, it reduces gates by omitting a check that the contract has been initialized
4743
#[external("private")]
4844
#[noinitcheck]
@@ -75,12 +71,7 @@ pub contract EcdsaKAccount {
7571
// Note that noir expects the hash of the message/challenge as input to the ECDSA verification.
7672
let outer_hash_bytes: [u8; 32] = outer_hash.to_be_bytes();
7773
let hashed_message: [u8; 32] = sha256::digest(outer_hash_bytes);
78-
std::ecdsa_secp256k1::verify_signature(
79-
public_key.x,
80-
public_key.y,
81-
signature,
82-
hashed_message,
83-
)
74+
std::ecdsa_secp256k1::verify_signature(public_key.x, public_key.y, signature, hashed_message)
8475
}
8576
// docs:end:is_valid_impl
8677
}

noir-projects/noir-contracts/contracts/account/ecdsa_r_account_contract/src/main.nr

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
// Account contract that uses ECDSA signatures for authentication on random version of the p256 curve (to use with touchID).
1+
// Account contract that uses ECDSA signatures for authentication on random version of the p256 curve (to use with
2+
// touchID).
23
use aztec::macros::aztec;
34

45
#[aztec]
56
pub contract EcdsaRAccount {
67
use aztec::{
78
authwit::{account::AccountActions, entrypoint::app::AppPayload},
89
context::PrivateContext,
9-
macros::{
10-
functions::{allow_phase_change, external, initializer, noinitcheck, view},
11-
storage::storage,
12-
},
10+
macros::{functions::{allow_phase_change, external, initializer, noinitcheck, view}, storage::storage},
1311
messages::message_delivery::MessageDelivery,
1412
oracle::{auth_witness::get_auth_witness_as_bytes, notes::set_sender_for_tags},
1513
state_vars::SinglePrivateImmutable,
@@ -36,12 +34,11 @@ pub contract EcdsaRAccount {
3634
unsafe { set_sender_for_tags(self.address) };
3735
// The note message gets delivered to the note owner which is set by the SinglePrivateImmutable to be this
3836
// contract.
39-
self.storage.signing_public_key.initialize(pub_key_note).deliver(
40-
MessageDelivery.ONCHAIN_CONSTRAINED,
41-
);
37+
self.storage.signing_public_key.initialize(pub_key_note).deliver(MessageDelivery.ONCHAIN_CONSTRAINED);
4238
}
4339

44-
// @dev: If you globally change the entrypoint signature don't forget to update account_entrypoint.ts file (specifically `getEntrypointAbi()`)
40+
// @dev: If you globally change the entrypoint signature don't forget to update account_entrypoint.ts file
41+
// (specifically `getEntrypointAbi()`)
4542
// using noinitcheck is an optimization, it reduces gates by omitting a check that the contract has been initialized
4643
#[external("private")]
4744
#[noinitcheck]
@@ -73,11 +70,6 @@ pub contract EcdsaRAccount {
7370
// Note that noir expects the hash of the message/challenge as input to the ECDSA verification.
7471
let outer_hash_bytes: [u8; 32] = outer_hash.to_be_bytes();
7572
let hashed_message: [u8; 32] = sha256::digest(outer_hash_bytes);
76-
std::ecdsa_secp256r1::verify_signature(
77-
public_key.x,
78-
public_key.y,
79-
signature,
80-
hashed_message,
81-
)
73+
std::ecdsa_secp256r1::verify_signature(public_key.x, public_key.y, signature, hashed_message)
8274
}
8375
}

noir-projects/noir-contracts/contracts/account/schnorr_account_contract/src/main.nr

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@ pub contract SchnorrAccount {
1414
},
1515
context::PrivateContext,
1616
hash::compute_siloed_nullifier,
17-
macros::{
18-
functions::{allow_phase_change, external, initializer, noinitcheck, view},
19-
storage::storage,
20-
},
17+
macros::{functions::{allow_phase_change, external, initializer, noinitcheck, view}, storage::storage},
2118
messages::message_delivery::MessageDelivery,
2219
oracle::{
2320
auth_witness::get_auth_witness_as_bytes,
24-
get_nullifier_membership_witness::get_low_nullifier_membership_witness,
25-
notes::set_sender_for_tags,
21+
get_nullifier_membership_witness::get_low_nullifier_membership_witness, notes::set_sender_for_tags,
2622
},
2723
protocol::address::AztecAddress,
2824
state_vars::SinglePrivateImmutable,
@@ -49,12 +45,11 @@ pub contract SchnorrAccount {
4945
unsafe { set_sender_for_tags(self.address) };
5046
// The note message gets delivered to the note owner which is set by the SinglePrivateImmutable to be this
5147
// contract.
52-
self.storage.signing_public_key.initialize(pub_key_note).deliver(
53-
MessageDelivery.ONCHAIN_CONSTRAINED,
54-
);
48+
self.storage.signing_public_key.initialize(pub_key_note).deliver(MessageDelivery.ONCHAIN_CONSTRAINED);
5549
}
5650

57-
// @dev: If you globally change the entrypoint signature don't forget to update account_entrypoint.ts file (specifically `getEntrypointAbi()`).
51+
// @dev: If you globally change the entrypoint signature don't forget to update account_entrypoint.ts file
52+
// (specifically `getEntrypointAbi()`).
5853
// using noinitcheck is an optimization, it reduces gates by omitting a check that the contract has been initialized
5954
#[external("private")]
6055
#[noinitcheck]
@@ -83,19 +78,16 @@ pub contract SchnorrAccount {
8378
// Hence it's safe.
8479
let signature: [u8; 64] = unsafe { get_auth_witness_as_bytes(outer_hash) };
8580

86-
let pub_key =
87-
std::embedded_curve_ops::EmbeddedCurvePoint { x: public_key.x, y: public_key.y };
81+
let pub_key = std::embedded_curve_ops::EmbeddedCurvePoint { x: public_key.x, y: public_key.y };
8882
// Verify signature of the payload bytes
8983
schnorr::verify_signature(pub_key, signature, outer_hash.to_be_bytes::<32>())
9084
// docs:end:is_valid_impl
9185
}
9286

93-
/**
94-
* @notice Helper function to check validity of private authwitnesses
95-
* @param consumer The address of the consumer of the message
96-
* @param message_hash The message hash of the message to check the validity
97-
* @return True if the message_hash can be consumed, false otherwise
98-
*/
87+
/// @notice Helper function to check validity of private authwitnesses
88+
/// @param consumer The address of the consumer of the message
89+
/// @param message_hash The message hash of the message to check the validity
90+
/// @return True if the message_hash can be consumed, false otherwise
9991
#[external("utility")]
10092
unconstrained fn lookup_validity(consumer: AztecAddress, inner_hash: Field) -> bool {
10193
let public_key = self.storage.signing_public_key.view_note();
@@ -108,10 +100,8 @@ pub contract SchnorrAccount {
108100
);
109101

110102
let signature: [u8; 64] = get_auth_witness_as_bytes(message_hash);
111-
let pub_key =
112-
std::embedded_curve_ops::EmbeddedCurvePoint { x: public_key.x, y: public_key.y };
113-
let valid_in_private =
114-
schnorr::verify_signature(pub_key, signature, message_hash.to_be_bytes::<32>());
103+
let pub_key = std::embedded_curve_ops::EmbeddedCurvePoint { x: public_key.x, y: public_key.y };
104+
let valid_in_private = schnorr::verify_signature(pub_key, signature, message_hash.to_be_bytes::<32>());
115105

116106
// Compute the nullifier and check if it is spent
117107
// This will BLINDLY TRUST the oracle, but the oracle is us, and

noir-projects/noir-contracts/contracts/account/schnorr_hardcoded_account_contract/src/main.nr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ pub contract SchnorrHardcodedAccount {
1616
y: 0x208d44b36eb6e73b254921134d002da1a90b41131024e3b1d721259182106205,
1717
};
1818

19-
// @dev: If you globally change the entrypoint signature don't forget to update account_entrypoint.ts (specifically `getEntrypointAbi()`)
19+
// @dev: If you globally change the entrypoint signature don't forget to update account_entrypoint.ts (specifically
20+
// `getEntrypointAbi()`)
2021
#[external("private")]
2122
#[allow_phase_change]
2223
fn entrypoint(app_payload: AppPayload, fee_payment_method: u8, cancellable: bool) {

noir-projects/noir-contracts/contracts/account/simulated_ecdsa_account_contract/src/main.nr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ pub contract SimulatedEcdsaAccount {
7070

7171
#[external("utility")]
7272
unconstrained fn sync_state() {
73-
assert(
74-
false,
75-
"BUG ALERT: sync_state on a simulated account contract should never be triggered.",
76-
);
73+
assert(false, "BUG ALERT: sync_state on a simulated account contract should never be triggered.");
7774
}
7875
}

noir-projects/noir-contracts/contracts/account/simulated_schnorr_account_contract/src/main.nr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ pub contract SimulatedSchnorrAccount {
7070

7171
#[external("utility")]
7272
unconstrained fn sync_state() {
73-
assert(
74-
false,
75-
"BUG ALERT: sync_state on a simulated account contract should never be triggered.",
76-
);
73+
assert(false, "BUG ALERT: sync_state on a simulated account contract should never be triggered.");
7774
}
7875
}

noir-projects/noir-contracts/contracts/app/amm_contract/src/lib.nr

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ pub fn get_amount_in(amount_out: u128, balance_in: u128, balance_out: u128) -> u
3232
(numerator / denominator) + 1 as u128
3333
}
3434

35-
/// Given the desired amounts and balances of token0 and token1 returns the optimal amount of token0 and token1 to be added to the pool.
35+
/// Given the desired amounts and balances of token0 and token1 returns the optimal amount of token0 and token1 to be
36+
/// added to the pool.
3637
pub fn get_amounts_to_add(
3738
amount0_max: u128,
3839
amount1_max: u128,
@@ -74,12 +75,7 @@ pub fn get_amounts_to_add(
7475
}
7576

7677
/// Returns the amount of tokens to return to a liquidity provider when they remove liquidity from the pool.
77-
pub fn get_amounts_on_remove(
78-
to_burn: u128,
79-
total_supply: u128,
80-
balance0: u128,
81-
balance1: u128,
82-
) -> (u128, u128) {
78+
pub fn get_amounts_on_remove(to_burn: u128, total_supply: u128, balance0: u128, balance1: u128) -> (u128, u128) {
8379
// Since the liquidity token tracks ownership of the pool, the liquidity provider gets a proportional share of each
8480
// token.
8581
(to_burn * balance0 / total_supply, to_burn * balance1 / total_supply)

0 commit comments

Comments
 (0)