Skip to content

Commit

Permalink
Merge ac37800 into 621cbaf
Browse files Browse the repository at this point in the history
  • Loading branch information
iAmMichaelConnor authored Dec 4, 2024
2 parents 621cbaf + ac37800 commit 80d2570
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions noir-projects/aztec-nr/authwit/src/auth.nr
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ use dep::aztec::protocol_types::{
global IS_VALID_SELECTOR: Field = 0x47dacd73; // 4 last bytes of poseidon2_hash_bytes("IS_VALID()")

/**
* Assert that `on_behalf_of` have authorized the current call with a valid authentication witness
* Assert that `on_behalf_of` has authorized the current call with a valid authentication witness
*
* Computing the `inner_hash` using the `msg_sender`, `selector` and `args_hash` and then making a call out to the
* Compute the `inner_hash` using the `msg_sender`, `selector` and `args_hash` and then make a call out to the
* `on_behalf_of` contract to verify that the `inner_hash` is valid.
*
* @param on_behalf_of The address that have authorized the current call
* @param on_behalf_of The address that has allegedly authorized the current call
*/
// docs:start:assert_current_call_valid_authwit
pub fn assert_current_call_valid_authwit(context: &mut PrivateContext, on_behalf_of: AztecAddress) {
Expand All @@ -217,7 +217,7 @@ pub fn assert_current_call_valid_authwit(context: &mut PrivateContext, on_behalf
* Used as an internal function for `assert_current_call_valid_authwit` and can be used as a standalone function when
* the `inner_hash` is from a different source, e.g., say a block of text etc.
*
* @param on_behalf_of The address that have authorized the current call
* @param on_behalf_of The address that has allegedly authorized the current call
* @param inner_hash The hash of the message to authorize
*/
pub fn assert_inner_hash_valid_authwit(
Expand All @@ -235,21 +235,21 @@ pub fn assert_inner_hash_valid_authwit(
.unpack_into();
assert(result == IS_VALID_SELECTOR, "Message not authorized by account");
// Compute the nullifier, similar computation to the outer hash, but without the chain_id and version.
// Those should already be handled in the verification, so we just need something to nullify, that allow same inner_hash for multiple actors.
// Those should already be handled in the verification, so we just need something to nullify, that allows the same inner_hash for multiple actors.
let nullifier = compute_authwit_nullifier(on_behalf_of, inner_hash);
context.push_nullifier(nullifier);
}

/**
* Assert that `on_behalf_of` have authorized the current call in the authentication registry
* Assert that `on_behalf_of` has authorized the current call in the authentication registry
*
* Computing the `inner_hash` using the `msg_sender`, `selector` and `args_hash` and then making a call out to the
* Compute the `inner_hash` using the `msg_sender`, `selector` and `args_hash` and then make a call out to the
* `on_behalf_of` contract to verify that the `inner_hash` is valid.
*
* Note that the authentication registry will take the `msg_sender` into account as the consumer, so this will only
* work if the `msg_sender` is the same as the `consumer` when the `message_hash` was inserted into the registry.
*
* @param on_behalf_of The address that have authorized the current call
* @param on_behalf_of The address that has allegedly authorized the current call
*/
// docs:start:assert_current_call_valid_authwit_public
pub unconstrained fn assert_current_call_valid_authwit_public(
Expand All @@ -266,15 +266,15 @@ pub unconstrained fn assert_current_call_valid_authwit_public(
// docs:end:assert_current_call_valid_authwit_public

/**
* Assert that `on_behalf_of` have authorized a speicifc `inner_hash` in the authentication registry
* Assert that `on_behalf_of` has authorized a specific `inner_hash` in the authentication registry
*
* Computing the `inner_hash` using the `msg_sender`, `selector` and `args_hash` and then making a call out to the
* Compute the `inner_hash` using the `msg_sender`, `selector` and `args_hash` and then make a call out to the
* `on_behalf_of` contract to verify that the `inner_hash` is valid.
*
* Note that the authentication registry will take the `msg_sender` into account as the consumer, so this will only
* work if the `msg_sender` is the same as the `consumer` when the `message_hash` was inserted into the registry.
*
* @param on_behalf_of The address that have authorized the `inner_hash`
* @param on_behalf_of The address that has allegedly authorized the `inner_hash`
*/
pub unconstrained fn assert_inner_hash_valid_authwit_public(
context: &mut PublicContext,
Expand Down Expand Up @@ -334,11 +334,11 @@ pub fn compute_inner_authwit_hash<let N: u32>(args: [Field; N]) -> Field {
}

/**
* Computs the `authwit_nullifier` for a specific `on_behalf_of` and `inner_hash`
* Computes the `authwit_nullifier` for a specific `on_behalf_of` and `inner_hash`
*
* Using the `on_behalf_of` and the `inner_hash` to ensure that the nullifier is siloed for a specific `on_behalf_of`.
*
* @param on_behalf_of The address that have authorized the `inner_hash`
* @param on_behalf_of The address that has authorized the `inner_hash`
* @param inner_hash The hash of the message to authorize
*/
pub fn compute_authwit_nullifier(on_behalf_of: AztecAddress, inner_hash: Field) -> Field {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ contract Token {
}

let from_ovpk_m = get_public_keys(from).ovpk_m;
// TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue
// TODO: constrain encryption below - we are using unconstrained here only because of the following Noir issue
// https://github.com/noir-lang/noir/issues/5771
storage.balances.at(from).sub(from, U128::from_integer(amount)).emit(
encode_and_encrypt_note_unconstrained(&mut context, from_ovpk_m, from, from),
Expand Down

0 comments on commit 80d2570

Please sign in to comment.