Skip to content

Commit

Permalink
feat: AUTHWIT generator (#4798)
Browse files Browse the repository at this point in the history
Fixes #2676 by using a different index for the pedersen hash.
  • Loading branch information
LHerskind committed Feb 28, 2024
1 parent 7d380e4 commit efd70f4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions noir-projects/aztec-nr/authwit/src/auth.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::aztec::protocol_types::{
abis::function_selector::FunctionSelector, address::AztecAddress,
constants::{GENERATOR_INDEX__SIGNATURE_PAYLOAD}, hash::{hash_args, pedersen_hash}
constants::{GENERATOR_INDEX__AUTHWIT}, hash::{hash_args, pedersen_hash}
};
use dep::aztec::context::{PrivateContext, PublicContext, Context};

Expand Down Expand Up @@ -31,7 +31,7 @@ pub fn assert_current_call_valid_authwit(context: &mut PrivateContext, on_behalf
[
context.msg_sender().to_field(), context.this_address().to_field(), context.selector().to_field(), context.args_hash
],
GENERATOR_INDEX__SIGNATURE_PAYLOAD
GENERATOR_INDEX__AUTHWIT
);
assert_valid_authwit(context, on_behalf_of, message_hash);
}
Expand All @@ -55,7 +55,7 @@ pub fn assert_current_call_valid_authwit_public(context: &mut PublicContext, on_
[
context.msg_sender().to_field(), context.this_address().to_field(), context.selector().to_field(), context.args_hash
],
GENERATOR_INDEX__SIGNATURE_PAYLOAD
GENERATOR_INDEX__AUTHWIT
);
assert_valid_authwit_public(context, on_behalf_of, message_hash);
}
Expand All @@ -72,7 +72,7 @@ pub fn compute_authwit_message_hash<N>(
let args_hash = hash_args(args);
pedersen_hash(
[caller.to_field(), target.to_field(), selector.to_field(), args_hash],
GENERATOR_INDEX__SIGNATURE_PAYLOAD
GENERATOR_INDEX__AUTHWIT
)
}
// docs:end:compute_authwit_message_hash
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,4 @@ global GENERATOR_INDEX__VK = 41;
global GENERATOR_INDEX__PRIVATE_CIRCUIT_PUBLIC_INPUTS = 42;
global GENERATOR_INDEX__PUBLIC_CIRCUIT_PUBLIC_INPUTS = 43;
global GENERATOR_INDEX__FUNCTION_ARGS = 44;
global GENERATOR_INDEX__AUTHWIT = 45;
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/utils/authwit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const computeAuthWitMessageHash = (caller: AztecAddress, request: Functio
request.functionData.selector.toField(),
PackedArguments.fromArgs(request.args).hash,
].map(fr => fr.toBuffer()),
GeneratorIndex.SIGNATURE_PAYLOAD,
GeneratorIndex.AUTHWIT,
);
};
// docs:end:authwit_computeAuthWitMessageHash
1 change: 1 addition & 0 deletions yarn-project/circuits.js/src/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,5 @@ export enum GeneratorIndex {
PRIVATE_CIRCUIT_PUBLIC_INPUTS = 42,
PUBLIC_CIRCUIT_PUBLIC_INPUTS = 43,
FUNCTION_ARGS = 44,
AUTHWIT = 45,
}

0 comments on commit efd70f4

Please sign in to comment.