From 826487a1d93fb1a0cfd1ef9ffb336ca2c53a06b7 Mon Sep 17 00:00:00 2001 From: LHerskind Date: Mon, 26 Feb 2024 17:47:42 +0000 Subject: [PATCH] feat: AUTHWIT generator --- noir-projects/aztec-nr/authwit/src/auth.nr | 8 ++++---- .../src/crates/types/src/constants.nr | 1 + yarn-project/aztec.js/src/utils/authwit.ts | 2 +- yarn-project/circuits.js/src/constants.gen.ts | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/noir-projects/aztec-nr/authwit/src/auth.nr b/noir-projects/aztec-nr/authwit/src/auth.nr index 99b07bf11a8b..34af8aa8bf91 100644 --- a/noir-projects/aztec-nr/authwit/src/auth.nr +++ b/noir-projects/aztec-nr/authwit/src/auth.nr @@ -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}; @@ -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); } @@ -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); } @@ -72,7 +72,7 @@ pub fn compute_authwit_message_hash( 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 diff --git a/noir-projects/noir-protocol-circuits/src/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/src/crates/types/src/constants.nr index 4c69e3ae4395..8514e3765424 100644 --- a/noir-projects/noir-protocol-circuits/src/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/src/crates/types/src/constants.nr @@ -230,3 +230,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; diff --git a/yarn-project/aztec.js/src/utils/authwit.ts b/yarn-project/aztec.js/src/utils/authwit.ts index f449a429b2be..79898897e9a4 100644 --- a/yarn-project/aztec.js/src/utils/authwit.ts +++ b/yarn-project/aztec.js/src/utils/authwit.ts @@ -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 diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index 8b3295b2af89..bce42ca14f6b 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -143,4 +143,5 @@ export enum GeneratorIndex { PRIVATE_CIRCUIT_PUBLIC_INPUTS = 42, PUBLIC_CIRCUIT_PUBLIC_INPUTS = 43, FUNCTION_ARGS = 44, + AUTHWIT = 45, }