Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Oct 12, 2023
1 parent a42568a commit f83f027
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions circuits/cpp/src/aztec3/circuits/abis/packers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -144,7 +144,7 @@ struct GeneratorIndexPacker {
UNIQUE_COMMITMENT,
SILOED_COMMITMENT,
NULLIFIER,
INITIALISATION_NULLIFIER,
INITIALIZATION_NULLIFIER,
OUTER_NULLIFIER,
PUBLIC_DATA_READ,
PUBLIC_DATA_UPDATE_REQUEST,
Expand Down
4 changes: 2 additions & 2 deletions circuits/cpp/src/aztec3/circuits/apps/.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<C, CT::fr>;

UTXO<Note> my_utxo(&exec_ctx, "my_utxo");
Expand Down Expand Up @@ -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<C, CT::fr>;

UTXO<Note> my_utxo(&exec_ctx, "my_utxo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ template <typename Builder, typename ValueType> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ template <typename Builder, typename ValueType> 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ typename CircuitTypes<Builder>::fr DefaultSingletonPrivateNote<Builder, V>::gene
};

template <typename Builder, typename V>
typename CircuitTypes<Builder>::fr DefaultSingletonPrivateNote<Builder, V>::get_initialisation_nullifier()
typename CircuitTypes<Builder>::fr DefaultSingletonPrivateNote<Builder, V>::get_initialization_nullifier()
{
auto& oracle = get_oracle();

Expand All @@ -205,23 +205,23 @@ typename CircuitTypes<Builder>::fr DefaultSingletonPrivateNote<Builder, V>::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<Builder, V>::compute_nullifier(
compressed_storage_slot_point, owner_private_key, is_dummy);
};

template <typename Builder, typename V>
typename CircuitTypes<Builder>::fr DefaultSingletonPrivateNote<Builder, V>::get_initialisation_commitment()
typename CircuitTypes<Builder>::fr DefaultSingletonPrivateNote<Builder, V>::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:
Expand All @@ -243,7 +243,7 @@ typename CircuitTypes<Builder>::fr DefaultSingletonPrivateNote<Builder, V>::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;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ template <typename Builder> 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<Builder> const& advice_note) = 0;

Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ template <typename Builder> 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 <typename Note> static void UTXO_INIT(StateVar<Builder>* state_var, Note& note_to_initialise);

Expand Down
4 changes: 2 additions & 2 deletions circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ void Opcodes<Builder>::UTXO_NULL(StateVar<Builder>* state_var, Note& note_to_nul
template <typename Builder> template <typename Note>
void Opcodes<Builder>::UTXO_INIT(StateVar<Builder>* 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;

Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/concepts/advanced/data_structures/trees.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. <!-- TODO: write about fragmented private state, somewhere. -->

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).
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dev_docs/wallets/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/aztec/src/constants_gen.nr
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr
Original file line number Diff line number Diff line change
@@ -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},
Expand All @@ -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]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/cbind/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<EndToEndContext> {
const config = { ...getConfigEnvVars(), ...opts };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit f83f027

Please sign in to comment.