From f83f0272b4ebcfdcf6e6c52faa43a28beabaf90f Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 12 Oct 2023 13:56:03 +0200 Subject: [PATCH] WIP --- CHANGELOG.md | 2 +- .../cpp/src/aztec3/circuits/abis/packers.hpp | 4 ++-- circuits/cpp/src/aztec3/circuits/apps/.test.cpp | 4 ++-- .../apps/notes/default_private_note/note.hpp | 8 ++++---- .../default_singleton_private_note/note.hpp | 4 ++-- .../default_singleton_private_note/note.tpp | 16 ++++++++-------- .../circuits/apps/notes/note_interface.hpp | 4 ++-- .../src/aztec3/circuits/apps/opcodes/opcodes.hpp | 2 +- .../src/aztec3/circuits/apps/opcodes/opcodes.tpp | 4 ++-- circuits/cpp/src/aztec3/constants.hpp | 2 +- .../concepts/advanced/data_structures/trees.md | 2 +- docs/docs/dev_docs/wallets/main.md | 2 +- yarn-project/aztec-nr/aztec/src/constants_gen.nr | 2 +- .../aztec-nr/aztec/src/state_vars/singleton.nr | 6 +++--- .../src/barretenberg/crypto/aes128/index.ts | 4 ++-- .../circuits.js/src/cbind/constants.gen.ts | 2 +- yarn-project/end-to-end/src/fixtures/utils.ts | 2 +- .../src/ecdsa_public_key_note.nr | 8 ++++---- 18 files changed, 39 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e77add497ce..a32c66e6874a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -199,7 +199,7 @@ * Add boxes to CI ([#2456](https://github.com/AztecProtocol/aztec-packages/issues/2456)) ([a90a185](https://github.com/AztecProtocol/aztec-packages/commit/a90a185bb1d72658c7910366e593303607edf873)) * Add selector to call_context ([#2626](https://github.com/AztecProtocol/aztec-packages/issues/2626)) ([8e317be](https://github.com/AztecProtocol/aztec-packages/commit/8e317be9fafb1daa7bc0bdd08d603ce95d3be2f9)) * AddNote api ([#2535](https://github.com/AztecProtocol/aztec-packages/issues/2535)) ([bb004f4](https://github.com/AztecProtocol/aztec-packages/commit/bb004f4419ca9dba9d8216eaba2e65d3a4a994f8)) -* **aztec_noir:** Abstract storage initialisation ([#2406](https://github.com/AztecProtocol/aztec-packages/issues/2406)) ([974b037](https://github.com/AztecProtocol/aztec-packages/commit/974b037650e7fac6fbc3721359daf5f1891b5a2a)) +* **aztec_noir:** Abstract storage initialization ([#2406](https://github.com/AztecProtocol/aztec-packages/issues/2406)) ([974b037](https://github.com/AztecProtocol/aztec-packages/commit/974b037650e7fac6fbc3721359daf5f1891b5a2a)) * **aztec.js:** Support AddressLike parameters ([#2430](https://github.com/AztecProtocol/aztec-packages/issues/2430)) ([5b5f139](https://github.com/AztecProtocol/aztec-packages/commit/5b5f139af2eb8ceb71e807c49be6c2b54e6e435b)) * Barretenberg/crypto/blake3s supports compile-time hashing ([#2556](https://github.com/AztecProtocol/aztec-packages/issues/2556)) ([da05dd7](https://github.com/AztecProtocol/aztec-packages/commit/da05dd7ea41208aea42efe0aeb838e4d76e2d34a)) * **bb:** Add `bb --version` command ([#2482](https://github.com/AztecProtocol/aztec-packages/issues/2482)) ([530676f](https://github.com/AztecProtocol/aztec-packages/commit/530676f8ec53e63ba24f6fabc9097ae8f5db5fc6)) diff --git a/circuits/cpp/src/aztec3/circuits/abis/packers.hpp b/circuits/cpp/src/aztec3/circuits/abis/packers.hpp index fb001b0f049a..8742e8956773 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/packers.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/packers.hpp @@ -107,7 +107,7 @@ struct GeneratorIndexPacker { int UNIQUE_COMMITMENT = GeneratorIndex::UNIQUE_COMMITMENT; int SILOED_COMMITMENT = GeneratorIndex::SILOED_COMMITMENT; int NULLIFIER = GeneratorIndex::NULLIFIER; - int INITIALISATION_NULLIFIER = GeneratorIndex::INITIALISATION_NULLIFIER; + int INITIALIZATION_NULLIFIER = GeneratorIndex::INITIALIZATION_NULLIFIER; int OUTER_NULLIFIER = GeneratorIndex::OUTER_NULLIFIER; int PUBLIC_DATA_READ = GeneratorIndex::PUBLIC_DATA_READ; int PUBLIC_DATA_UPDATE_REQUEST = GeneratorIndex::PUBLIC_DATA_UPDATE_REQUEST; @@ -144,7 +144,7 @@ struct GeneratorIndexPacker { UNIQUE_COMMITMENT, SILOED_COMMITMENT, NULLIFIER, - INITIALISATION_NULLIFIER, + INITIALIZATION_NULLIFIER, OUTER_NULLIFIER, PUBLIC_DATA_READ, PUBLIC_DATA_UPDATE_REQUEST, diff --git a/circuits/cpp/src/aztec3/circuits/apps/.test.cpp b/circuits/cpp/src/aztec3/circuits/apps/.test.cpp index d847c14c699a..3e35f82b9ccd 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/.test.cpp @@ -300,7 +300,7 @@ TEST_F(state_var_tests, circuit_initialise_utxo_of_default_singleton_private_not // FUNCTION: // This time we use a slightly different Note type, which is tailored towards singleton UTXO use-cases. In - // particular, it copes with the distinction between initialisation of the UTXO, vs future modification of the UTXO. + // particular, it copes with the distinction between initialization of the UTXO, vs future modification of the UTXO. using Note = DefaultSingletonPrivateNote; UTXO my_utxo(&exec_ctx, "my_utxo"); @@ -348,7 +348,7 @@ TEST_F(state_var_tests, circuit_modify_utxo_of_default_singleton_private_note_fr // FUNCTION: // This time we use a slightly different Note type, which is tailored towards singleton UTXO use-cases. In - // particular, it copes with the distinction between initialisation of the UTXO, vs future modification of the UTXO. + // particular, it copes with the distinction between initialization of the UTXO, vs future modification of the UTXO. using Note = DefaultSingletonPrivateNote; UTXO my_utxo(&exec_ctx, "my_utxo"); diff --git a/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note.hpp b/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note.hpp index 2dcff2259d6f..6c2837c5447d 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note.hpp @@ -85,16 +85,16 @@ template class DefaultPrivateNote : publi fr generate_nonce() override; - fr get_initialisation_nullifier() override + fr get_initialization_nullifier() override { throw_or_abort( - "DefaultPrivateNote does not support initialisation. Maybe use DefaultSingletonPrivateNote instead?"); + "DefaultPrivateNote does not support initialization. Maybe use DefaultSingletonPrivateNote instead?"); }; - fr get_initialisation_commitment() override + fr get_initialization_commitment() override { throw_or_abort( - "DefaultPrivateNote does not support initialisation. Maybe use DefaultSingletonPrivateNote instead?"); + "DefaultPrivateNote does not support initialization. Maybe use DefaultSingletonPrivateNote instead?"); }; // CUSTOM METHODS diff --git a/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.hpp b/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.hpp index a5389838cd3d..df09571661c0 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.hpp @@ -74,9 +74,9 @@ template class DefaultSingletonPrivateNot fr generate_nonce() override; - fr get_initialisation_nullifier() override; + fr get_initialization_nullifier() override; - fr get_initialisation_commitment() override; + fr get_initialization_commitment() override; // CUSTOM METHODS diff --git a/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.tpp b/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.tpp index 76742963edf2..18bc2b54a7db 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.tpp +++ b/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.tpp @@ -188,7 +188,7 @@ typename CircuitTypes::fr DefaultSingletonPrivateNote::gene }; template -typename CircuitTypes::fr DefaultSingletonPrivateNote::get_initialisation_nullifier() +typename CircuitTypes::fr DefaultSingletonPrivateNote::get_initialization_nullifier() { auto& oracle = get_oracle(); @@ -205,7 +205,7 @@ typename CircuitTypes::fr DefaultSingletonPrivateNote::get_ const bool is_dummy = false; // We compress the hash_inputs with Pedersen, because that's cheap. - const fr compressed_storage_slot_point = CT::compress(hash_inputs, GeneratorIndex::INITIALISATION_NULLIFIER); + const fr compressed_storage_slot_point = CT::compress(hash_inputs, GeneratorIndex::INITIALIZATION_NULLIFIER); // For now, we piggy-back on the regular nullifier function. return DefaultSingletonPrivateNote::compute_nullifier( @@ -213,15 +213,15 @@ typename CircuitTypes::fr DefaultSingletonPrivateNote::get_ }; template -typename CircuitTypes::fr DefaultSingletonPrivateNote::get_initialisation_commitment() +typename CircuitTypes::fr DefaultSingletonPrivateNote::get_initialization_commitment() { /** - * TODO: Get rid of this temporary fix of including owner_private_key while computing the initialisation commitment. - * Details: We need to add the initialisation commitment value to the `nullified_commitments`. - * In this case, since the actual note data is not yet available, we compute the initialisation nullifier as: + * TODO: Get rid of this temporary fix of including owner_private_key while computing the initialization commitment. + * Details: We need to add the initialization commitment value to the `nullified_commitments`. + * In this case, since the actual note data is not yet available, we compute the initialization nullifier as: * null = hash(compressed_storage_slot, owner_private_key, false) * - * Thus, the initialisation commitment here is `compressed_storage_slot`. But since the storage slot is not a real + * Thus, the initialization commitment here is `compressed_storage_slot`. But since the storage slot is not a real * circuit variable, `compressed_storage_slot` would be a circuit constant. The compiler doesn't allow us * to make a circuit constant as a public input of the circuit, it just crashes at runtime. * To avoid this, we compute the initial commitment as: @@ -243,7 +243,7 @@ typename CircuitTypes::fr DefaultSingletonPrivateNote::get_ }; // We compress the hash_inputs with Pedersen, because that's cheap. - fr compressed_storage_slot_point = CT::compress(hash_inputs, GeneratorIndex::INITIALISATION_NULLIFIER); + fr compressed_storage_slot_point = CT::compress(hash_inputs, GeneratorIndex::INITIALIZATION_NULLIFIER); return compressed_storage_slot_point; }; diff --git a/circuits/cpp/src/aztec3/circuits/apps/notes/note_interface.hpp b/circuits/cpp/src/aztec3/circuits/apps/notes/note_interface.hpp index a56982bb6827..f9bfb3c7e943 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/notes/note_interface.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/notes/note_interface.hpp @@ -38,9 +38,9 @@ template class NoteInterface { virtual fr get_nullifier() = 0; - virtual fr get_initialisation_nullifier() = 0; + virtual fr get_initialization_nullifier() = 0; - virtual fr get_initialisation_commitment() = 0; + virtual fr get_initialization_commitment() = 0; virtual void constrain_against_advice(NoteInterface const& advice_note) = 0; diff --git a/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.hpp b/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.hpp index 59e715f1d0f4..15595b63fa10 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.hpp @@ -62,7 +62,7 @@ template class Opcodes { /** * @brief Compute and push a new commitment to the public inputs of this exec_ctx, BUT ALSO compute and produce an - * initialisation nullifier, to prevent this note from being initialised again in the future. + * initialization nullifier, to prevent this note from being initialised again in the future. */ template static void UTXO_INIT(StateVar* state_var, Note& note_to_initialise); diff --git a/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.tpp b/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.tpp index a44bdd044003..7a4d3d1f4904 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.tpp +++ b/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.tpp @@ -122,8 +122,8 @@ void Opcodes::UTXO_NULL(StateVar* state_var, Note& note_to_nul template template void Opcodes::UTXO_INIT(StateVar* state_var, Note& note_to_initialise) { - typename CT::fr const init_nullifier = note_to_initialise.get_initialisation_nullifier(); - typename CT::fr const init_commitment = note_to_initialise.get_initialisation_commitment(); + typename CT::fr const init_nullifier = note_to_initialise.get_initialization_nullifier(); + typename CT::fr const init_commitment = note_to_initialise.get_initialization_commitment(); auto& exec_ctx = state_var->exec_ctx; diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index 152c5ce6b566..a9bf9e8bfd1b 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -146,7 +146,7 @@ enum GeneratorIndex { UNIQUE_COMMITMENT, // Size = 2 SILOED_COMMITMENT, // Size = 2 NULLIFIER, // Size = 4 (unused) - INITIALISATION_NULLIFIER, // Size = 2 (unused) + INITIALIZATION_NULLIFIER, // Size = 2 (unused) OUTER_NULLIFIER, // Size = 2 PUBLIC_DATA_READ, // Size = 2 PUBLIC_DATA_UPDATE_REQUEST, // Size = 3 diff --git a/docs/docs/concepts/advanced/data_structures/trees.md b/docs/docs/concepts/advanced/data_structures/trees.md index d2d4034b4775..ad801b6a0511 100644 --- a/docs/docs/concepts/advanced/data_structures/trees.md +++ b/docs/docs/concepts/advanced/data_structures/trees.md @@ -100,7 +100,7 @@ If a function of a smart contract generates this Nullifier and submits it to the 'Singleton Note' is a term we've been using to mean: "A single Note which contains the whole of a private state's current value, and must be deleted and replaced with another single Note, if one ever wishes to edit that state". It's in contrast to a Note which only contains a small fragment of a Private State's current value. -We've found that such notes require an 'Initialisation Nullifier'; a nullifier which, when emitted, signals the initialisation of this state variable. I.e. the very first time the state variable has been written-to. +We've found that such notes require an 'Initialisation Nullifier'; a nullifier which, when emitted, signals the initialization of this state variable. I.e. the very first time the state variable has been written-to. > There's more on this topic in [the Aztec forum](https://discourse.aztec.network/t/utxo-syntax-2-initialising-singleton-utxos/47). diff --git a/docs/docs/dev_docs/wallets/main.md b/docs/docs/dev_docs/wallets/main.md index b346c8976e4b..66da29e8824d 100644 --- a/docs/docs/dev_docs/wallets/main.md +++ b/docs/docs/dev_docs/wallets/main.md @@ -14,7 +14,7 @@ The first step for any wallet is to let the user set up their [accounts](../../c A wallet must support at least one specific [account contract implementation](./writing_an_account_contract.md), which means being able to deploy such a contract, as well as interacting with it when sending transactions. Code-wise, this requires [implementing the `AccountContract` interface](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec.js/src/account/contract/index.ts). -Note that users must be able to receive funds in Aztec before deploying their account. A wallet should let a user generate a [deterministic complete address](../../concepts/foundation/accounts/keys.md#addresses-partial-addresses-and-public-keys) without having to interact with the network, so they can share it with others to receive funds. This requires that the wallet pins a specific contract implementation, its initialisation arguments, a deployment salt, and a privacy key. These values yield a deterministic address, so when the account contract is actually deployed, it is available at the precalculated address. Once the account contract is deployed, the user can start sending transactions using it as the transaction origin. +Note that users must be able to receive funds in Aztec before deploying their account. A wallet should let a user generate a [deterministic complete address](../../concepts/foundation/accounts/keys.md#addresses-partial-addresses-and-public-keys) without having to interact with the network, so they can share it with others to receive funds. This requires that the wallet pins a specific contract implementation, its initialization arguments, a deployment salt, and a privacy key. These values yield a deterministic address, so when the account contract is actually deployed, it is available at the precalculated address. Once the account contract is deployed, the user can start sending transactions using it as the transaction origin. ## Transaction lifecycle diff --git a/yarn-project/aztec-nr/aztec/src/constants_gen.nr b/yarn-project/aztec-nr/aztec/src/constants_gen.nr index c0680c8b2c62..bafa6e36b35c 100644 --- a/yarn-project/aztec-nr/aztec/src/constants_gen.nr +++ b/yarn-project/aztec-nr/aztec/src/constants_gen.nr @@ -78,7 +78,7 @@ global GENERATOR_INDEX__COMMITMENT_NONCE = 2; global GENERATOR_INDEX__UNIQUE_COMMITMENT = 3; global GENERATOR_INDEX__SILOED_COMMITMENT = 4; global GENERATOR_INDEX__NULLIFIER = 5; -global GENERATOR_INDEX__INITIALISATION_NULLIFIER = 6; +global GENERATOR_INDEX__INITIALIZATION_NULLIFIER = 6; global GENERATOR_INDEX__OUTER_NULLIFIER = 7; global GENERATOR_INDEX__PUBLIC_DATA_READ = 8; global GENERATOR_INDEX__PUBLIC_DATA_UPDATE_REQUEST = 9; diff --git a/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr b/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr index 965e4e5f47fa..d1ce9e44593e 100644 --- a/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr +++ b/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr @@ -1,5 +1,5 @@ use dep::std::option::Option; -use crate::constants_gen::{EMPTY_NULLIFIED_COMMITMENT, GENERATOR_INDEX__INITIALISATION_NULLIFIER}; +use crate::constants_gen::{EMPTY_NULLIFIED_COMMITMENT, GENERATOR_INDEX__INITIALIZATION_NULLIFIER}; use crate::context::{PrivateContext, PublicContext, Context}; use crate::note::{ lifecycle::{create_note, destroy_note}, @@ -18,12 +18,12 @@ pub fn compute_singleton_initialization_nullifier(storage_slot: Field, owner: Op let secret = get_secret_key(owner.unwrap_unchecked()); pedersen_with_separator( [storage_slot, secret.low, secret.high], - GENERATOR_INDEX__INITIALISATION_NULLIFIER, + GENERATOR_INDEX__INITIALIZATION_NULLIFIER, )[0] } else { pedersen_with_separator( [storage_slot], - GENERATOR_INDEX__INITIALISATION_NULLIFIER, + GENERATOR_INDEX__INITIALIZATION_NULLIFIER, )[0] } } diff --git a/yarn-project/circuits.js/src/barretenberg/crypto/aes128/index.ts b/yarn-project/circuits.js/src/barretenberg/crypto/aes128/index.ts index 47e8b7c90dad..8d92a2779ab2 100644 --- a/yarn-project/circuits.js/src/barretenberg/crypto/aes128/index.ts +++ b/yarn-project/circuits.js/src/barretenberg/crypto/aes128/index.ts @@ -11,7 +11,7 @@ export class Aes128 { /** * Encrypt a buffer using AES-128-CBC. * @param data - Data to encrypt. - * @param iv - AES initialisation vector. + * @param iv - AES initialization vector. * @param key - Key to encrypt with. * @returns Encrypted data. */ @@ -50,7 +50,7 @@ export class Aes128 { /** * Decrypt a buffer using AES-128-CBC. * @param data - Data to decrypt. - * @param iv - AES initialisation vector. + * @param iv - AES initialization vector. * @param key - Key to decrypt with. * @returns Decrypted data. */ diff --git a/yarn-project/circuits.js/src/cbind/constants.gen.ts b/yarn-project/circuits.js/src/cbind/constants.gen.ts index 13b9bd3515f2..1817cbedd8fd 100644 --- a/yarn-project/circuits.js/src/cbind/constants.gen.ts +++ b/yarn-project/circuits.js/src/cbind/constants.gen.ts @@ -80,7 +80,7 @@ export enum GeneratorIndex { UNIQUE_COMMITMENT = 3, SILOED_COMMITMENT = 4, NULLIFIER = 5, - INITIALISATION_NULLIFIER = 6, + INITIALIZATION_NULLIFIER = 6, OUTER_NULLIFIER = 7, PUBLIC_DATA_READ = 8, PUBLIC_DATA_UPDATE_REQUEST = 9, diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index db7cfde63df3..4c5e9e228766 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -248,7 +248,7 @@ export type EndToEndContext = { /** * Sets up the environment for the end-to-end tests. * @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated. - * @param opts - Options to pass to the node initialisation and to the setup script. + * @param opts - Options to pass to the node initialization and to the setup script. */ export async function setup(numberOfAccounts = 1, opts: SetupOptions = {}): Promise { const config = { ...getConfigEnvVars(), ...opts }; diff --git a/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr b/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr index e7df3dcb1bcb..99e27616bed9 100644 --- a/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr +++ b/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr @@ -36,10 +36,10 @@ impl EcdsaPublicKeyNote { let mut mul: Field = 1; for i in 1..32 { - let bytex: Field = self.x[31 - i] as Field; - x = x + (bytex * mul); - let bytey: Field = self.y[31 - i] as Field; - y = y + (bytey * mul); + let byte_x: Field = self.x[31 - i] as Field; + x = x + (byte_x * mul); + let byte_y: Field = self.y[31 - i] as Field; + y = y + (byte_y * mul); mul *= 256; }